Skip to content

Commit

Permalink
Fix Israel/Diaspora other link errors for Triennial before 5744
Browse files Browse the repository at this point in the history
  • Loading branch information
mjradwin committed Jul 17, 2024
1 parent 572ad0f commit dc7c050
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 10 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
"@hebcal/leyning": "^8.2.2",
"@hebcal/locales": "^5.0.1",
"@hebcal/rest-api": "^5.1.2",
"@hebcal/triennial": "^5.1.1",
"@hebcal/triennial": "^5.1.2",
"better-sqlite3": "^11.1.2",
"dayjs": "^1.11.11",
"ejs": "^3.1.10",
Expand Down
31 changes: 22 additions & 9 deletions src/sedrot.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,18 @@ for (const parshaName of allParshiot) {
items15yrDiaspora.set(parshaName, get15yrEvents(parshaName, false));
}

function simchatTorahDate(hyear, il) {
const mday = il ? 22 : 23;
return new HDate(mday, months.TISHREI, hyear);
}

function makeVezotEvents(il) {
const startYear = new HDate().getFullYear() - 2;
const mday = il ? 22 : 23;
const events = [];
for (let i = 0; i < 18; i++) {
const hyear = startYear + i;
const pe = new ParshaEvent(new HDate(mday, months.TISHREI, hyear), [VEZOT_HABERAKHAH], il);
const hd = simchatTorahDate(hyear, il);
const pe = new ParshaEvent(hd, [VEZOT_HABERAKHAH], il);
events.push(pe);
}
return events;
Expand Down Expand Up @@ -271,10 +276,7 @@ function doTriennialDiffer(a, b) {
if (a.readSeparately && b.readSeparately) {
return false;
}
if (!a.date.isSameDate(b)) {
return true;
}
return false;
return !a.date.isSameDate(b);
}

/**
Expand All @@ -287,7 +289,15 @@ function doTriennialDiffer(a, b) {
function doIsraelDiasporaDiffer(parsha, il, hd, triennial) {
const parshaName = parsha.name;
const hyear = hd.getFullYear();
if (parshaName === VEZOT_HABERAKHAH) {
const otherHD = simchatTorahDate(hyear, !il);
const anchor = parshaDateAnchor(parshaName, dayjs(otherHD.greg()), !il);
return [true, anchor, parshaName];
}
if (triennial.readings) {
if (hyear < 5744) {
return [false, '', ''];
}
// compare each 3-year index page
const otherReadings = make3yearTriennial(hyear, parshaName, !il);
for (let yr = 0; yr <= 2; yr++) {
Expand Down Expand Up @@ -320,12 +330,15 @@ function doIsraelDiasporaDiffer(parsha, il, hd, triennial) {
return [true, anchor, pair];
}
}
if (hyear < 5744) {
return [false, '', ''];
}
const otherTriennial = getRawTriennial(parshaName, hd, !il);
if (doTriennialDiffer(otherTriennial, triennial)) {
const anchor = parshaDateAnchor(parshaName, dayjs(hd.greg()), !il);
return [true, anchor, parshaName];
}
return [false, '', parshaName];
return [false, '', ''];
}

function makePrevNext(parsha, date, hd, il) {
Expand Down Expand Up @@ -529,8 +542,8 @@ function findParshaEvent(events, parshaName, il) {
if (parshaName === VEZOT_HABERAKHAH) {
const bereshit = events.find((ev) => ev.getDesc() === 'Parashat Bereshit');
const hyear = bereshit.getDate().getFullYear();
const mday = il ? 22 : 23;
return new ParshaEvent(new HDate(mday, months.TISHREI, hyear), [parshaName], il);
const hd = simchatTorahDate(hyear, il);
return new ParshaEvent(hd, [parshaName], il);
}
const desc = 'Parashat ' + parshaName;
const event = events.find((ev) => ev.getDesc() === desc);
Expand Down

0 comments on commit dc7c050

Please sign in to comment.