Skip to content

Commit

Permalink
Add leyning for Erev Simchat Torah
Browse files Browse the repository at this point in the history
  • Loading branch information
mjradwin committed Jun 27, 2024
1 parent ce014e4 commit 40b5eb1
Show file tree
Hide file tree
Showing 11 changed files with 95 additions and 18 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@hebcal/leyning",
"version": "8.2.1",
"version": "8.2.2",
"author": "Michael J. Radwin (https://github.com/mjradwin)",
"keywords": [
"hebcal",
Expand Down
21 changes: 14 additions & 7 deletions src/aliyot.json
Original file line number Diff line number Diff line change
Expand Up @@ -1040,7 +1040,8 @@
"3":["33:13","33:17"]
}},
"Vayakhel-Pekudei":{
"num":101,"combined":true,
"num":[22,23],
"combined":true,
"p1":"Vayakhel",
"p2":"Pekudei",
"num1":22,
Expand All @@ -1057,7 +1058,8 @@
"M":["40:34","40:38"]}
},
"Tazria-Metzora":{
"num":102,"combined":true,
"num":[27,28],
"combined":true,
"p1":"Tazria",
"p2":"Metzora",
"num1":27,
Expand All @@ -1074,7 +1076,8 @@
"M":["15:31","15:33"]}
},
"Achrei Mot-Kedoshim":{
"num":103,"combined":true,
"num":[29,30],
"combined":true,
"p1":"Achrei Mot",
"p2":"Kedoshim",
"num1":29,
Expand All @@ -1092,7 +1095,8 @@
"7":["20:8","20:27"],
"M":["20:25","20:27"]}},
"Behar-Bechukotai":{
"num":104,"combined":true,
"num":[32,33],
"combined":true,
"p1":"Behar",
"p2":"Bechukotai",
"num1":32,
Expand All @@ -1109,7 +1113,8 @@
"M":["27:32","27:34"]}
},
"Chukat-Balak":{
"num":105,"combined":true,
"num":[39,40],
"combined":true,
"p1":"Chukat",
"p2":"Balak",
"num1":39,
Expand All @@ -1126,7 +1131,8 @@
"M":["25:7","25:9"]}
},
"Matot-Masei":{
"num":106,"combined":true,
"num":[42,43],
"combined":true,
"p1":"Matot",
"p2":"Masei",
"num1":42,
Expand All @@ -1143,7 +1149,8 @@
"M":["36:11","36:13"]}
},
"Nitzavim-Vayeilech":{
"num":107,"combined":true,
"num":[51,52],
"combined":true,
"p1":"Nitzavim",
"p2":"Vayeilech",
"num1":51,
Expand Down
6 changes: 6 additions & 0 deletions src/csv.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,12 @@ export function writeFullKriyahEvent(stream: WriteStream, ev: Event, il: boolean
writeCsvLines(stream, ev, reading, il, isParsha);
if (!isParsha) {
writeHolidayMincha(stream, ev as HolidayEvent, il);
const desc = ev.getDesc();
if ((il && desc === 'Sukkot VII (Hoshana Raba)') ||
(!il && desc === 'Shmini Atzeret')) {
const ev2 = new HolidayEvent(ev.getDate(), 'Erev Simchat Torah', flags.EREV);
writeFullKriyahEvent(stream, ev2, il);
}
}
}
}
Expand Down
7 changes: 7 additions & 0 deletions src/getLeyningOnDate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,13 @@ export function getLeyningOnDate(hdate: HDate, il: boolean, wantarray: boolean =
if (mincha) {
arr.push(mincha);
}
// Special case for Erev Simchat Torah - the only time we read Torah at night
const desc = ev.getDesc();
if ((il && desc === 'Sukkot VII (Hoshana Raba)') ||
(!il && desc === 'Shmini Atzeret')) {
const erevST = getLeyningForHolidayKey('Erev Simchat Torah');
arr.push(erevST!);
}
}
}
if (!hasFullKriyah && (dow === 1 || dow === 4)) {
Expand Down
4 changes: 2 additions & 2 deletions src/leyning.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ type JsonParshaMap = {
}

type JsonParsha = {
num: number;
num: number | number[];
hebrew?: string;
book: number;
haft?: JsonAliyah | JsonAliyah[];
Expand Down Expand Up @@ -107,7 +107,7 @@ function getLeyningForParshaShabbatOnly(parsha: string | string[]): Leyning {
const hkey = getHaftaraKey(parshaNameArray);
const haft0 = parshiyotObj[hkey].haft;
if (haft0) {
const haft = result.haft = cloneHaftara(haft0!);
const haft = result.haft = cloneHaftara(haft0);
result.haftara = makeSummaryFromParts(haft);
result.haftaraNumV = sumVerses(haft);
}
Expand Down
2 changes: 1 addition & 1 deletion src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export type LeyningNames = {
*/
export type ParshaMeta = {
/** 1 for Bereshit, 2 for Noach, etc. `undefined` for holiday readings */
num: number;
num: number | number[];
/** parsha name in Hebrew with niqud */
hebrew: string;
/** 1 for Genesis, 2 for Exodus, 5 for Deuteronomy */
Expand Down
28 changes: 24 additions & 4 deletions test/csv.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,19 +107,39 @@ test('writeFullKriyahEvent-9av', () => {
expect(lines).toEqual(expected);
});

test.skip('writeFullKriyahEvent-SimchatTorah', () => {
test('writeFullKriyahEvent-SimchatTorah', () => {
const events = HebrewCalendar.calendar({
start: new HDate(22, months.TISHREI, 5784),
end: new HDate(23, months.TISHREI, 5784),
start: new HDate(22, months.TISHREI, 5783),
end: new HDate(23, months.TISHREI, 5783),
il: false,
});
expect(events.length).toBe(2);
const stream = new StringWritable();
events.forEach((ev) => writeFullKriyahEvent(stream, ev, false));
const lines = stream.toString().split('\r\n');
console.log(lines);
// Erev Simchat Torah
const expected = [
'17-Oct-2022,"Shmini Atzeret",1,"Deuteronomy 14:22-14:29",8',
'17-Oct-2022,"Shmini Atzeret",2,"Deuteronomy 15:1-15:18",18',
'17-Oct-2022,"Shmini Atzeret",3,"Deuteronomy 15:19-16:3",8',
'17-Oct-2022,"Shmini Atzeret",4,"Deuteronomy 16:4-16:8",5',
'17-Oct-2022,"Shmini Atzeret",5,"Deuteronomy 16:9-16:17",9',
'17-Oct-2022,"Shmini Atzeret","maf","Numbers 29:35-30:1",6',
'17-Oct-2022,"Shmini Atzeret","Haftara","I Kings 8:54-66",13',
'',
'17-Oct-2022,"Erev Simchat Torah",1,"Deuteronomy 33:1-33:7",7',
'17-Oct-2022,"Erev Simchat Torah",2,"Deuteronomy 33:8-33:12",5',
'17-Oct-2022,"Erev Simchat Torah",3,"Deuteronomy 33:13-33:17",5',
'',
'18-Oct-2022,"Simchat Torah",1,"Deuteronomy 33:1-33:7",7',
'18-Oct-2022,"Simchat Torah",2,"Deuteronomy 33:8-33:12",5',
'18-Oct-2022,"Simchat Torah",3,"Deuteronomy 33:13-33:17",5',
'18-Oct-2022,"Simchat Torah",4,"Deuteronomy 33:18-33:21",4',
'18-Oct-2022,"Simchat Torah",5,"Deuteronomy 33:22-33:26",5',
'18-Oct-2022,"Simchat Torah",6,"Deuteronomy 33:27-34:12",15',
'18-Oct-2022,"Simchat Torah",7,"Genesis 1:1-2:3",34',
'18-Oct-2022,"Simchat Torah","maf","Numbers 29:35-30:1",6',
'18-Oct-2022,"Simchat Torah","Haftara","Joshua 1:1-18",18',
'', ''];
expect(lines).toEqual(expected);
});
Expand Down
2 changes: 1 addition & 1 deletion test/getLeyningForParsha.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ test('getLeyningForParsha-2', () => {
'Matot',
'Masei',
],
parshaNum: 106,
parshaNum: [42, 43],
summary: 'Numbers 30:2-36:13',
fullkriyah: {
'1': {k: 'Numbers', b: '30:2', e: '31:12', v: 28},
Expand Down
14 changes: 14 additions & 0 deletions test/getLeyningOnDate.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -299,3 +299,17 @@ test('erev-purim-sat-nite', () => {
expect(readings[0].name.en).toBe('Vayikra');
expect(readings[1].name.en).toBe('Erev Purim');
});

test('Erev Simchat Torah Diaspora', () => {
const hd = new HDate(22, 'Tishrei', 5783);
const readings = getLeyningOnDate(hd, false, true);
expect(readings.length).toBe(2);
expect(readings[1].name.en).toBe('Erev Simchat Torah');
});

test('Erev Simchat Torah Israel', () => {
const hd = new HDate(21, 'Tishrei', 5783);
const readings = getLeyningOnDate(hd, true, true);
expect(readings.length).toBe(2);
expect(readings[1].name.en).toBe('Erev Simchat Torah');
});
25 changes: 24 additions & 1 deletion test/holiday.spec.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {HDate, HebrewCalendar, Event, months, flags, HolidayEvent} from '@hebcal/core';
import {Event, HDate, HebrewCalendar, HolidayEvent, flags, months} from '@hebcal/core';
import {getLeyningForHoliday, getLeyningForHolidayKey} from '../src/getLeyningForHoliday';
import {getLeyningKeyForEvent} from '../src/getLeyningKeyForEvent';
import {formatAliyahWithBook} from '../src/common';
Expand Down Expand Up @@ -635,3 +635,26 @@ test('getLeyningForHolidayKey-note', () => {
const reading = getLeyningForHolidayKey('Shushan Purim', undefined, true);
expect(reading.note).toBe('Jerusalem & walled cities only');
});

test('Erev Simchat Torah', () => {
// Disapora
const ev = new HolidayEvent(new HDate(22, months.TISHREI, 5783),
'Erev Simchat Torah', flags.EREV);
const reading = getLeyningForHoliday(ev, false);
const expected = {
name: {en: 'Erev Simchat Torah', he: 'עֶרֶב שִׂמְחַת תּוֹרָה'},
fullkriyah: {
'1': {p: 54, k: 'Deuteronomy', b: '33:1', e: '33:7', v: 7},
'2': {p: 54, k: 'Deuteronomy', b: '33:8', e: '33:12', v: 5},
'3': {p: 54, k: 'Deuteronomy', b: '33:13', e: '33:17', v: 5},
},
summary: 'Deuteronomy 33:1-17',
};
expect(reading).toEqual(expected);

// Israel
const ev2 = new HolidayEvent(new HDate(21, months.TISHREI, 5783),
'Erev Simchat Torah', flags.EREV);
const reading2 = getLeyningForHoliday(ev2, true);
expect(reading2).toEqual(expected);
});
2 changes: 1 addition & 1 deletion test/lookupParsha.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ test('lookupParsha-combined', () => {
const meta = lookupParsha(['Tazria', 'Metzora']);
const expected = {
'hebrew': 'תַזְרִיעַ־מְּצֹרָע',
'num': 102,
'num': [27, 28],
'combined': true,
'p1': 'Tazria',
'p2': 'Metzora',
Expand Down

0 comments on commit 40b5eb1

Please sign in to comment.