Skip to content

Commit

Permalink
Add options.yizkor (default false) to CalOptions
Browse files Browse the repository at this point in the history
  • Loading branch information
mjradwin committed Nov 10, 2024
1 parent 12bd16b commit 83ee626
Show file tree
Hide file tree
Showing 5 changed files with 65 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/CalOptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};
19 changes: 19 additions & 0 deletions src/calendar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -315,6 +329,7 @@ const RECOGNIZED_OPTIONS: StringIntMap = {
hour12: 1,
dailyLearning: 1,
useElevation: 1,
yizkor: 1,
} as const satisfies Record<keyof CalOptions, 1>;

/**
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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;
}

Expand Down
2 changes: 2 additions & 0 deletions src/event.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ export const flags = {
NACH_YOMI: 0x2000000,
/** Daily Learning */
DAILY_LEARNING: 0x4000000,
/** Yizkor */
YIZKOR: 0x8000000,
} as const;

const flagToCategory = [
Expand Down
1 change: 1 addition & 0 deletions src/hebcal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
32 changes: 32 additions & 0 deletions test/hebcal.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});

0 comments on commit 83ee626

Please sign in to comment.