Skip to content

Commit

Permalink
Fix Erev Purim on Sat nite
Browse files Browse the repository at this point in the history
  • Loading branch information
mjradwin committed Mar 19, 2024
1 parent aea34e0 commit 80d0bc2
Show file tree
Hide file tree
Showing 4 changed files with 111 additions and 77 deletions.
144 changes: 72 additions & 72 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@hebcal/leyning",
"version": "8.1.7",
"version": "8.1.8",
"author": "Michael J. Radwin (https://github.com/mjradwin)",
"keywords": [
"hebcal",
Expand Down Expand Up @@ -63,6 +63,6 @@
"eslint-config-google": "^0.14.0",
"jsdoc": "^4.0.2",
"jsdoc-to-markdown": "^8.0.1",
"rollup": "^4.12.1"
"rollup": "^4.13.0"
}
}
15 changes: 12 additions & 3 deletions src/getLeyningOnDate.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {HDate, HebrewCalendar, ParshaEvent, months} from '@hebcal/core';
import {HDate, HebrewCalendar, ParshaEvent, flags, months} from '@hebcal/core';
import {getLeyningForHoliday, getLeyningForHolidayKey} from './getLeyningForHoliday.js';
import {getLeyningKeyForEvent} from './getLeyningKeyForEvent.js';
import {getLeyningForParshaHaShavua, getWeekdayReading, makeLeyningNames} from './leyning.js';
Expand Down Expand Up @@ -62,20 +62,29 @@ function findParshaHaShavua(saturday, il) {
*/
export function getLeyningOnDate(hdate, il, wantarray = false) {
const dow = hdate.getDay();
const arr = [];
let hasParshaHaShavua = false;
if (dow === 6) {
const hyear = hdate.getFullYear();
const sedra = HebrewCalendar.getSedra(hyear, il);
const parsha = sedra.lookup(hdate);
if (!parsha.chag) {
const parshaEvent = new ParshaEvent(hdate, parsha.parsha, il);
const reading = getLeyningForParshaHaShavua(parshaEvent, il);
return wantarray ? [reading] : reading;
if (wantarray) {
hasParshaHaShavua = true;
arr.push(reading);
} else {
return reading;
}
}
}
const events = HebrewCalendar.getHolidaysOnDate(hdate, il) || [];
const arr = [];
let hasFullKriyah = false;
for (const ev of events) {
if (hasParshaHaShavua && (ev.getFlags() & flags.SPECIAL_SHABBAT)) {
continue;
}
const reading = getLeyningForHoliday(ev, il);
if (reading) {
arr.push(reading);
Expand Down
25 changes: 25 additions & 0 deletions src/getLeyningOnDate.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -270,3 +270,28 @@ test('getLeyningOnDate-weekday-erev9av', (t) => {
t.is(readings[0].name.en, 'Vaetchanan');
t.is(readings[1].name.en, 'Erev Tish\'a B\'Av');
});

test('getLeyningOnDate-erev9av-sat-nite', (t) => {
const hd = new HDate(8, 'Av', 5785);
const readings = getLeyningOnDate(hd, false, true);
t.is(readings.length, 2);
t.is(readings[0].name.en, 'Devarim');
t.is(readings[1].name.en, 'Erev Tish\'a B\'Av');
});

test('erev-purim-wed-nite', (t) => {
const hd = new HDate(13, 'Adar 2', 5782);
const readings = getLeyningOnDate(hd, false, true);
t.is(readings.length, 3);
t.is(readings[0].name.en, 'Ta\'anit Esther');
t.is(readings[1].name.en, 'Ta\'anit Esther (Mincha)');
t.is(readings[2].name.en, 'Erev Purim');
});

test('erev-purim-sat-nite', (t) => {
const hd = new HDate(13, 'Adar', 5784);
const readings = getLeyningOnDate(hd, false, true);
t.is(readings.length, 2);
t.is(readings[0].name.en, 'Vayikra');
t.is(readings[1].name.en, 'Erev Purim');
});

0 comments on commit 80d0bc2

Please sign in to comment.