Skip to content

Commit

Permalink
Fix 8-digit date suffix for Asara B'Tevet when timed calendar
Browse files Browse the repository at this point in the history
  • Loading branch information
mjradwin committed Nov 4, 2024
1 parent 69bf489 commit 5f5c9cd
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 2 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@hebcal/core",
"version": "5.7.0",
"version": "5.7.1",
"author": "Michael J. Radwin (https://github.com/mjradwin)",
"contributors": [
"Eyal Schachter (https://github.com/Scimonster)",
Expand Down
9 changes: 8 additions & 1 deletion src/candles.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* eslint-disable max-len */
import {HDate, months} from '@hebcal/hdate';
import {HDate, months, isoDateString} from '@hebcal/hdate';
import {CalOptions} from './CalOptions';
import {Location} from './location';
import {Event, flags} from './event';
Expand Down Expand Up @@ -86,6 +86,13 @@ export class FastDayEvent extends HolidayEvent {
this.startEvent = startEvent;
this.endEvent = endEvent;
}
urlDateSuffix(): string {
if (this.getDesc() === "Asara B'Tevet") {
const isoDate = isoDateString(this.getDate().greg());
return isoDate.replace(/-/g, '');
}
return super.urlDateSuffix();
}
}

/**
Expand Down
21 changes: 21 additions & 0 deletions test/candles.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -395,6 +395,27 @@ test('fastStartEnd-TzomTammuz', () => {
expect(ev1.endEvent).toEqual(events[2]);
});

test('fastStartEnd Asara BTevet', () => {
const events0 = HebrewCalendar.calendar({
year: 2020,
location: Location.lookup('Providence'),
candlelighting: true,
});
const events = events0.filter((ev) => ev.getDesc() === 'Asara B\'Tevet');
expect(events.length).toBe(2);
expect(events[0]).toBeInstanceOf(FastDayEvent);
const urls = events.map((ev) => ev.url());
const expectedUrls = [
'https://www.hebcal.com/holidays/asara-btevet-20200107',
'https://www.hebcal.com/holidays/asara-btevet-20201225',
];
expect(urls).toEqual(expectedUrls);
const fastEv = events[0] as FastDayEvent;
expect(fastEv.startEvent).toBeDefined();
expect(fastEv.startEvent).toBeInstanceOf(TimedEvent);
expect(fastEv.startEvent?.getDesc()).toBe('Fast begins');
});

test('fastStartEnd-withoutHoliday', () => {
const events = HebrewCalendar.calendar({
start: new Date(2021, 5, 27),
Expand Down

0 comments on commit 5f5c9cd

Please sign in to comment.