From 5f5c9cd9eb2ba1ff1cf2ce7519a1cc7293d76ff7 Mon Sep 17 00:00:00 2001 From: "Michael J. Radwin" Date: Sun, 3 Nov 2024 16:48:41 -0800 Subject: [PATCH] Fix 8-digit date suffix for Asara B'Tevet when timed calendar --- package.json | 2 +- src/candles.ts | 9 ++++++++- test/candles.spec.ts | 21 +++++++++++++++++++++ 3 files changed, 30 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index bae7487..7cc5fef 100644 --- a/package.json +++ b/package.json @@ -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)", diff --git a/src/candles.ts b/src/candles.ts index 06f9c6b..073fe3f 100644 --- a/src/candles.ts +++ b/src/candles.ts @@ -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'; @@ -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(); + } } /** diff --git a/test/candles.spec.ts b/test/candles.spec.ts index 0e456dc..9cfb833 100644 --- a/test/candles.spec.ts +++ b/test/candles.spec.ts @@ -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),