@hebcal/leyning 8.2.6 → 8.2.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bundle.js +102 -74
- package/dist/bundle.min.js +2 -2
- package/dist/common.d.ts +9 -1
- package/dist/getLeyningOnDate.d.ts +2 -1
- package/dist/index.cjs +102 -74
- package/dist/index.d.ts +1 -1
- package/dist/index.mjs +102 -75
- package/dist/module.d.ts +12 -3
- package/package.json +12 -12
package/dist/bundle.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! @hebcal/leyning v8.2.
|
|
1
|
+
/*! @hebcal/leyning v8.2.8 */
|
|
2
2
|
var hebcal__leyning = (function (exports, core) {
|
|
3
3
|
'use strict';
|
|
4
4
|
|
|
@@ -54,7 +54,19 @@ var numverses = {
|
|
|
54
54
|
* Names of the books of the Torah. BOOK[1] === 'Genesis'
|
|
55
55
|
* @readonly
|
|
56
56
|
*/
|
|
57
|
-
const BOOK = [
|
|
57
|
+
const BOOK = [
|
|
58
|
+
'',
|
|
59
|
+
'Genesis',
|
|
60
|
+
'Exodus',
|
|
61
|
+
'Leviticus',
|
|
62
|
+
'Numbers',
|
|
63
|
+
'Deuteronomy',
|
|
64
|
+
];
|
|
65
|
+
/**
|
|
66
|
+
* The number of verses in each book of the Tanakh.
|
|
67
|
+
* @readonly
|
|
68
|
+
*/
|
|
69
|
+
const NUM_VERSES = numverses;
|
|
58
70
|
/**
|
|
59
71
|
* Formats parsha as a string
|
|
60
72
|
* @param parsha untranslated name like 'Pinchas' or ['Pinchas'] or ['Matot','Masei']
|
|
@@ -63,11 +75,13 @@ function parshaToString(parsha) {
|
|
|
63
75
|
if (typeof parsha === 'string') {
|
|
64
76
|
return parsha;
|
|
65
77
|
}
|
|
66
|
-
else if (!Array.isArray(parsha) ||
|
|
78
|
+
else if (!Array.isArray(parsha) ||
|
|
79
|
+
parsha.length === 0 ||
|
|
80
|
+
parsha.length > 2) {
|
|
67
81
|
throw new TypeError(`Bad parsha argument: ${parsha}`);
|
|
68
82
|
}
|
|
69
83
|
let s = parsha[0];
|
|
70
|
-
if (parsha.length
|
|
84
|
+
if (parsha.length === 2) {
|
|
71
85
|
s += '-' + parsha[1];
|
|
72
86
|
}
|
|
73
87
|
return s;
|
|
@@ -91,7 +105,7 @@ function calculateNumVerses(aliyah) {
|
|
|
91
105
|
aliyah.v = v2 - v1 + 1;
|
|
92
106
|
}
|
|
93
107
|
else if (typeof aliyah.k === 'string') {
|
|
94
|
-
const numv =
|
|
108
|
+
const numv = NUM_VERSES[aliyah.k];
|
|
95
109
|
if (typeof numv !== 'object' || !numv.length) {
|
|
96
110
|
throw new ReferenceError(`Can't find numverses for ${aliyah.k}`);
|
|
97
111
|
}
|
|
@@ -130,16 +144,16 @@ function formatAliyahShort(aliyah, showBook) {
|
|
|
130
144
|
* @private
|
|
131
145
|
*/
|
|
132
146
|
function isChapVerseBefore(a, b) {
|
|
133
|
-
const cv1 = a.split(':').map(
|
|
134
|
-
const cv2 = b.split(':').map(
|
|
135
|
-
return
|
|
147
|
+
const cv1 = a.split(':').map(x => +x);
|
|
148
|
+
const cv2 = b.split(':').map(x => +x);
|
|
149
|
+
return cv1[0] * 100 + cv1[1] < cv2[0] * 100 + cv2[1];
|
|
136
150
|
}
|
|
137
151
|
/**
|
|
138
152
|
* Summarizes an `AliyotMap` by collapsing all adjacent aliyot.
|
|
139
153
|
* Finds any non-overlapping parts (e.g. special 7th aliyah or maftir)
|
|
140
154
|
*/
|
|
141
155
|
function makeLeyningParts(aliyot) {
|
|
142
|
-
const nums = Object.keys(aliyot).filter(
|
|
156
|
+
const nums = Object.keys(aliyot).filter(x => {
|
|
143
157
|
if (x.length === 1) {
|
|
144
158
|
return true;
|
|
145
159
|
}
|
|
@@ -152,15 +166,17 @@ function makeLeyningParts(aliyot) {
|
|
|
152
166
|
for (let i = 0; i < nums.length; i++) {
|
|
153
167
|
const num = nums[i];
|
|
154
168
|
const aliyah = aliyot[num];
|
|
155
|
-
if (
|
|
169
|
+
if (i === nums.length - 1 && aliyah.k === end.k && aliyah.e === end.e) {
|
|
156
170
|
// short-circuit when final aliyah is within the previous (e.g. M inside of 7)
|
|
157
171
|
continue;
|
|
158
172
|
}
|
|
159
|
-
const prevEndChap = +
|
|
160
|
-
const curStartChap = +
|
|
173
|
+
const prevEndChap = +end.e.split(':')[0];
|
|
174
|
+
const curStartChap = +aliyah.b.split(':')[0];
|
|
161
175
|
const sameOrNextChap = curStartChap === prevEndChap || curStartChap === prevEndChap + 1;
|
|
162
|
-
if (
|
|
163
|
-
(aliyah.k !== start.k ||
|
|
176
|
+
if (i !== 0 &&
|
|
177
|
+
(aliyah.k !== start.k ||
|
|
178
|
+
isChapVerseBefore(aliyah.b, start.e) ||
|
|
179
|
+
!sameOrNextChap)) {
|
|
164
180
|
parts.push({ k: start.k, b: start.b, e: end.e });
|
|
165
181
|
start = aliyah;
|
|
166
182
|
}
|
|
@@ -226,7 +242,9 @@ function cloneHaftara(haft) {
|
|
|
226
242
|
* Returns the total number of verses in an array of Aliyah (or haftarah) objects
|
|
227
243
|
*/
|
|
228
244
|
function sumVerses(aliyot) {
|
|
229
|
-
return Array.isArray(aliyot)
|
|
245
|
+
return Array.isArray(aliyot)
|
|
246
|
+
? aliyot.reduce((prev, cur) => prev + cur.v, 0)
|
|
247
|
+
: aliyot.v;
|
|
230
248
|
}
|
|
231
249
|
|
|
232
250
|
var festivals0 = { "Pesach I": {
|
|
@@ -881,9 +899,15 @@ function lookupFestival(holiday) {
|
|
|
881
899
|
return result;
|
|
882
900
|
}
|
|
883
901
|
|
|
884
|
-
const HOLIDAY_IGNORE_MASK = core.flags.DAF_YOMI |
|
|
885
|
-
core.flags.
|
|
886
|
-
core.flags.
|
|
902
|
+
const HOLIDAY_IGNORE_MASK = core.flags.DAF_YOMI |
|
|
903
|
+
core.flags.OMER_COUNT |
|
|
904
|
+
core.flags.SHABBAT_MEVARCHIM |
|
|
905
|
+
core.flags.MOLAD |
|
|
906
|
+
core.flags.USER_EVENT |
|
|
907
|
+
core.flags.HEBREW_DATE |
|
|
908
|
+
core.flags.MISHNA_YOMI |
|
|
909
|
+
core.flags.MODERN_HOLIDAY |
|
|
910
|
+
core.flags.YERUSHALMI_YOMI;
|
|
887
911
|
/**
|
|
888
912
|
* Based on the event date, type and title, finds the relevant leyning key
|
|
889
913
|
* @param ev event
|
|
@@ -907,17 +931,19 @@ function getLeyningKeyForEvent(ev, il = false) {
|
|
|
907
931
|
const day = hd.getDate();
|
|
908
932
|
const dow = hd.abs() % 7;
|
|
909
933
|
const month = hd.getMonth();
|
|
910
|
-
const isShabbat =
|
|
911
|
-
const isRoshChodesh =
|
|
934
|
+
const isShabbat = dow === 6;
|
|
935
|
+
const isRoshChodesh = day === 1 || day === 30;
|
|
912
936
|
const holiday = ev.basename();
|
|
913
937
|
const isPesach = holiday === 'Pesach';
|
|
914
938
|
if (il && isPesach) {
|
|
915
939
|
if (isShabbat) {
|
|
916
|
-
return day === 15 || day === 21
|
|
940
|
+
return day === 15 || day === 21
|
|
941
|
+
? desc + ' (on Shabbat)'
|
|
942
|
+
: 'Pesach Shabbat Chol ha-Moed';
|
|
917
943
|
}
|
|
918
944
|
return desc;
|
|
919
945
|
}
|
|
920
|
-
if (day
|
|
946
|
+
if (day === 1 && month === core.months.TISHREI) {
|
|
921
947
|
return isShabbat ? 'Rosh Hashana I (on Shabbat)' : 'Rosh Hashana I';
|
|
922
948
|
}
|
|
923
949
|
const cholHaMoedDay = ev.cholHaMoedDay;
|
|
@@ -926,14 +952,14 @@ function getLeyningKeyForEvent(ev, il = false) {
|
|
|
926
952
|
if (isShabbat) {
|
|
927
953
|
return holiday + ' Shabbat Chol ha-Moed';
|
|
928
954
|
}
|
|
929
|
-
else if (desc
|
|
955
|
+
else if (desc === 'Sukkot VII (Hoshana Raba)') {
|
|
930
956
|
return 'Sukkot Final Day (Hoshana Raba)';
|
|
931
957
|
}
|
|
932
958
|
if (isPesach && cholHaMoedDay) {
|
|
933
|
-
if (dow === 0 && desc ===
|
|
959
|
+
if (dow === 0 && desc === "Pesach IV (CH''M)") {
|
|
934
960
|
return 'Pesach Chol ha-Moed Day 2 on Sunday';
|
|
935
961
|
}
|
|
936
|
-
else if (dow === 1 && desc ===
|
|
962
|
+
else if (dow === 1 && desc === "Pesach V (CH''M)") {
|
|
937
963
|
return 'Pesach Chol ha-Moed Day 3 on Monday';
|
|
938
964
|
}
|
|
939
965
|
}
|
|
@@ -944,8 +970,8 @@ function getLeyningKeyForEvent(ev, il = false) {
|
|
|
944
970
|
if (isShabbat && isRoshChodesh) {
|
|
945
971
|
return 'Shabbat Rosh Chodesh Chanukah';
|
|
946
972
|
}
|
|
947
|
-
else if (isRoshChodesh && chanukahDay
|
|
948
|
-
return
|
|
973
|
+
else if (isRoshChodesh && chanukahDay === 7) {
|
|
974
|
+
return 'Chanukah Day 7 (on Rosh Chodesh)';
|
|
949
975
|
}
|
|
950
976
|
else if (isShabbat) {
|
|
951
977
|
return `Chanukah Day ${chanukahDay} (on Shabbat)`;
|
|
@@ -954,16 +980,17 @@ function getLeyningKeyForEvent(ev, il = false) {
|
|
|
954
980
|
return `Chanukah Day ${chanukahDay}`;
|
|
955
981
|
}
|
|
956
982
|
}
|
|
957
|
-
if (isRoshChodesh &&
|
|
983
|
+
if (isRoshChodesh &&
|
|
984
|
+
(desc === 'Shabbat HaChodesh' || desc === 'Shabbat Shekalim')) {
|
|
958
985
|
return desc + ' (on Rosh Chodesh)';
|
|
959
986
|
}
|
|
960
|
-
if (il && desc
|
|
987
|
+
if (il && desc === 'Shmini Atzeret') {
|
|
961
988
|
return 'Simchat Torah';
|
|
962
989
|
}
|
|
963
990
|
if (desc === 'Chag HaBanot') {
|
|
964
991
|
return undefined;
|
|
965
992
|
}
|
|
966
|
-
if (isShabbat && 'Shabbat'
|
|
993
|
+
if (isShabbat && 'Shabbat' !== desc.substring(0, 7)) {
|
|
967
994
|
if (isRoshChodesh) {
|
|
968
995
|
if (desc === 'Rosh Chodesh Tevet') {
|
|
969
996
|
return 'Shabbat Rosh Chodesh Chanukah';
|
|
@@ -1001,8 +1028,8 @@ function getLeyningKeyForEvent(ev, il = false) {
|
|
|
1001
1028
|
if (isRoshChodesh) {
|
|
1002
1029
|
return desc;
|
|
1003
1030
|
}
|
|
1004
|
-
if (desc ===
|
|
1005
|
-
return
|
|
1031
|
+
if (desc === "Tish'a B'Av (observed)") {
|
|
1032
|
+
return "Tish'a B'Av";
|
|
1006
1033
|
}
|
|
1007
1034
|
return undefined;
|
|
1008
1035
|
}
|
|
@@ -1079,7 +1106,7 @@ function specialReadings2(parsha, hd, il, aliyot) {
|
|
|
1079
1106
|
}
|
|
1080
1107
|
const parshaName = parshaToString(parsha);
|
|
1081
1108
|
const events0 = core.HebrewCalendar.getHolidaysOnDate(hd, il) || [];
|
|
1082
|
-
const events = events0.filter(
|
|
1109
|
+
const events = events0.filter(ev => !(ev.getFlags() & core.flags.ROSH_CHODESH));
|
|
1083
1110
|
for (const ev of events) {
|
|
1084
1111
|
if (ev.getDesc() === 'Shabbat Shuva') {
|
|
1085
1112
|
handleSpecial(`Shabbat Shuva (with ${parshaName})`);
|
|
@@ -1099,9 +1126,9 @@ function specialReadings2(parsha, hd, il, aliyot) {
|
|
|
1099
1126
|
handleSpecial('Pinchas occurring after 17 Tammuz');
|
|
1100
1127
|
}
|
|
1101
1128
|
else if (day === 30 || day === 1) {
|
|
1102
|
-
const key =
|
|
1103
|
-
`${parshaName} on Shabbat Rosh Chodesh`
|
|
1104
|
-
'Shabbat Rosh Chodesh';
|
|
1129
|
+
const key = parshaName === 'Masei' || parshaName === 'Matot-Masei'
|
|
1130
|
+
? `${parshaName} on Shabbat Rosh Chodesh`
|
|
1131
|
+
: 'Shabbat Rosh Chodesh';
|
|
1105
1132
|
handleSpecial(key);
|
|
1106
1133
|
}
|
|
1107
1134
|
else if (parshaName === 'Ki Teitzei' && day === 14) {
|
|
@@ -1113,7 +1140,8 @@ function specialReadings2(parsha, hd, il, aliyot) {
|
|
|
1113
1140
|
// Source: Luaḥ Hashanah, Rabbi Miles B. Cohen and Leslie Rubin
|
|
1114
1141
|
handleSpecial('Ki Teitzei with 3rd Haftarah of Consolation');
|
|
1115
1142
|
}
|
|
1116
|
-
else if (parshaName === 'Kedoshim' &&
|
|
1143
|
+
else if (parshaName === 'Kedoshim' &&
|
|
1144
|
+
(day === 26 || day === 28 || day === 6)) {
|
|
1117
1145
|
// Kedoshim is read separately from Achrei Mot in ~37% of years.
|
|
1118
1146
|
// When this happens, it is will be read on
|
|
1119
1147
|
// 26th or 28th of Nisan (Achrei Mot was Shabbat HaGadol, ~10%),
|
|
@@ -1153,7 +1181,9 @@ function getLeyningForHolidayKey(key, cholHaMoedDay, il) {
|
|
|
1153
1181
|
return undefined;
|
|
1154
1182
|
}
|
|
1155
1183
|
const israelOnly = src.il;
|
|
1156
|
-
if (typeof israelOnly === 'boolean' &&
|
|
1184
|
+
if (typeof israelOnly === 'boolean' &&
|
|
1185
|
+
typeof il === 'boolean' &&
|
|
1186
|
+
il !== israelOnly) {
|
|
1157
1187
|
return undefined;
|
|
1158
1188
|
}
|
|
1159
1189
|
const leyning = {
|
|
@@ -1177,21 +1207,21 @@ function getLeyningForHolidayKey(key, cholHaMoedDay, il) {
|
|
|
1177
1207
|
leyning.summaryParts = parts;
|
|
1178
1208
|
}
|
|
1179
1209
|
}
|
|
1180
|
-
Object.values(leyning.fullkriyah).map(
|
|
1210
|
+
Object.values(leyning.fullkriyah).map(aliyah => calculateNumVerses(aliyah));
|
|
1181
1211
|
}
|
|
1182
1212
|
if (src.haft) {
|
|
1183
|
-
const haft = leyning.haft = cloneHaftara(src.haft);
|
|
1213
|
+
const haft = (leyning.haft = cloneHaftara(src.haft));
|
|
1184
1214
|
leyning.haftara = makeSummaryFromParts(haft);
|
|
1185
1215
|
leyning.haftaraNumV = sumVerses(haft);
|
|
1186
1216
|
}
|
|
1187
1217
|
if (src.seph) {
|
|
1188
|
-
const seph = leyning.seph = cloneHaftara(src.seph);
|
|
1218
|
+
const seph = (leyning.seph = cloneHaftara(src.seph));
|
|
1189
1219
|
leyning.sephardic = makeSummaryFromParts(seph);
|
|
1190
1220
|
leyning.sephardicNumV = sumVerses(seph);
|
|
1191
1221
|
}
|
|
1192
1222
|
if (src.megillah) {
|
|
1193
1223
|
const book = src.megillah;
|
|
1194
|
-
const chaps =
|
|
1224
|
+
const chaps = NUM_VERSES[book];
|
|
1195
1225
|
const m = {};
|
|
1196
1226
|
for (let i = 1; i < chaps.length; i++) {
|
|
1197
1227
|
const numv = chaps[i];
|
|
@@ -2523,10 +2553,10 @@ const parshiyotObj = parshiyotObj0;
|
|
|
2523
2553
|
*/
|
|
2524
2554
|
function getHaftaraKey(parsha) {
|
|
2525
2555
|
const first = parsha[0];
|
|
2526
|
-
if (parsha.length === 2 && first
|
|
2556
|
+
if (parsha.length === 2 && first === 'Achrei Mot') {
|
|
2527
2557
|
return parshaToString(parsha); // 'Achrei Mot-Kedoshim'
|
|
2528
2558
|
}
|
|
2529
|
-
if (parsha.length === 1 || first
|
|
2559
|
+
if (parsha.length === 1 || first === 'Nitzavim') {
|
|
2530
2560
|
return first;
|
|
2531
2561
|
}
|
|
2532
2562
|
else {
|
|
@@ -2541,7 +2571,7 @@ function makeLeyningNames(parsha) {
|
|
|
2541
2571
|
const name = parshaToString(parsha);
|
|
2542
2572
|
return {
|
|
2543
2573
|
en: name,
|
|
2544
|
-
he: parsha.map(
|
|
2574
|
+
he: parsha.map(s => core.Locale.lookupTranslation(s, 'he')).join('־'),
|
|
2545
2575
|
};
|
|
2546
2576
|
}
|
|
2547
2577
|
/**
|
|
@@ -2578,13 +2608,13 @@ function getLeyningForParshaShabbatOnly(parsha) {
|
|
|
2578
2608
|
const hkey = getHaftaraKey(parshaNameArray);
|
|
2579
2609
|
const haft0 = parshiyotObj[hkey].haft;
|
|
2580
2610
|
if (haft0) {
|
|
2581
|
-
const haft = result.haft = cloneHaftara(haft0);
|
|
2611
|
+
const haft = (result.haft = cloneHaftara(haft0));
|
|
2582
2612
|
result.haftara = makeSummaryFromParts(haft);
|
|
2583
2613
|
result.haftaraNumV = sumVerses(haft);
|
|
2584
2614
|
}
|
|
2585
2615
|
const seph0 = parshiyotObj[hkey].seph;
|
|
2586
2616
|
if (seph0) {
|
|
2587
|
-
const seph = result.seph = cloneHaftara(seph0);
|
|
2617
|
+
const seph = (result.seph = cloneHaftara(seph0));
|
|
2588
2618
|
result.sephardic = makeSummaryFromParts(seph);
|
|
2589
2619
|
result.sephardicNumV = sumVerses(seph);
|
|
2590
2620
|
}
|
|
@@ -2632,7 +2662,7 @@ function getLeyningForParshaHaShavua(ev, il = false) {
|
|
|
2632
2662
|
if (typeof ev !== 'object' || typeof ev.getFlags !== 'function') {
|
|
2633
2663
|
throw new TypeError(`Bad event argument: ${ev}`);
|
|
2634
2664
|
}
|
|
2635
|
-
else if (ev.getFlags()
|
|
2665
|
+
else if (ev.getFlags() !== core.flags.PARSHA_HASHAVUA) {
|
|
2636
2666
|
throw new TypeError(`Event must be parsha hashavua: ${ev.getDesc()}`);
|
|
2637
2667
|
}
|
|
2638
2668
|
// first, collect the default aliyot and haftara
|
|
@@ -2643,11 +2673,11 @@ function getLeyningForParshaHaShavua(ev, il = false) {
|
|
|
2643
2673
|
const special = specialReadings2(parsha, hd, il, result.fullkriyah);
|
|
2644
2674
|
const reason = special.reason;
|
|
2645
2675
|
if (special.haft) {
|
|
2646
|
-
const haft = result.haft = cloneHaftara(special.haft);
|
|
2676
|
+
const haft = (result.haft = cloneHaftara(special.haft));
|
|
2647
2677
|
result.haftara = makeSummaryFromParts(haft);
|
|
2648
2678
|
result.haftaraNumV = sumVerses(haft);
|
|
2649
2679
|
if (special.seph) {
|
|
2650
|
-
const seph = result.seph = cloneHaftara(special.seph);
|
|
2680
|
+
const seph = (result.seph = cloneHaftara(special.seph));
|
|
2651
2681
|
result.sephardic = makeSummaryFromParts(seph);
|
|
2652
2682
|
result.sephardicNumV = sumVerses(seph);
|
|
2653
2683
|
}
|
|
@@ -2742,23 +2772,6 @@ function findParshaHaShavua(saturday, il) {
|
|
|
2742
2772
|
/* NOTREACHED */
|
|
2743
2773
|
throw new Error(`can't findParshaHaShavua for ${saturday}/${il}`);
|
|
2744
2774
|
}
|
|
2745
|
-
/**
|
|
2746
|
-
* Looks up leyning for a regular Shabbat, Monday/Thursday weekday or holiday.
|
|
2747
|
-
*
|
|
2748
|
-
* If `hdate` coincides with a holiday that has Torah reading, returns the
|
|
2749
|
-
* reading for that day (see {@link getLeyningForHoliday})
|
|
2750
|
-
*
|
|
2751
|
-
* Otherwise, if `hdate` is a Saturday, returns {@link getLeyningForParshaHaShavua}
|
|
2752
|
-
*
|
|
2753
|
-
* Otherwise, if `hdate` is a Monday or Thursday, returns {@link Leyning} for the
|
|
2754
|
-
* Parashat haShavua, containing only the `weekday` aliyot (no `fullkriyah`).
|
|
2755
|
-
*
|
|
2756
|
-
* Otherwise, returns `undefined`.
|
|
2757
|
-
*
|
|
2758
|
-
* @param {HDate} hdate Hebrew Date
|
|
2759
|
-
* @param {boolean} il in Israel
|
|
2760
|
-
* @param {boolean} [wantarray] to return an array of 0 or more readings
|
|
2761
|
-
*/
|
|
2762
2775
|
function getLeyningOnDate(hdate, il, wantarray = false) {
|
|
2763
2776
|
const dow = hdate.getDay();
|
|
2764
2777
|
const arr = [];
|
|
@@ -2788,6 +2801,9 @@ function getLeyningOnDate(hdate, il, wantarray = false) {
|
|
|
2788
2801
|
}
|
|
2789
2802
|
const reading = getLeyningForHoliday(ev, il);
|
|
2790
2803
|
if (reading) {
|
|
2804
|
+
// Skip duplicate readings from overlapping events (eg, Rosh Chodesh + Chanukah)
|
|
2805
|
+
if (arr.some(r => r.name.en === reading.name.en))
|
|
2806
|
+
continue;
|
|
2791
2807
|
const fk = reading.fullkriyah;
|
|
2792
2808
|
if (fk) {
|
|
2793
2809
|
hasFullKriyah = true;
|
|
@@ -2843,14 +2859,16 @@ function getMincha(ev, il) {
|
|
|
2843
2859
|
}
|
|
2844
2860
|
|
|
2845
2861
|
const fmt = new Intl.DateTimeFormat('en-US', {
|
|
2846
|
-
year: 'numeric',
|
|
2862
|
+
year: 'numeric',
|
|
2863
|
+
month: 'short',
|
|
2864
|
+
day: '2-digit',
|
|
2847
2865
|
});
|
|
2848
2866
|
function fmtDate(dt) {
|
|
2849
2867
|
const s = fmt.format(dt).split(' ');
|
|
2850
2868
|
return s[1].substring(0, 2) + '-' + s[0] + '-' + s[2];
|
|
2851
2869
|
}
|
|
2852
2870
|
function getParshaDates(events) {
|
|
2853
|
-
const parshaEvents = events.filter(
|
|
2871
|
+
const parshaEvents = events.filter(ev => ev.getFlags() === core.flags.PARSHA_HASHAVUA);
|
|
2854
2872
|
const emptyMap = {};
|
|
2855
2873
|
const parshaDates = parshaEvents.reduce((set, ev) => {
|
|
2856
2874
|
set[ev.getDate().toString()] = true;
|
|
@@ -2869,7 +2887,8 @@ function writeFullKriyahCsv(stream, hyear, il) {
|
|
|
2869
2887
|
const parshaDates = getParshaDates(events);
|
|
2870
2888
|
stream.write('"Date","Parashah","Aliyah","Reading","Verses"\r\n');
|
|
2871
2889
|
for (const ev of events) {
|
|
2872
|
-
if (ev.getFlags() === core.flags.PARSHA_HASHAVUA ||
|
|
2890
|
+
if (ev.getFlags() === core.flags.PARSHA_HASHAVUA ||
|
|
2891
|
+
!parshaDates[ev.getDate().toString()]) {
|
|
2873
2892
|
writeFullKriyahEvent(stream, ev, il);
|
|
2874
2893
|
}
|
|
2875
2894
|
}
|
|
@@ -2890,7 +2909,9 @@ function writeFullKriyahEvent(stream, ev, il) {
|
|
|
2890
2909
|
}
|
|
2891
2910
|
const mask = ev.getFlags();
|
|
2892
2911
|
const isParsha = mask === core.flags.PARSHA_HASHAVUA;
|
|
2893
|
-
const reading = isParsha
|
|
2912
|
+
const reading = isParsha
|
|
2913
|
+
? getLeyningForParshaHaShavua(ev, il)
|
|
2914
|
+
: getLeyningForHoliday(ev, il);
|
|
2894
2915
|
if (reading) {
|
|
2895
2916
|
writeCsvLines(stream, ev, reading, il, isParsha);
|
|
2896
2917
|
if (!isParsha) {
|
|
@@ -2919,7 +2940,9 @@ function writeHolidayMincha(stream, ev, il) {
|
|
|
2919
2940
|
* Formats reading for CSV
|
|
2920
2941
|
*/
|
|
2921
2942
|
function writeCsvLines(stream, ev, reading, il, isParsha) {
|
|
2922
|
-
const parsha = isParsha
|
|
2943
|
+
const parsha = isParsha
|
|
2944
|
+
? ev.basename()
|
|
2945
|
+
: getLeyningKeyForEvent(ev, il) || ev.render();
|
|
2923
2946
|
const date = fmtDate(ev.getDate().greg());
|
|
2924
2947
|
const lines = getFullKriyahLines(reading);
|
|
2925
2948
|
for (const s of lines) {
|
|
@@ -2937,7 +2960,7 @@ function getFullKriyahLines(reading) {
|
|
|
2937
2960
|
if (reading.fullkriyah) {
|
|
2938
2961
|
for (const [num, a] of Object.entries(reading.fullkriyah)) {
|
|
2939
2962
|
if (typeof a !== 'undefined') {
|
|
2940
|
-
const k = num
|
|
2963
|
+
const k = num === 'M' ? 'maf' : num;
|
|
2941
2964
|
let aliyah = formatAliyahWithBook(a);
|
|
2942
2965
|
if ((_a = reading.reason) === null || _a === void 0 ? void 0 : _a[num]) {
|
|
2943
2966
|
aliyah += ' | ' + reading.reason[num];
|
|
@@ -2959,7 +2982,11 @@ function getFullKriyahLines(reading) {
|
|
|
2959
2982
|
if ((_c = reading.reason) === null || _c === void 0 ? void 0 : _c.sephardic) {
|
|
2960
2983
|
sephardic += ' | ' + reading.reason.sephardic;
|
|
2961
2984
|
}
|
|
2962
|
-
lines.push([
|
|
2985
|
+
lines.push([
|
|
2986
|
+
'Haftara for Sephardim',
|
|
2987
|
+
sephardic,
|
|
2988
|
+
reading.sephardicNumV || '',
|
|
2989
|
+
]);
|
|
2963
2990
|
}
|
|
2964
2991
|
if (reading.triHaftara) {
|
|
2965
2992
|
const haftara = reading.triHaftara.replace(/,/g, ';');
|
|
@@ -2977,6 +3004,7 @@ function getFullKriyahLines(reading) {
|
|
|
2977
3004
|
}
|
|
2978
3005
|
|
|
2979
3006
|
exports.BOOK = BOOK;
|
|
3007
|
+
exports.NUM_VERSES = NUM_VERSES;
|
|
2980
3008
|
exports.calculateNumVerses = calculateNumVerses;
|
|
2981
3009
|
exports.clone = clone;
|
|
2982
3010
|
exports.cloneHaftara = cloneHaftara;
|