From 83ee626bd05a102c560b3004ab0244ec6fa19444 Mon Sep 17 00:00:00 2001 From: "Michael J. Radwin" Date: Sat, 9 Nov 2024 18:28:03 -0800 Subject: [PATCH] Add options.yizkor (default false) to CalOptions --- src/CalOptions.ts | 11 +++++++++++ src/calendar.ts | 19 +++++++++++++++++++ src/event.ts | 2 ++ src/hebcal.ts | 1 + test/hebcal.spec.ts | 32 ++++++++++++++++++++++++++++++++ 5 files changed, 65 insertions(+) diff --git a/src/CalOptions.ts b/src/CalOptions.ts index 566019e..d54e212 100644 --- a/src/CalOptions.ts +++ b/src/CalOptions.ts @@ -158,4 +158,15 @@ export type CalOptions = { dailyLearning?: { [x: string]: DailyLearningValue; }; + /** + * Yizkor (Hebrew: יִזְכּוֹר) is an Ashkenazi Jewish memorial prayer service + * for the dead. Yizkor is recited in synagogue as part of the service + * during four holidays each year: + * 1. Yom Kippur + * 2. Shmini Atzeret + * 3. The final day of Passover (8th day Pesach in Diaspora, 7th day + * Pesach in Israel) + * 4. Shavuot (2nd day Shavuot in Diaspora) + */ + yizkor?: boolean; }; diff --git a/src/calendar.ts b/src/calendar.ts index e20cf08..25d397a 100644 --- a/src/calendar.ts +++ b/src/calendar.ts @@ -55,6 +55,7 @@ import {Location} from './location'; * * Shabbat Mevarchim HaChodesh on Saturday before Rosh Chodesh (`options.shabbatMevarchim`) * * Molad announcement on Saturday before Rosh Chodesh (`options.molad`) * * Yom Kippur Katan (`options.yomKippurKatan`) + * * Yizkor (`options.yizkor`) * * Daily Study of texts are supported by the * {@link https://github.com/hebcal/hebcal-learning @hebcal/learning} package, @@ -233,6 +234,18 @@ export function calendar(options: CalOptions = {}): Event[] { if (candlesEv) { evts.push(candlesEv); } + if (options.yizkor) { + const mm = hd.getMonth(); + const dd = hd.getDate(); + if ( + (mm === months.TISHREI && (dd === 10 || dd === 22)) || + (mm === NISAN && dd === (il ? 21 : 22)) || + (mm === SIVAN && dd === (il ? 6 : 7)) + ) { + const ev = new Event(hd, 'Yizkor', flags.YIZKOR, {emoji: '🕯️'}); + evts.push(ev); + } + } if ( options.addHebrewDates || (options.addHebrewDatesForEvents && prevEventsLength !== evts.length) @@ -277,6 +290,7 @@ const MINOR_HOLIDAY = flags.MINOR_HOLIDAY; const EREV = flags.EREV; const CHOL_HAMOED = flags.CHOL_HAMOED; const YOM_KIPPUR_KATAN = flags.YOM_KIPPUR_KATAN; +const YIZKOR = flags.YIZKOR; type StringIntMap = { [x: string]: number; @@ -315,6 +329,7 @@ const RECOGNIZED_OPTIONS: StringIntMap = { hour12: 1, dailyLearning: 1, useElevation: 1, + yizkor: 1, } as const satisfies Record; /** @@ -490,6 +505,9 @@ function getMaskFromOptions(options: CalOptions): number { if (options.yomKippurKatan) { mask |= YOM_KIPPUR_KATAN; } + if (options.yizkor) { + mask |= YIZKOR; + } if (options.dailyLearning) { const dailyLearning = options.dailyLearning; if (dailyLearning.dafYomi) { @@ -542,6 +560,7 @@ function setOptionsFromMask(options: CalOptions): number { if (m & OMER_COUNT) options.omer = true; if (m & SHABBAT_MEVARCHIM) options.shabbatMevarchim = true; if (m & YOM_KIPPUR_KATAN) options.yomKippurKatan = true; + if (m & YIZKOR) options.yizkor = true; return m; } diff --git a/src/event.ts b/src/event.ts index 8e2ff25..b3596b5 100644 --- a/src/event.ts +++ b/src/event.ts @@ -62,6 +62,8 @@ export const flags = { NACH_YOMI: 0x2000000, /** Daily Learning */ DAILY_LEARNING: 0x4000000, + /** Yizkor */ + YIZKOR: 0x8000000, } as const; const flagToCategory = [ diff --git a/src/hebcal.ts b/src/hebcal.ts index 455a1d7..55de259 100644 --- a/src/hebcal.ts +++ b/src/hebcal.ts @@ -79,6 +79,7 @@ export class HebrewCalendar { * * Shabbat Mevarchim HaChodesh on Saturday before Rosh Chodesh (`options.shabbatMevarchim`) * * Molad announcement on Saturday before Rosh Chodesh (`options.molad`) * * Yom Kippur Katan (`options.yomKippurKatan`) + * * Yizkor (`options.yizkor`) * * Daily Study of texts are supported by the * {@link https://github.com/hebcal/hebcal-learning @hebcal/learning} package, diff --git a/test/hebcal.spec.ts b/test/hebcal.spec.ts index 4ffd2da..de3267b 100644 --- a/test/hebcal.spec.ts +++ b/test/hebcal.spec.ts @@ -713,3 +713,35 @@ test('Eruv Tavshilin', () => { expect(HebrewCalendar.eruvTavshilin(new HDate(20, 'Cheshvan', 5785), false)).toBe(false); expect(HebrewCalendar.eruvTavshilin(new HDate(20, 'Cheshvan', 5785), true)).toBe(false); }); + +test('yikzor', () => { + const options: CalOptions = { + isHebrewYear: true, + year: 5786, + noHolidays: true, + yizkor: true, + il: true, + }; + const events = HebrewCalendar.calendar(options); + expect(events.length).toBe(4); + const actualIL = events.map(eventISODateDesc); + const expectedIL = [ + { date: '2025-10-02', desc: 'Yizkor' }, + { date: '2025-10-14', desc: 'Yizkor' }, + { date: '2026-04-08', desc: 'Yizkor' }, + { date: '2026-05-22', desc: 'Yizkor' } + ]; + expect(actualIL).toEqual(expectedIL); + + options.il = false; + const diaspora = HebrewCalendar.calendar(options); + expect(diaspora.length).toBe(4); + const actualD = diaspora.map(eventISODateDesc); + const expectedD = [ + { date: '2025-10-02', desc: 'Yizkor' }, + { date: '2025-10-14', desc: 'Yizkor' }, + { date: '2026-04-09', desc: 'Yizkor' }, + { date: '2026-05-23', desc: 'Yizkor' } + ]; + expect(actualD).toEqual(expectedD); +});