@hebcal/core 5.4.8 → 5.4.10
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/README.md +3 -3735
- package/dist/CalOptions.d.ts +2 -1
- package/dist/DailyLearning.d.ts +3 -6
- package/dist/HebrewDateEvent.d.ts +4 -7
- package/dist/HolidayEvent.d.ts +9 -23
- package/dist/MevarchimChodeshEvent.d.ts +5 -8
- package/dist/ParshaEvent.d.ts +2 -9
- package/dist/TimedEvent.d.ts +5 -12
- package/dist/YomKippurKatanEvent.d.ts +4 -8
- package/dist/bundle.js +1123 -878
- package/dist/bundle.js.map +1 -0
- package/dist/bundle.min.js +3 -2
- package/dist/bundle.min.js.map +1 -0
- package/dist/event.d.ts +61 -51
- package/dist/hallel.d.ts +0 -3
- package/dist/hebcal.d.ts +15 -36
- package/dist/index.cjs +1172 -912
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +4 -3
- package/dist/index.mjs +1172 -912
- package/dist/index.mjs.map +1 -0
- package/dist/location.d.ts +14 -28
- package/dist/modern.d.ts +2 -4
- package/dist/molad.d.ts +13 -18
- package/dist/omer.d.ts +6 -14
- package/dist/pkgVersion.d.ts +1 -1
- package/dist/reformatTimeStr.d.ts +3 -4
- package/dist/sedra.d.ts +9 -19
- package/dist/staticHolidays.d.ts +74 -74
- package/dist/zmanim.d.ts +19 -60
- package/package.json +13 -12
package/dist/index.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! @hebcal/core v5.4.
|
|
1
|
+
/*! @hebcal/core v5.4.10 */
|
|
2
2
|
'use strict';
|
|
3
3
|
|
|
4
4
|
/* eslint-disable @typescript-eslint/no-namespace, no-inner-declarations */
|
|
@@ -39,107 +39,106 @@ function yearFromFixed(abs) {
|
|
|
39
39
|
const ABS_14SEP1752 = 639797;
|
|
40
40
|
const ABS_2SEP1752 = 639785;
|
|
41
41
|
*/
|
|
42
|
+
/*
|
|
43
|
+
* Formerly in namespace, now top-level
|
|
44
|
+
*/
|
|
42
45
|
/**
|
|
43
|
-
* Gregorian
|
|
46
|
+
* Returns true if the Gregorian year is a leap year
|
|
47
|
+
* @param year Gregorian year
|
|
44
48
|
*/
|
|
45
|
-
|
|
46
|
-
(
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
49
|
+
function isGregLeapYear(year) {
|
|
50
|
+
return !(year % 4) && (!!(year % 100) || !(year % 400));
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Number of days in the Gregorian month for given year
|
|
54
|
+
* @param month Gregorian month (1=January, 12=December)
|
|
55
|
+
* @param year Gregorian year
|
|
56
|
+
*/
|
|
57
|
+
function daysInGregMonth(month, year) {
|
|
58
|
+
// 1 based months
|
|
59
|
+
return monthLengths[+isGregLeapYear(year)][month];
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Returns true if the object is a Javascript Date
|
|
63
|
+
*/
|
|
64
|
+
function isDate(obj) {
|
|
65
|
+
// eslint-disable-next-line no-prototype-builtins
|
|
66
|
+
return typeof obj === 'object' && Date.prototype.isPrototypeOf(obj);
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* @private
|
|
70
|
+
* @param year
|
|
71
|
+
* @param month (1-12)
|
|
72
|
+
* @param day (1-31)
|
|
73
|
+
*/
|
|
74
|
+
function toFixed(year, month, day) {
|
|
75
|
+
const py = year - 1;
|
|
76
|
+
return (365 * py +
|
|
77
|
+
quotient(py, 4) -
|
|
78
|
+
quotient(py, 100) +
|
|
79
|
+
quotient(py, 400) +
|
|
80
|
+
quotient(367 * month - 362, 12) +
|
|
81
|
+
(month <= 2 ? 0 : isGregLeapYear(year) ? -1 : -2) +
|
|
82
|
+
day);
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Converts Gregorian date to absolute R.D. (Rata Die) days
|
|
86
|
+
* @param date Gregorian date
|
|
87
|
+
*/
|
|
88
|
+
function greg2abs(date) {
|
|
89
|
+
if (!isDate(date)) {
|
|
90
|
+
throw new TypeError(`Argument not a Date: ${date}`);
|
|
54
91
|
}
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
92
|
+
const abs = toFixed(date.getFullYear(), date.getMonth() + 1, date.getDate());
|
|
93
|
+
/*
|
|
94
|
+
if (abs < ABS_14SEP1752 && abs > ABS_2SEP1752) {
|
|
95
|
+
throw new RangeError(`Invalid Date: ${date}`);
|
|
96
|
+
}
|
|
97
|
+
*/
|
|
98
|
+
return abs;
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Converts from Rata Die (R.D. number) to Gregorian date.
|
|
102
|
+
* See the footnote on page 384 of ``Calendrical Calculations, Part II:
|
|
103
|
+
* Three Historical Calendars'' by E. M. Reingold, N. Dershowitz, and S. M.
|
|
104
|
+
* Clamen, Software--Practice and Experience, Volume 23, Number 4
|
|
105
|
+
* (April, 1993), pages 383-404 for an explanation.
|
|
106
|
+
* @param abs - R.D. number of days
|
|
107
|
+
*/
|
|
108
|
+
function abs2greg(abs) {
|
|
109
|
+
if (typeof abs !== 'number') {
|
|
110
|
+
throw new TypeError(`Argument not a Number: ${abs}`);
|
|
65
111
|
}
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
112
|
+
abs = Math.trunc(abs);
|
|
113
|
+
/*
|
|
114
|
+
if (abs < ABS_14SEP1752 && abs > ABS_2SEP1752) {
|
|
115
|
+
throw new RangeError(`Invalid Date: ${abs}`);
|
|
116
|
+
}
|
|
117
|
+
*/
|
|
118
|
+
const year = yearFromFixed(abs);
|
|
119
|
+
const priorDays = abs - toFixed(year, 1, 1);
|
|
120
|
+
const correction = abs < toFixed(year, 3, 1) ? 0 : isGregLeapYear(year) ? 1 : 2;
|
|
121
|
+
const month = quotient(12 * (priorDays + correction) + 373, 367);
|
|
122
|
+
const day = abs - toFixed(year, month, 1) + 1;
|
|
123
|
+
const dt = new Date(year, month - 1, day);
|
|
124
|
+
if (year < 100 && year >= 0) {
|
|
125
|
+
dt.setFullYear(year);
|
|
75
126
|
}
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
return (365 * py +
|
|
86
|
-
quotient(py, 4) -
|
|
87
|
-
quotient(py, 100) +
|
|
88
|
-
quotient(py, 400) +
|
|
89
|
-
quotient(367 * month - 362, 12) +
|
|
90
|
-
(month <= 2 ? 0 : isLeapYear(year) ? -1 : -2) +
|
|
91
|
-
day);
|
|
92
|
-
}
|
|
93
|
-
/**
|
|
94
|
-
* Converts Gregorian date to absolute R.D. (Rata Die) days
|
|
95
|
-
* @param {Date} date Gregorian date
|
|
96
|
-
* @return {number}
|
|
97
|
-
*/
|
|
98
|
-
function greg2abs(date) {
|
|
99
|
-
if (!isDate(date)) {
|
|
100
|
-
throw new TypeError(`Argument not a Date: ${date}`);
|
|
101
|
-
}
|
|
102
|
-
const abs = toFixed(date.getFullYear(), date.getMonth() + 1, date.getDate());
|
|
103
|
-
/*
|
|
104
|
-
if (abs < ABS_14SEP1752 && abs > ABS_2SEP1752) {
|
|
105
|
-
throw new RangeError(`Invalid Date: ${date}`);
|
|
106
|
-
}
|
|
107
|
-
*/
|
|
108
|
-
return abs;
|
|
109
|
-
}
|
|
110
|
-
greg.greg2abs = greg2abs;
|
|
111
|
-
/**
|
|
112
|
-
* Converts from Rata Die (R.D. number) to Gregorian date.
|
|
113
|
-
* See the footnote on page 384 of ``Calendrical Calculations, Part II:
|
|
114
|
-
* Three Historical Calendars'' by E. M. Reingold, N. Dershowitz, and S. M.
|
|
115
|
-
* Clamen, Software--Practice and Experience, Volume 23, Number 4
|
|
116
|
-
* (April, 1993), pages 383-404 for an explanation.
|
|
117
|
-
* @param {number} abs - R.D. number of days
|
|
118
|
-
* @return {Date}
|
|
119
|
-
*/
|
|
120
|
-
function abs2greg(abs) {
|
|
121
|
-
if (typeof abs !== 'number') {
|
|
122
|
-
throw new TypeError(`Argument not a Number: ${abs}`);
|
|
123
|
-
}
|
|
124
|
-
abs = Math.trunc(abs);
|
|
125
|
-
/*
|
|
126
|
-
if (abs < ABS_14SEP1752 && abs > ABS_2SEP1752) {
|
|
127
|
-
throw new RangeError(`Invalid Date: ${abs}`);
|
|
128
|
-
}
|
|
129
|
-
*/
|
|
130
|
-
const year = yearFromFixed(abs);
|
|
131
|
-
const priorDays = abs - toFixed(year, 1, 1);
|
|
132
|
-
const correction = abs < toFixed(year, 3, 1) ? 0 : isLeapYear(year) ? 1 : 2;
|
|
133
|
-
const month = quotient(12 * (priorDays + correction) + 373, 367);
|
|
134
|
-
const day = abs - toFixed(year, month, 1) + 1;
|
|
135
|
-
const dt = new Date(year, month - 1, day);
|
|
136
|
-
if (year < 100 && year >= 0) {
|
|
137
|
-
dt.setFullYear(year);
|
|
138
|
-
}
|
|
139
|
-
return dt;
|
|
140
|
-
}
|
|
141
|
-
greg.abs2greg = abs2greg;
|
|
127
|
+
return dt;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
/* eslint-disable @typescript-eslint/no-explicit-any, @typescript-eslint/no-namespace */
|
|
131
|
+
/**
|
|
132
|
+
* Gregorian date helper functions
|
|
133
|
+
*/
|
|
134
|
+
exports.greg = void 0;
|
|
135
|
+
(function (greg) {
|
|
142
136
|
})(exports.greg || (exports.greg = {}));
|
|
137
|
+
exports.greg.abs2greg = abs2greg;
|
|
138
|
+
exports.greg.daysInMonth = daysInGregMonth;
|
|
139
|
+
exports.greg.greg2abs = greg2abs;
|
|
140
|
+
exports.greg.isDate = isDate;
|
|
141
|
+
exports.greg.isLeapYear = isGregLeapYear;
|
|
143
142
|
|
|
144
143
|
/*
|
|
145
144
|
* More minimal HDate
|
|
@@ -229,10 +228,9 @@ function assertNumber(n, name) {
|
|
|
229
228
|
* Converts Hebrew date to R.D. (Rata Die) fixed days.
|
|
230
229
|
* R.D. 1 is the imaginary date Monday, January 1, 1 on the Gregorian
|
|
231
230
|
* Calendar.
|
|
232
|
-
* @param
|
|
233
|
-
* @param
|
|
234
|
-
* @param
|
|
235
|
-
* @return {number}
|
|
231
|
+
* @param year Hebrew year
|
|
232
|
+
* @param month Hebrew month
|
|
233
|
+
* @param day Hebrew date (1-30)
|
|
236
234
|
*/
|
|
237
235
|
function hebrew2abs(year, month, day) {
|
|
238
236
|
assertNumber(year, 'year');
|
|
@@ -265,8 +263,7 @@ function newYear(year) {
|
|
|
265
263
|
}
|
|
266
264
|
/**
|
|
267
265
|
* Converts absolute R.D. days to Hebrew date
|
|
268
|
-
* @param
|
|
269
|
-
* @return {SimpleHebrewDate}
|
|
266
|
+
* @param abs absolute R.D. days
|
|
270
267
|
*/
|
|
271
268
|
function abs2hebrew(abs) {
|
|
272
269
|
assertNumber(abs, 'abs');
|
|
@@ -289,25 +286,22 @@ function abs2hebrew(abs) {
|
|
|
289
286
|
}
|
|
290
287
|
/**
|
|
291
288
|
* Returns true if Hebrew year is a leap year
|
|
292
|
-
* @param
|
|
293
|
-
* @return {boolean}
|
|
289
|
+
* @param year Hebrew year
|
|
294
290
|
*/
|
|
295
291
|
function isLeapYear(year) {
|
|
296
292
|
return (1 + year * 7) % 19 < 7;
|
|
297
293
|
}
|
|
298
294
|
/**
|
|
299
295
|
* Number of months in this Hebrew year (either 12 or 13 depending on leap year)
|
|
300
|
-
* @param
|
|
301
|
-
* @return {number}
|
|
296
|
+
* @param year Hebrew year
|
|
302
297
|
*/
|
|
303
298
|
function monthsInYear(year) {
|
|
304
299
|
return 12 + +isLeapYear(year); // boolean is cast to 1 or 0
|
|
305
300
|
}
|
|
306
301
|
/**
|
|
307
302
|
* Number of days in Hebrew month in a given year (29 or 30)
|
|
308
|
-
* @param
|
|
309
|
-
* @param
|
|
310
|
-
* @return {number}
|
|
303
|
+
* @param month Hebrew month (e.g. months.TISHREI)
|
|
304
|
+
* @param year Hebrew year
|
|
311
305
|
*/
|
|
312
306
|
function daysInMonth(month, year) {
|
|
313
307
|
switch (month) {
|
|
@@ -330,8 +324,8 @@ function daysInMonth(month, year) {
|
|
|
330
324
|
/**
|
|
331
325
|
* Returns a transliterated string name of Hebrew month in year,
|
|
332
326
|
* for example 'Elul' or 'Cheshvan'.
|
|
333
|
-
* @param
|
|
334
|
-
* @param
|
|
327
|
+
* @param month Hebrew month (e.g. months.TISHREI)
|
|
328
|
+
* @param year Hebrew year
|
|
335
329
|
*/
|
|
336
330
|
function getMonthName(month, year) {
|
|
337
331
|
assertNumber(month, 'month');
|
|
@@ -344,8 +338,7 @@ function getMonthName(month, year) {
|
|
|
344
338
|
/**
|
|
345
339
|
* Days from sunday prior to start of Hebrew calendar to mean
|
|
346
340
|
* conjunction of Tishrei in Hebrew YEAR
|
|
347
|
-
* @param
|
|
348
|
-
* @return {number}
|
|
341
|
+
* @param year Hebrew year
|
|
349
342
|
*/
|
|
350
343
|
function elapsedDays(year) {
|
|
351
344
|
const n = edCache.get(year);
|
|
@@ -391,32 +384,28 @@ function elapsedDays0(year) {
|
|
|
391
384
|
* Number of days in the hebrew YEAR.
|
|
392
385
|
* A common Hebrew calendar year can have a length of 353, 354 or 355 days
|
|
393
386
|
* A leap Hebrew calendar year can have a length of 383, 384 or 385 days
|
|
394
|
-
* @param
|
|
395
|
-
* @return {number}
|
|
387
|
+
* @param year Hebrew year
|
|
396
388
|
*/
|
|
397
389
|
function daysInYear(year) {
|
|
398
390
|
return elapsedDays(year + 1) - elapsedDays(year);
|
|
399
391
|
}
|
|
400
392
|
/**
|
|
401
393
|
* true if Cheshvan is long in Hebrew year
|
|
402
|
-
* @param
|
|
403
|
-
* @return {boolean}
|
|
394
|
+
* @param year Hebrew year
|
|
404
395
|
*/
|
|
405
396
|
function longCheshvan(year) {
|
|
406
397
|
return daysInYear(year) % 10 === 5;
|
|
407
398
|
}
|
|
408
399
|
/**
|
|
409
400
|
* true if Kislev is short in Hebrew year
|
|
410
|
-
* @param
|
|
411
|
-
* @return {boolean}
|
|
401
|
+
* @param year Hebrew year
|
|
412
402
|
*/
|
|
413
403
|
function shortKislev(year) {
|
|
414
404
|
return daysInYear(year) % 10 === 3;
|
|
415
405
|
}
|
|
416
406
|
/**
|
|
417
407
|
* Converts Hebrew month string name to numeric
|
|
418
|
-
* @param
|
|
419
|
-
* @return {number}
|
|
408
|
+
* @param monthName monthName
|
|
420
409
|
*/
|
|
421
410
|
function monthFromName(monthName) {
|
|
422
411
|
if (typeof monthName === 'number') {
|
|
@@ -541,7 +530,6 @@ const ADAR_II$1 = months.ADAR_II;
|
|
|
541
530
|
/**
|
|
542
531
|
* Returns true if the object is a SimpleHebrewDate
|
|
543
532
|
* @private
|
|
544
|
-
* @param {Object} obj
|
|
545
533
|
*/
|
|
546
534
|
function isSimpleHebrewDate$1(obj) {
|
|
547
535
|
return (typeof obj === 'object' &&
|
|
@@ -560,8 +548,8 @@ function toSimpleHebrewDate(obj) {
|
|
|
560
548
|
else if (typeof obj === 'number') {
|
|
561
549
|
return abs2hebrew(obj);
|
|
562
550
|
}
|
|
563
|
-
else if (
|
|
564
|
-
const abs =
|
|
551
|
+
else if (isDate(obj)) {
|
|
552
|
+
const abs = greg2abs(obj);
|
|
565
553
|
return abs2hebrew(abs);
|
|
566
554
|
}
|
|
567
555
|
else {
|
|
@@ -708,8 +696,6 @@ function num2digits(num) {
|
|
|
708
696
|
* gematriya(60) // 'ס׳'
|
|
709
697
|
* gematriya(3761) // 'ג׳תשס״א'
|
|
710
698
|
* gematriya(1123) // 'א׳קכ״ג'
|
|
711
|
-
* @param {number} num
|
|
712
|
-
* @return {string}
|
|
713
699
|
*/
|
|
714
700
|
function gematriya(num) {
|
|
715
701
|
const num0 = num;
|
|
@@ -744,9 +730,6 @@ function gematriya(num) {
|
|
|
744
730
|
* Only considers the value of Hebrew letters `א` through `ת`.
|
|
745
731
|
* Ignores final Hebrew letters such as `ך` (kaf sofit) or `ם` (mem sofit)
|
|
746
732
|
* and vowels (nekudot).
|
|
747
|
-
*
|
|
748
|
-
* @param {string} str
|
|
749
|
-
* @return {number}
|
|
750
733
|
*/
|
|
751
734
|
function gematriyaStrToNum(str) {
|
|
752
735
|
let num = 0;
|
|
@@ -1026,8 +1009,6 @@ function molad(year, month) {
|
|
|
1026
1009
|
const _formatters = new Map();
|
|
1027
1010
|
/**
|
|
1028
1011
|
* @private
|
|
1029
|
-
* @param {string} tzid
|
|
1030
|
-
* @return {Intl.DateTimeFormat}
|
|
1031
1012
|
*/
|
|
1032
1013
|
function getFormatter$1(tzid) {
|
|
1033
1014
|
const fmt = _formatters.get(tzid);
|
|
@@ -1051,9 +1032,6 @@ const dateFormatRegex = /^(\d+).(\d+).(\d+),?\s+(\d+).(\d+).(\d+)/;
|
|
|
1051
1032
|
* Returns a string similar to `Date.toISOString()` but in the
|
|
1052
1033
|
* timezone `tzid`. Contrary to the typical meaning of `Z` at the end
|
|
1053
1034
|
* of the string, this is not actually a UTC date.
|
|
1054
|
-
* @param {string} tzid
|
|
1055
|
-
* @param {Date} date
|
|
1056
|
-
* @return {string}
|
|
1057
1035
|
*/
|
|
1058
1036
|
function getPseudoISO(tzid, date) {
|
|
1059
1037
|
const str = getFormatter$1(tzid).format(date);
|
|
@@ -1070,9 +1048,6 @@ function getPseudoISO(tzid, date) {
|
|
|
1070
1048
|
}
|
|
1071
1049
|
/**
|
|
1072
1050
|
* Returns number of minutes `tzid` is offset from UTC on date `date`.
|
|
1073
|
-
* @param {string} tzid
|
|
1074
|
-
* @param {Date} date
|
|
1075
|
-
* @return {number}
|
|
1076
1051
|
*/
|
|
1077
1052
|
function getTimezoneOffset(tzid, date) {
|
|
1078
1053
|
const utcStr = getPseudoISO('UTC', date);
|
|
@@ -1085,8 +1060,6 @@ function getTimezoneOffset(tzid, date) {
|
|
|
1085
1060
|
* Similar to `string.padStart(4, '0')` but will also format
|
|
1086
1061
|
* negative numbers similar to how the JavaScript date formats
|
|
1087
1062
|
* negative year numbers (e.g. `-37` is formatted as `-000037`).
|
|
1088
|
-
* @param {number} number
|
|
1089
|
-
* @return {string}
|
|
1090
1063
|
*/
|
|
1091
1064
|
function pad4(number) {
|
|
1092
1065
|
if (number < 0) {
|
|
@@ -1106,8 +1079,6 @@ function pad4(number) {
|
|
|
1106
1079
|
/**
|
|
1107
1080
|
* Formats a number with leading zeros so the resulting string is 2 digits long.
|
|
1108
1081
|
* Similar to `string.padStart(2, '0')`.
|
|
1109
|
-
* @param {number} number
|
|
1110
|
-
* @return {string}
|
|
1111
1082
|
*/
|
|
1112
1083
|
function pad2(number) {
|
|
1113
1084
|
if (number < 10) {
|
|
@@ -1117,9 +1088,6 @@ function pad2(number) {
|
|
|
1117
1088
|
}
|
|
1118
1089
|
/**
|
|
1119
1090
|
* Returns YYYY-MM-DD in the local timezone
|
|
1120
|
-
* @private
|
|
1121
|
-
* @param {Date} dt
|
|
1122
|
-
* @return {string}
|
|
1123
1091
|
*/
|
|
1124
1092
|
function isoDateString(dt) {
|
|
1125
1093
|
return (pad4(dt.getFullYear()) +
|
|
@@ -1138,9 +1106,9 @@ const noopLocale = {
|
|
|
1138
1106
|
contexts: { '': {} },
|
|
1139
1107
|
};
|
|
1140
1108
|
const alias = {
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1109
|
+
h: 'he',
|
|
1110
|
+
a: 'ashkenazi',
|
|
1111
|
+
s: 'en',
|
|
1144
1112
|
'': 'en',
|
|
1145
1113
|
};
|
|
1146
1114
|
/** @private */
|
|
@@ -1161,12 +1129,12 @@ class Locale {
|
|
|
1161
1129
|
/**
|
|
1162
1130
|
* Returns translation only if `locale` offers a non-empty translation for `id`.
|
|
1163
1131
|
* Otherwise, returns `undefined`.
|
|
1164
|
-
* @param
|
|
1165
|
-
* @param
|
|
1166
|
-
* @return {string}
|
|
1132
|
+
* @param id Message ID to translate
|
|
1133
|
+
* @param [locale] Optional locale name (i.e: `'he'`, `'fr'`). Defaults to active locale.
|
|
1167
1134
|
*/
|
|
1168
1135
|
static lookupTranslation(id, locale) {
|
|
1169
|
-
const loc = (typeof locale === 'string' && locales.get(locale.toLowerCase())) ||
|
|
1136
|
+
const loc = (typeof locale === 'string' && locales.get(locale.toLowerCase())) ||
|
|
1137
|
+
activeLocale;
|
|
1170
1138
|
const array = loc[id];
|
|
1171
1139
|
if ((array === null || array === void 0 ? void 0 : array.length) && array[0].length) {
|
|
1172
1140
|
return array[0];
|
|
@@ -1175,9 +1143,8 @@ class Locale {
|
|
|
1175
1143
|
}
|
|
1176
1144
|
/**
|
|
1177
1145
|
* By default, if no translation was found, returns `id`.
|
|
1178
|
-
* @param
|
|
1179
|
-
* @param
|
|
1180
|
-
* @return {string}
|
|
1146
|
+
* @param id Message ID to translate
|
|
1147
|
+
* @param [locale] Optional locale name (i.e: `'he'`, `'fr'`). Defaults to active locale.
|
|
1181
1148
|
*/
|
|
1182
1149
|
static gettext(id, locale) {
|
|
1183
1150
|
const text = this.lookupTranslation(id, locale);
|
|
@@ -1188,23 +1155,24 @@ class Locale {
|
|
|
1188
1155
|
}
|
|
1189
1156
|
/**
|
|
1190
1157
|
* Register locale translations.
|
|
1191
|
-
* @param
|
|
1192
|
-
* @param
|
|
1158
|
+
* @param locale Locale name (i.e.: `'he'`, `'fr'`)
|
|
1159
|
+
* @param data parsed data from a `.po` file.
|
|
1193
1160
|
*/
|
|
1194
1161
|
static addLocale(locale, data) {
|
|
1195
1162
|
if (typeof locale !== 'string') {
|
|
1196
1163
|
throw new TypeError(`Invalid locale name: ${locale}`);
|
|
1197
1164
|
}
|
|
1198
|
-
if (typeof data.contexts !== 'object' ||
|
|
1165
|
+
if (typeof data.contexts !== 'object' ||
|
|
1166
|
+
typeof data.contexts[''] !== 'object') {
|
|
1199
1167
|
throw new TypeError(`Locale '${locale}' invalid compact format`);
|
|
1200
1168
|
}
|
|
1201
1169
|
locales.set(locale.toLowerCase(), data.contexts['']);
|
|
1202
1170
|
}
|
|
1203
1171
|
/**
|
|
1204
1172
|
* Adds a translation to `locale`, replacing any previous translation.
|
|
1205
|
-
* @param
|
|
1206
|
-
* @param
|
|
1207
|
-
* @param
|
|
1173
|
+
* @param locale Locale name (i.e: `'he'`, `'fr'`).
|
|
1174
|
+
* @param id Message ID to translate
|
|
1175
|
+
* @param translation Translation text
|
|
1208
1176
|
*/
|
|
1209
1177
|
static addTranslation(locale, id, translation) {
|
|
1210
1178
|
if (typeof locale !== 'string') {
|
|
@@ -1231,8 +1199,8 @@ class Locale {
|
|
|
1231
1199
|
}
|
|
1232
1200
|
/**
|
|
1233
1201
|
* Adds multiple translations to `locale`, replacing any previous translations.
|
|
1234
|
-
* @param
|
|
1235
|
-
* @param
|
|
1202
|
+
* @param locale Locale name (i.e: `'he'`, `'fr'`).
|
|
1203
|
+
* @param data parsed data from a `.po` file.
|
|
1236
1204
|
*/
|
|
1237
1205
|
static addTranslations(locale, data) {
|
|
1238
1206
|
if (typeof locale !== 'string') {
|
|
@@ -1242,7 +1210,8 @@ class Locale {
|
|
|
1242
1210
|
if (!loc) {
|
|
1243
1211
|
throw new TypeError(`Unknown locale: ${locale}`);
|
|
1244
1212
|
}
|
|
1245
|
-
if (typeof data.contexts !== 'object' ||
|
|
1213
|
+
if (typeof data.contexts !== 'object' ||
|
|
1214
|
+
typeof data.contexts[''] !== 'object') {
|
|
1246
1215
|
throw new TypeError(`Locale '${locale}' invalid compact format`);
|
|
1247
1216
|
}
|
|
1248
1217
|
const ctx = data.contexts[''];
|
|
@@ -1252,7 +1221,7 @@ class Locale {
|
|
|
1252
1221
|
* Activates a locale. Throws an error if the locale has not been previously added.
|
|
1253
1222
|
* After setting the locale to be used, all strings marked for translations
|
|
1254
1223
|
* will be represented by the corresponding translation in the specified locale.
|
|
1255
|
-
* @param
|
|
1224
|
+
* @param locale Locale name (i.e: `'he'`, `'fr'`)
|
|
1256
1225
|
*/
|
|
1257
1226
|
static useLocale(locale) {
|
|
1258
1227
|
const locale0 = locale.toLowerCase();
|
|
@@ -1266,23 +1235,20 @@ class Locale {
|
|
|
1266
1235
|
}
|
|
1267
1236
|
/**
|
|
1268
1237
|
* Returns the name of the active locale (i.e. 'he', 'ashkenazi', 'fr')
|
|
1269
|
-
* @return {string}
|
|
1270
1238
|
*/
|
|
1271
1239
|
static getLocaleName() {
|
|
1272
1240
|
return activeName;
|
|
1273
1241
|
}
|
|
1274
1242
|
/**
|
|
1275
1243
|
* Returns the names of registered locales
|
|
1276
|
-
* @return {string[]}
|
|
1277
1244
|
*/
|
|
1278
1245
|
static getLocaleNames() {
|
|
1279
1246
|
const keys = Array.from(locales.keys());
|
|
1280
1247
|
return keys.sort((a, b) => a.localeCompare(b));
|
|
1281
1248
|
}
|
|
1282
1249
|
/**
|
|
1283
|
-
*
|
|
1284
|
-
* @param
|
|
1285
|
-
* @return {string}
|
|
1250
|
+
* Renders a number in ordinal, such as 1st, 2nd or 3rd
|
|
1251
|
+
* @param [locale] Optional locale name (i.e: `'he'`, `'fr'`). Defaults to active locale.
|
|
1286
1252
|
*/
|
|
1287
1253
|
static ordinal(n, locale) {
|
|
1288
1254
|
const locale1 = locale === null || locale === void 0 ? void 0 : locale.toLowerCase();
|
|
@@ -1309,11 +1275,6 @@ class Locale {
|
|
|
1309
1275
|
return n + '.';
|
|
1310
1276
|
}
|
|
1311
1277
|
}
|
|
1312
|
-
/**
|
|
1313
|
-
* @private
|
|
1314
|
-
* @param {number} n
|
|
1315
|
-
* @return {string}
|
|
1316
|
-
*/
|
|
1317
1278
|
static getEnOrdinal(n) {
|
|
1318
1279
|
const s = ['th', 'st', 'nd', 'rd'];
|
|
1319
1280
|
const v = n % 100;
|
|
@@ -1321,8 +1282,6 @@ class Locale {
|
|
|
1321
1282
|
}
|
|
1322
1283
|
/**
|
|
1323
1284
|
* Removes nekudot from Hebrew string
|
|
1324
|
-
* @param {string} str
|
|
1325
|
-
* @return {string}
|
|
1326
1285
|
*/
|
|
1327
1286
|
static hebrewStripNikkud(str) {
|
|
1328
1287
|
return str.replace(/[\u0590-\u05bd]/g, '').replace(/[\u05bf-\u05c7]/g, '');
|
|
@@ -1370,10 +1329,10 @@ Locale.addLocale('he-x-NoNikud', poHeNoNikud$1);
|
|
|
1370
1329
|
You should have received a copy of the GNU General Public License
|
|
1371
1330
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
1372
1331
|
*/
|
|
1373
|
-
// eslint-disable-next-line require-jsdoc
|
|
1374
1332
|
function mod(x, y) {
|
|
1375
1333
|
return x - y * Math.floor(x / y);
|
|
1376
1334
|
}
|
|
1335
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1377
1336
|
function isSimpleHebrewDate(obj) {
|
|
1378
1337
|
return obj.yy !== undefined;
|
|
1379
1338
|
}
|
|
@@ -1381,7 +1340,24 @@ const UNITS_DAY = 'day';
|
|
|
1381
1340
|
const UNITS_WEEK = 'week';
|
|
1382
1341
|
const UNITS_MONTH = 'month';
|
|
1383
1342
|
const UNITS_YEAR = 'year';
|
|
1384
|
-
/**
|
|
1343
|
+
/**
|
|
1344
|
+
* A `HDate` represents a Hebrew calendar date.
|
|
1345
|
+
*
|
|
1346
|
+
* An instance of this class encapsulates a date in the Hebrew calendar system.
|
|
1347
|
+
* It consists of a year, month, and day, without any associated time or location data.
|
|
1348
|
+
* The Hebrew calendar is a lunisolar calendar, meaning it is based on both lunar and solar cycles.
|
|
1349
|
+
*
|
|
1350
|
+
* A Hebrew date internally stores three numbers:
|
|
1351
|
+
* - year: The Hebrew year (1-9999). Counted from the traditional Hebrew date of creation (3761 BCE in the Gregorian calendar)
|
|
1352
|
+
* - month: The Hebrew month (1-13). Month 1 is Nisan, month 7 is Tishrei. There are 12 months in a regular year and 13 months in a leap year.
|
|
1353
|
+
* - day: The day of the month (1-30)
|
|
1354
|
+
*
|
|
1355
|
+
* This class uses Rata Die to convert between the Hebrew and Gregorian calendars.
|
|
1356
|
+
*
|
|
1357
|
+
* To calculate times of day, use `Zmanim` class from `@hebcal/core`
|
|
1358
|
+
* @see {@link https://en.wikipedia.org/wiki/Rata_Die | Rata Die}
|
|
1359
|
+
* @see {@link https://hebcal.github.io/api/core/classes/Zmanim.html | Zmanim}
|
|
1360
|
+
*/
|
|
1385
1361
|
class HDate {
|
|
1386
1362
|
/**
|
|
1387
1363
|
* Create a Hebrew date. There are 3 basic forms for the `HDate()` constructor.
|
|
@@ -1406,12 +1382,12 @@ class HDate {
|
|
|
1406
1382
|
* const hd5 = new HDate(733359); // ==> 15 Cheshvan 5769
|
|
1407
1383
|
* const monthName = 'אייר';
|
|
1408
1384
|
* const hd6 = new HDate(5, monthName, 5773);
|
|
1409
|
-
* @param
|
|
1385
|
+
* @param [day] - Day of month (1-30) if a `number`.
|
|
1410
1386
|
* If a `Date` is specified, represents the Hebrew date corresponding to the
|
|
1411
1387
|
* Gregorian date using local time.
|
|
1412
1388
|
* If an `HDate` is specified, clones a copy of the given Hebrew date.
|
|
1413
|
-
* @param
|
|
1414
|
-
* @param
|
|
1389
|
+
* @param [month] - Hebrew month of year (1=NISAN, 7=TISHREI)
|
|
1390
|
+
* @param [year] - Hebrew year
|
|
1415
1391
|
*/
|
|
1416
1392
|
constructor(day, month, year) {
|
|
1417
1393
|
if (arguments.length === 2 || arguments.length > 3) {
|
|
@@ -1438,9 +1414,13 @@ class HDate {
|
|
|
1438
1414
|
day = new Date();
|
|
1439
1415
|
}
|
|
1440
1416
|
// 1 argument
|
|
1441
|
-
const abs0 =
|
|
1442
|
-
|
|
1443
|
-
|
|
1417
|
+
const abs0 = typeof day === 'number' && !isNaN(day)
|
|
1418
|
+
? day
|
|
1419
|
+
: isDate(day)
|
|
1420
|
+
? greg2abs(day)
|
|
1421
|
+
: isSimpleHebrewDate(day)
|
|
1422
|
+
? day
|
|
1423
|
+
: null;
|
|
1444
1424
|
if (abs0 === null) {
|
|
1445
1425
|
throw new TypeError(`HDate called with bad argument: ${day}`);
|
|
1446
1426
|
}
|
|
@@ -1455,68 +1435,99 @@ class HDate {
|
|
|
1455
1435
|
}
|
|
1456
1436
|
}
|
|
1457
1437
|
/**
|
|
1458
|
-
*
|
|
1459
|
-
* @
|
|
1438
|
+
* Returns the Hebrew year of this Hebrew date
|
|
1439
|
+
* @returns an integer >= 1
|
|
1440
|
+
* @example
|
|
1441
|
+
* const hd = new HDate(new Date(2008, 10, 13)); // 15 Cheshvan 5769
|
|
1442
|
+
* hd.getFullYear(); // 5769
|
|
1460
1443
|
*/
|
|
1461
1444
|
getFullYear() {
|
|
1462
1445
|
return this.yy;
|
|
1463
1446
|
}
|
|
1464
1447
|
/**
|
|
1465
|
-
*
|
|
1466
|
-
* @
|
|
1448
|
+
* Returns `true` if this Hebrew date occurs during a Hebrew leap year
|
|
1449
|
+
* @example
|
|
1450
|
+
* const hd = new HDate(new Date(2008, 10, 13)); // 15 Cheshvan 5769
|
|
1451
|
+
* hd.isLeapYear(); // false
|
|
1467
1452
|
*/
|
|
1468
1453
|
isLeapYear() {
|
|
1469
1454
|
return isLeapYear(this.yy);
|
|
1470
1455
|
}
|
|
1471
1456
|
/**
|
|
1472
|
-
*
|
|
1473
|
-
* @
|
|
1457
|
+
* Returns the Hebrew month (1=NISAN, 7=TISHREI) of this Hebrew date
|
|
1458
|
+
* @returns an integer 1-13
|
|
1459
|
+
* @example
|
|
1460
|
+
* const hd = new HDate(new Date(2008, 10, 13)); // 15 Cheshvan 5769
|
|
1461
|
+
* hd.getMonth(); // 8
|
|
1474
1462
|
*/
|
|
1475
1463
|
getMonth() {
|
|
1476
1464
|
return this.mm;
|
|
1477
1465
|
}
|
|
1478
1466
|
/**
|
|
1479
|
-
* The Tishrei-based month of
|
|
1480
|
-
* @
|
|
1467
|
+
* The Tishrei-based month of this Hebrew date. 1 is Tishrei, 7 is Nisan, 13 is Elul in a leap year
|
|
1468
|
+
* @returns an integer 1-13
|
|
1469
|
+
* @example
|
|
1470
|
+
* const hd = new HDate(new Date(2008, 10, 13)); // 15 Cheshvan 5769
|
|
1471
|
+
* hd.getMonth(); // 2
|
|
1481
1472
|
*/
|
|
1482
1473
|
getTishreiMonth() {
|
|
1483
1474
|
const nummonths = monthsInYear(this.getFullYear());
|
|
1484
1475
|
return (this.getMonth() + nummonths - 6) % nummonths || nummonths;
|
|
1485
1476
|
}
|
|
1486
1477
|
/**
|
|
1487
|
-
* Number of days in the month of this Hebrew date
|
|
1488
|
-
* @
|
|
1478
|
+
* Number of days in the month of this Hebrew date (29 or 30)
|
|
1479
|
+
* @returns an integer 29-30
|
|
1480
|
+
* @example
|
|
1481
|
+
* const hd = new HDate(new Date(2008, 10, 13)); // 15 Cheshvan 5769
|
|
1482
|
+
* hd.daysInMonth(); // 29
|
|
1489
1483
|
*/
|
|
1490
1484
|
daysInMonth() {
|
|
1491
1485
|
return daysInMonth(this.getMonth(), this.getFullYear());
|
|
1492
1486
|
}
|
|
1493
1487
|
/**
|
|
1494
1488
|
* Gets the day within the month (1-30)
|
|
1495
|
-
* @
|
|
1489
|
+
* @returns an integer 1-30
|
|
1490
|
+
* @example
|
|
1491
|
+
* const hd = new HDate(new Date(2008, 10, 13)); // 15 Cheshvan 5769
|
|
1492
|
+
* hd.getDate(); // 15
|
|
1496
1493
|
*/
|
|
1497
1494
|
getDate() {
|
|
1498
1495
|
return this.dd;
|
|
1499
1496
|
}
|
|
1500
1497
|
/**
|
|
1501
|
-
*
|
|
1502
|
-
*
|
|
1498
|
+
* Returns the day of the week for this Hebrew date,
|
|
1499
|
+
* where 0 represents Sunday, 1 represents Monday, 6 represents Saturday.
|
|
1500
|
+
*
|
|
1501
|
+
* For the day of the month, see `getDate()`
|
|
1502
|
+
* @returns an integer 0-6
|
|
1503
|
+
* @example
|
|
1504
|
+
* const hd = new HDate(new Date(2008, 10, 13)); // 15 Cheshvan 5769
|
|
1505
|
+
* hd.getDate(); // 4
|
|
1503
1506
|
*/
|
|
1504
1507
|
getDay() {
|
|
1505
1508
|
return mod(this.abs(), 7);
|
|
1506
1509
|
}
|
|
1507
1510
|
/**
|
|
1508
|
-
* Converts to Gregorian date
|
|
1509
|
-
*
|
|
1511
|
+
* Converts this Hebrew date to the corresponding Gregorian date.
|
|
1512
|
+
* Note that this function returns the daytime portion of the date.
|
|
1513
|
+
* For example, the 15th of Cheshvan 5769 began at sundown on
|
|
1514
|
+
* 12 November 2008 and continues through 13 November 2008. This
|
|
1515
|
+
* function would return only the date 13 November 2008.
|
|
1516
|
+
* @example
|
|
1517
|
+
* const hd = new HDate(15, 'Cheshvan', 5769);
|
|
1518
|
+
* hd.greg(); // 13 November 2008
|
|
1510
1519
|
*/
|
|
1511
1520
|
greg() {
|
|
1512
|
-
return
|
|
1521
|
+
return abs2greg(this.abs());
|
|
1513
1522
|
}
|
|
1514
1523
|
/**
|
|
1515
|
-
*
|
|
1516
|
-
* R.D. 1
|
|
1524
|
+
* Converts from Hebrew date representation to R.D. (Rata Die) fixed days.
|
|
1525
|
+
* R.D. 1 is the imaginary date Monday, January 1, 1 (Gregorian).
|
|
1517
1526
|
* Note also that R.D. = Julian Date − 1,721,424.5
|
|
1518
|
-
* https://en.wikipedia.org/wiki/Rata_Die
|
|
1519
|
-
* @
|
|
1527
|
+
* @see {@link https://en.wikipedia.org/wiki/Rata_Die | Rata Die}
|
|
1528
|
+
* @example
|
|
1529
|
+
* const hd = new HDate(15, 'Cheshvan', 5769);
|
|
1530
|
+
* hd.abs(); // 733359
|
|
1520
1531
|
*/
|
|
1521
1532
|
abs() {
|
|
1522
1533
|
if (typeof this.rd !== 'number') {
|
|
@@ -1528,17 +1539,21 @@ class HDate {
|
|
|
1528
1539
|
* Converts Hebrew date to R.D. (Rata Die) fixed days.
|
|
1529
1540
|
* R.D. 1 is the imaginary date Monday, January 1, 1 on the Gregorian
|
|
1530
1541
|
* Calendar.
|
|
1531
|
-
* @param
|
|
1532
|
-
* @param
|
|
1533
|
-
* @param
|
|
1534
|
-
* @
|
|
1542
|
+
* @param year Hebrew year
|
|
1543
|
+
* @param month Hebrew month (1=NISAN, 7=TISHREI)
|
|
1544
|
+
* @param day Hebrew date (1-30)
|
|
1545
|
+
* @example
|
|
1546
|
+
* import {HDate, months} from '@hebcal/hdate';
|
|
1547
|
+
* HDate.hebrew2abs(5769, months.CHESHVAN, 15); // 733359
|
|
1535
1548
|
*/
|
|
1536
1549
|
static hebrew2abs(year, month, day) {
|
|
1537
1550
|
return hebrew2abs(year, month, day);
|
|
1538
1551
|
}
|
|
1539
1552
|
/**
|
|
1540
1553
|
* Returns a transliterated Hebrew month name, e.g. `'Elul'` or `'Cheshvan'`.
|
|
1541
|
-
* @
|
|
1554
|
+
* @example
|
|
1555
|
+
* const hd = new HDate(new Date(2008, 10, 13)); // 15 Cheshvan 5769
|
|
1556
|
+
* hd.getMonthName(); // 'Cheshvan'
|
|
1542
1557
|
*/
|
|
1543
1558
|
getMonthName() {
|
|
1544
1559
|
return getMonthName(this.getMonth(), this.getFullYear());
|
|
@@ -1552,9 +1567,11 @@ class HDate {
|
|
|
1552
1567
|
* const hd = new HDate(15, months.CHESHVAN, 5769);
|
|
1553
1568
|
* console.log(hd.render('en')); // '15th of Cheshvan, 5769'
|
|
1554
1569
|
* console.log(hd.render('he')); // '15 חֶשְׁוָן, 5769'
|
|
1555
|
-
*
|
|
1556
|
-
*
|
|
1557
|
-
* @
|
|
1570
|
+
* console.log(hd.render('en', false)); // '15th of Cheshvan'
|
|
1571
|
+
* console.log(hd.render('he', false)); // '15 חֶשְׁוָן'
|
|
1572
|
+
* @param [locale] Optional locale name (defaults to active locale).
|
|
1573
|
+
* @param [showYear=true] Display year (defaults to true).
|
|
1574
|
+
* @see {@link Locale}
|
|
1558
1575
|
*/
|
|
1559
1576
|
render(locale, showYear = true) {
|
|
1560
1577
|
const locale0 = locale || Locale.getLocaleName();
|
|
@@ -1577,9 +1594,8 @@ class HDate {
|
|
|
1577
1594
|
* @example
|
|
1578
1595
|
* import {HDate, months} from '@hebcal/hdate';
|
|
1579
1596
|
* const hd = new HDate(15, months.CHESHVAN, 5769);
|
|
1580
|
-
*
|
|
1581
|
-
*
|
|
1582
|
-
* @return {string}
|
|
1597
|
+
* hd.renderGematriya(); // 'ט״ו חֶשְׁוָן תשס״ט'
|
|
1598
|
+
* hd.renderGematriya(true); // 'ט״ו חשון תשס״ט'
|
|
1583
1599
|
*/
|
|
1584
1600
|
renderGematriya(suppressNikud = false) {
|
|
1585
1601
|
const d = this.getDate();
|
|
@@ -1589,77 +1605,76 @@ class HDate {
|
|
|
1589
1605
|
return gematriya(d) + ' ' + m + ' ' + gematriya(y);
|
|
1590
1606
|
}
|
|
1591
1607
|
/**
|
|
1592
|
-
* Returns an `HDate`
|
|
1593
|
-
*
|
|
1608
|
+
* Returns an `HDate` corresponding to the specified day of week
|
|
1609
|
+
* **before** this Hebrew date
|
|
1594
1610
|
* @example
|
|
1595
1611
|
* new HDate(new Date('Wednesday February 19, 2014')).before(6).greg() // Sat Feb 15 2014
|
|
1596
|
-
* @param
|
|
1597
|
-
* @return {HDate}
|
|
1612
|
+
* @param dayOfWeek day of week: Sunday=0, Saturday=6
|
|
1598
1613
|
*/
|
|
1599
|
-
before(
|
|
1600
|
-
return onOrBefore(
|
|
1614
|
+
before(dayOfWeek) {
|
|
1615
|
+
return onOrBefore(dayOfWeek, this, -1);
|
|
1601
1616
|
}
|
|
1602
1617
|
/**
|
|
1603
|
-
* Returns an `HDate`
|
|
1604
|
-
*
|
|
1618
|
+
* Returns an `HDate` corresponding to the specified day of week
|
|
1619
|
+
* **on or before** this Hebrew date
|
|
1605
1620
|
* @example
|
|
1606
1621
|
* new HDate(new Date('Wednesday February 19, 2014')).onOrBefore(6).greg() // Sat Feb 15 2014
|
|
1607
1622
|
* new HDate(new Date('Saturday February 22, 2014')).onOrBefore(6).greg() // Sat Feb 22 2014
|
|
1608
1623
|
* new HDate(new Date('Sunday February 23, 2014')).onOrBefore(6).greg() // Sat Feb 22 2014
|
|
1609
|
-
* @param
|
|
1610
|
-
* @return {HDate}
|
|
1624
|
+
* @param dayOfWeek day of week: Sunday=0, Saturday=6
|
|
1611
1625
|
*/
|
|
1612
|
-
onOrBefore(
|
|
1613
|
-
return onOrBefore(
|
|
1626
|
+
onOrBefore(dayOfWeek) {
|
|
1627
|
+
return onOrBefore(dayOfWeek, this, 0);
|
|
1614
1628
|
}
|
|
1615
1629
|
/**
|
|
1616
|
-
* Returns an `HDate`
|
|
1617
|
-
*
|
|
1630
|
+
* Returns an `HDate` corresponding to the specified day of week
|
|
1631
|
+
* **nearest** to this Hebrew date
|
|
1618
1632
|
* @example
|
|
1619
1633
|
* new HDate(new Date('Wednesday February 19, 2014')).nearest(6).greg() // Sat Feb 22 2014
|
|
1620
1634
|
* new HDate(new Date('Tuesday February 18, 2014')).nearest(6).greg() // Sat Feb 15 2014
|
|
1621
|
-
* @param
|
|
1622
|
-
* @return {HDate}
|
|
1635
|
+
* @param dayOfWeek day of week: Sunday=0, Saturday=6
|
|
1623
1636
|
*/
|
|
1624
|
-
nearest(
|
|
1625
|
-
return onOrBefore(
|
|
1637
|
+
nearest(dayOfWeek) {
|
|
1638
|
+
return onOrBefore(dayOfWeek, this, 3);
|
|
1626
1639
|
}
|
|
1627
1640
|
/**
|
|
1628
|
-
* Returns an `HDate`
|
|
1629
|
-
*
|
|
1641
|
+
* Returns an `HDate` corresponding to the specified day of week
|
|
1642
|
+
* **on or after** this Hebrew date
|
|
1630
1643
|
* @example
|
|
1631
1644
|
* new HDate(new Date('Wednesday February 19, 2014')).onOrAfter(6).greg() // Sat Feb 22 2014
|
|
1632
1645
|
* new HDate(new Date('Saturday February 22, 2014')).onOrAfter(6).greg() // Sat Feb 22 2014
|
|
1633
1646
|
* new HDate(new Date('Sunday February 23, 2014')).onOrAfter(6).greg() // Sat Mar 01 2014
|
|
1634
|
-
* @param
|
|
1635
|
-
* @return {HDate}
|
|
1647
|
+
* @param dayOfWeek day of week: Sunday=0, Saturday=6
|
|
1636
1648
|
*/
|
|
1637
|
-
onOrAfter(
|
|
1638
|
-
return onOrBefore(
|
|
1649
|
+
onOrAfter(dayOfWeek) {
|
|
1650
|
+
return onOrBefore(dayOfWeek, this, 6);
|
|
1639
1651
|
}
|
|
1640
1652
|
/**
|
|
1641
|
-
* Returns an `HDate`
|
|
1642
|
-
*
|
|
1653
|
+
* Returns an `HDate` corresponding to the specified day of week
|
|
1654
|
+
* **after** this Hebrew date
|
|
1643
1655
|
* @example
|
|
1644
1656
|
* new HDate(new Date('Wednesday February 19, 2014')).after(6).greg() // Sat Feb 22 2014
|
|
1645
1657
|
* new HDate(new Date('Saturday February 22, 2014')).after(6).greg() // Sat Mar 01 2014
|
|
1646
1658
|
* new HDate(new Date('Sunday February 23, 2014')).after(6).greg() // Sat Mar 01 2014
|
|
1647
|
-
* @param
|
|
1648
|
-
* @return {HDate}
|
|
1659
|
+
* @param dayOfWeek day of week: Sunday=0, Saturday=6
|
|
1649
1660
|
*/
|
|
1650
|
-
after(
|
|
1651
|
-
return onOrBefore(
|
|
1661
|
+
after(dayOfWeek) {
|
|
1662
|
+
return onOrBefore(dayOfWeek, this, 7);
|
|
1652
1663
|
}
|
|
1653
1664
|
/**
|
|
1654
1665
|
* Returns the next Hebrew date
|
|
1655
|
-
* @
|
|
1666
|
+
* @example
|
|
1667
|
+
* const hd = new HDate(new Date(2008, 10, 13)); // 15 Cheshvan 5769
|
|
1668
|
+
* hd.next(); // '16 Cheshvan 5769'
|
|
1656
1669
|
*/
|
|
1657
1670
|
next() {
|
|
1658
1671
|
return new HDate(this.abs() + 1);
|
|
1659
1672
|
}
|
|
1660
1673
|
/**
|
|
1661
1674
|
* Returns the previous Hebrew date
|
|
1662
|
-
* @
|
|
1675
|
+
* @example
|
|
1676
|
+
* const hd = new HDate(new Date(2008, 10, 13)); // 15 Cheshvan 5769
|
|
1677
|
+
* hd.prev(); // '14 Cheshvan 5769'
|
|
1663
1678
|
*/
|
|
1664
1679
|
prev() {
|
|
1665
1680
|
return new HDate(this.abs() - 1);
|
|
@@ -1676,12 +1691,10 @@ class HDate {
|
|
|
1676
1691
|
* | `week` | `w` | weeks |
|
|
1677
1692
|
* | `month` | `M` | months |
|
|
1678
1693
|
* | `year` | `y` | years |
|
|
1679
|
-
* @param {number} amount
|
|
1680
|
-
* @param {string} [units]
|
|
1681
|
-
* @return {HDate}
|
|
1682
1694
|
*/
|
|
1683
1695
|
add(amount, units = 'd') {
|
|
1684
|
-
amount =
|
|
1696
|
+
amount =
|
|
1697
|
+
typeof amount === 'string' ? parseInt(amount, 10) : amount;
|
|
1685
1698
|
if (!amount) {
|
|
1686
1699
|
return new HDate(this);
|
|
1687
1700
|
}
|
|
@@ -1690,7 +1703,7 @@ class HDate {
|
|
|
1690
1703
|
return new HDate(this.abs() + amount);
|
|
1691
1704
|
}
|
|
1692
1705
|
else if (units === UNITS_WEEK) {
|
|
1693
|
-
return new HDate(this.abs() +
|
|
1706
|
+
return new HDate(this.abs() + 7 * amount);
|
|
1694
1707
|
}
|
|
1695
1708
|
else if (units === UNITS_YEAR) {
|
|
1696
1709
|
return new HDate(this.getDate(), this.getMonth(), this.getFullYear() + amount);
|
|
@@ -1700,7 +1713,7 @@ class HDate {
|
|
|
1700
1713
|
const sign = amount > 0 ? 1 : -1;
|
|
1701
1714
|
amount = Math.abs(amount);
|
|
1702
1715
|
for (let i = 0; i < amount; i++) {
|
|
1703
|
-
hd = new HDate(hd.abs() +
|
|
1716
|
+
hd = new HDate(hd.abs() + sign * hd.daysInMonth());
|
|
1704
1717
|
}
|
|
1705
1718
|
return hd;
|
|
1706
1719
|
}
|
|
@@ -1726,9 +1739,6 @@ class HDate {
|
|
|
1726
1739
|
* const hd1 = new HDate(15, months.CHESHVAN, 5769);
|
|
1727
1740
|
* const hd2 = hd1.add(1, 'weeks'); // 7 Kislev 5769
|
|
1728
1741
|
* const hd3 = hd1.add(-3, 'M'); // 30 Av 5768
|
|
1729
|
-
* @param {number} amount
|
|
1730
|
-
* @param {string} [units]
|
|
1731
|
-
* @return {HDate}
|
|
1732
1742
|
*/
|
|
1733
1743
|
subtract(amount, units = 'd') {
|
|
1734
1744
|
return this.add(amount * -1, units);
|
|
@@ -1747,8 +1757,7 @@ class HDate {
|
|
|
1747
1757
|
* const hd1 = new HDate(25, months.KISLEV, 5770);
|
|
1748
1758
|
* const hd2 = new HDate(15, months.CHESHVAN, 5769);
|
|
1749
1759
|
* const days = hd1.deltaDays(hd2); // 394
|
|
1750
|
-
* @param
|
|
1751
|
-
* @return {number}
|
|
1760
|
+
* @param other Hebrew date to compare
|
|
1752
1761
|
*/
|
|
1753
1762
|
deltaDays(other) {
|
|
1754
1763
|
if (!HDate.isHDate(other)) {
|
|
@@ -1757,19 +1766,25 @@ class HDate {
|
|
|
1757
1766
|
return this.abs() - other.abs();
|
|
1758
1767
|
}
|
|
1759
1768
|
/**
|
|
1760
|
-
* Compares this date to another date, returning `true` if the dates match.
|
|
1761
|
-
* @param
|
|
1762
|
-
* @
|
|
1769
|
+
* Compares this Hebrew date to another date, returning `true` if the dates match.
|
|
1770
|
+
* @param other Hebrew date to compare
|
|
1771
|
+
* @example
|
|
1772
|
+
* const hd1 = new HDate(new Date(2008, 10, 13));
|
|
1773
|
+
* const hd2 = new HDate(15, 'Cheshvan', 5769);
|
|
1774
|
+
* hd1.isSameDate(hd2); // true
|
|
1763
1775
|
*/
|
|
1764
1776
|
isSameDate(other) {
|
|
1765
1777
|
if (HDate.isHDate(other)) {
|
|
1766
|
-
return this.yy === other.yy &&
|
|
1767
|
-
this.mm === other.mm &&
|
|
1768
|
-
this.dd === other.dd;
|
|
1778
|
+
return (this.yy === other.yy && this.mm === other.mm && this.dd === other.dd);
|
|
1769
1779
|
}
|
|
1770
1780
|
return false;
|
|
1771
1781
|
}
|
|
1772
|
-
/**
|
|
1782
|
+
/**
|
|
1783
|
+
* Returns a string representation of this Hebrew date using English transliterations
|
|
1784
|
+
* @example
|
|
1785
|
+
* const hd = new HDate(new Date(2008, 10, 13)); // 15 Cheshvan 5769
|
|
1786
|
+
* hd.toString(); // '15 Cheshvan 5769'
|
|
1787
|
+
*/
|
|
1773
1788
|
toString() {
|
|
1774
1789
|
const day = this.getDate();
|
|
1775
1790
|
const fullYear = this.getFullYear();
|
|
@@ -1778,25 +1793,31 @@ class HDate {
|
|
|
1778
1793
|
}
|
|
1779
1794
|
/**
|
|
1780
1795
|
* Returns true if Hebrew year is a leap year
|
|
1781
|
-
* @param
|
|
1782
|
-
* @
|
|
1796
|
+
* @param year Hebrew year
|
|
1797
|
+
* @example
|
|
1798
|
+
* HDate.isLeapYear(5783); // false
|
|
1799
|
+
* HDate.isLeapYear(5784); // true
|
|
1783
1800
|
*/
|
|
1784
1801
|
static isLeapYear(year) {
|
|
1785
1802
|
return isLeapYear(year);
|
|
1786
1803
|
}
|
|
1787
1804
|
/**
|
|
1788
1805
|
* Number of months in this Hebrew year (either 12 or 13 depending on leap year)
|
|
1789
|
-
* @param
|
|
1790
|
-
* @
|
|
1806
|
+
* @param year Hebrew year
|
|
1807
|
+
* @example
|
|
1808
|
+
* HDate.monthsInYear(5783); // 12
|
|
1809
|
+
* HDate.monthsInYear(5784); // 13
|
|
1791
1810
|
*/
|
|
1792
1811
|
static monthsInYear(year) {
|
|
1793
1812
|
return monthsInYear(year);
|
|
1794
1813
|
}
|
|
1795
1814
|
/**
|
|
1796
1815
|
* Number of days in Hebrew month in a given year (29 or 30)
|
|
1797
|
-
* @param
|
|
1798
|
-
* @param
|
|
1799
|
-
* @
|
|
1816
|
+
* @param month Hebrew month (e.g. months.TISHREI)
|
|
1817
|
+
* @param year Hebrew year
|
|
1818
|
+
* @example
|
|
1819
|
+
* import {HDate, months} from '@hebcal/hdate';
|
|
1820
|
+
* HDate.daysInMonth(months.CHESHVAN, 5769); // 29
|
|
1800
1821
|
*/
|
|
1801
1822
|
static daysInMonth(month, year) {
|
|
1802
1823
|
return daysInMonth(month, year);
|
|
@@ -1804,17 +1825,23 @@ class HDate {
|
|
|
1804
1825
|
/**
|
|
1805
1826
|
* Returns a transliterated string name of Hebrew month in year,
|
|
1806
1827
|
* for example 'Elul' or 'Cheshvan'.
|
|
1807
|
-
* @param
|
|
1808
|
-
* @param
|
|
1809
|
-
* @
|
|
1828
|
+
* @param month Hebrew month (e.g. months.TISHREI)
|
|
1829
|
+
* @param year Hebrew year
|
|
1830
|
+
* @example
|
|
1831
|
+
* import {HDate, months} from '@hebcal/hdate';
|
|
1832
|
+
* HDate.getMonthName(months.CHESHVAN, 5769); // 'Cheshvan'
|
|
1810
1833
|
*/
|
|
1811
1834
|
static getMonthName(month, year) {
|
|
1812
1835
|
return getMonthName(month, year);
|
|
1813
1836
|
}
|
|
1814
1837
|
/**
|
|
1815
1838
|
* Returns the Hebrew month number (NISAN=1, TISHREI=7)
|
|
1816
|
-
* @param
|
|
1817
|
-
* @
|
|
1839
|
+
* @param month A number, or Hebrew month name string
|
|
1840
|
+
* @example
|
|
1841
|
+
* import {HDate, months} from '@hebcal/hdate';
|
|
1842
|
+
* HDate.monthNum(months.CHESHVAN); // 8
|
|
1843
|
+
* HDate.monthNum('Cheshvan'); // 8
|
|
1844
|
+
* HDate.monthNum('חשון'); // 8
|
|
1818
1845
|
*/
|
|
1819
1846
|
static monthNum(month) {
|
|
1820
1847
|
if (typeof month === 'number') {
|
|
@@ -1823,38 +1850,49 @@ class HDate {
|
|
|
1823
1850
|
}
|
|
1824
1851
|
return month;
|
|
1825
1852
|
}
|
|
1826
|
-
return month.charCodeAt(0) >= 48 && month.charCodeAt(0) <= 57
|
|
1827
|
-
parseInt(month, 10)
|
|
1828
|
-
HDate.monthFromName(month);
|
|
1853
|
+
return month.charCodeAt(0) >= 48 && month.charCodeAt(0) <= 57 /* number */
|
|
1854
|
+
? parseInt(month, 10)
|
|
1855
|
+
: HDate.monthFromName(month);
|
|
1829
1856
|
}
|
|
1830
1857
|
/**
|
|
1831
|
-
* Number of days in the
|
|
1832
|
-
*
|
|
1833
|
-
*
|
|
1858
|
+
* Number of days in the Hebrew year.
|
|
1859
|
+
* Regular years can have 353, 354, or 355 days.
|
|
1860
|
+
* Leap years can have 383, 384, or 385 days.
|
|
1861
|
+
* @param year Hebrew year
|
|
1862
|
+
* @example
|
|
1863
|
+
* HDate.daysInYear(5783); // 355
|
|
1864
|
+
* HDate.daysInYear(5784); // 383
|
|
1834
1865
|
*/
|
|
1835
1866
|
static daysInYear(year) {
|
|
1836
1867
|
return daysInYear(year);
|
|
1837
1868
|
}
|
|
1838
1869
|
/**
|
|
1839
1870
|
* true if Cheshvan is long in Hebrew year
|
|
1840
|
-
* @param
|
|
1841
|
-
* @
|
|
1871
|
+
* @param year Hebrew year
|
|
1872
|
+
* @example
|
|
1873
|
+
* HDate.longCheshvan(5783); // true
|
|
1874
|
+
* HDate.longCheshvan(5784); // false
|
|
1842
1875
|
*/
|
|
1843
1876
|
static longCheshvan(year) {
|
|
1844
1877
|
return longCheshvan(year);
|
|
1845
1878
|
}
|
|
1846
1879
|
/**
|
|
1847
1880
|
* true if Kislev is short in Hebrew year
|
|
1848
|
-
* @param
|
|
1849
|
-
* @
|
|
1881
|
+
* @param year Hebrew year
|
|
1882
|
+
* @example
|
|
1883
|
+
* HDate.shortKislev(5783); // false
|
|
1884
|
+
* HDate.shortKislev(5784); // true
|
|
1850
1885
|
*/
|
|
1851
1886
|
static shortKislev(year) {
|
|
1852
1887
|
return shortKislev(year);
|
|
1853
1888
|
}
|
|
1854
1889
|
/**
|
|
1855
1890
|
* Converts Hebrew month string name to numeric
|
|
1856
|
-
* @
|
|
1857
|
-
*
|
|
1891
|
+
* @example
|
|
1892
|
+
* import {HDate, months} from '@hebcal/hdate';
|
|
1893
|
+
* HDate.monthFromName(months.CHESHVAN); // 8
|
|
1894
|
+
* HDate.monthFromName('Cheshvan'); // 8
|
|
1895
|
+
* HDate.monthFromName('חשון'); // 8
|
|
1858
1896
|
*/
|
|
1859
1897
|
static monthFromName(monthName) {
|
|
1860
1898
|
if (typeof monthName === 'number') {
|
|
@@ -1867,42 +1905,45 @@ class HDate {
|
|
|
1867
1905
|
return monthFromName(name);
|
|
1868
1906
|
}
|
|
1869
1907
|
/**
|
|
1870
|
-
*
|
|
1871
|
-
*
|
|
1872
|
-
*
|
|
1873
|
-
*
|
|
1874
|
-
*
|
|
1875
|
-
*
|
|
1876
|
-
*
|
|
1908
|
+
* Convenience function for determining the R.D. date
|
|
1909
|
+
* near a specified R.D. date, corresponding to the specified day of week.
|
|
1910
|
+
*
|
|
1911
|
+
* Note: Applying this function to d+6 gives us the `dayOfWeek` on or after an
|
|
1912
|
+
* absolute day d. Similarly, applying it to d+3 gives the `dayOfWeek` nearest to
|
|
1913
|
+
* absolute date d, applying it to d-1 gives the `dayOfWeek` previous to absolute
|
|
1914
|
+
* date d, and applying it to d+7 gives the `dayOfWeek` following absolute date d.
|
|
1915
|
+
* @param dayOfWeek day of week: Sunday=0, Saturday=6
|
|
1877
1916
|
*/
|
|
1878
1917
|
static dayOnOrBefore(dayOfWeek, absdate) {
|
|
1879
1918
|
return absdate - ((absdate - dayOfWeek) % 7);
|
|
1880
1919
|
}
|
|
1881
1920
|
/**
|
|
1882
1921
|
* Tests if the object is an instance of `HDate`
|
|
1883
|
-
* @
|
|
1884
|
-
*
|
|
1922
|
+
* @example
|
|
1923
|
+
* HDate.isHDate(new HDate()); // true
|
|
1924
|
+
* HDate.isHDate(new Date()); // false
|
|
1925
|
+
* HDate.isHDate(null); // false
|
|
1926
|
+
* HDate.isHDate(12345); // false
|
|
1927
|
+
* HDate.isHDate('15 Cheshvan 5769'); // false
|
|
1885
1928
|
*/
|
|
1886
1929
|
static isHDate(obj) {
|
|
1887
|
-
return obj !== null &&
|
|
1930
|
+
return (obj !== null &&
|
|
1931
|
+
typeof obj === 'object' &&
|
|
1888
1932
|
typeof obj.yy === 'number' &&
|
|
1889
1933
|
typeof obj.mm === 'number' &&
|
|
1890
1934
|
typeof obj.dd === 'number' &&
|
|
1891
1935
|
typeof obj.greg === 'function' &&
|
|
1892
|
-
typeof obj.abs === 'function';
|
|
1936
|
+
typeof obj.abs === 'function');
|
|
1893
1937
|
}
|
|
1894
1938
|
/**
|
|
1895
1939
|
* Construct a new instance of `HDate` from a Gematriya-formatted string
|
|
1896
1940
|
* @example
|
|
1897
|
-
*
|
|
1898
|
-
*
|
|
1899
|
-
*
|
|
1900
|
-
* @param {string} str
|
|
1901
|
-
* @param {number} currentThousands
|
|
1902
|
-
* @return {HDate}
|
|
1941
|
+
* HDate.fromGematriyaString('כ״ז בְּתַמּוּז תשפ״ג') // 27 Tamuz 5783
|
|
1942
|
+
* HDate.fromGematriyaString('כ׳ סיון תש״ד') // 20 Sivan 5704
|
|
1943
|
+
* HDate.fromGematriyaString('ה׳ אִיָיר תש״ח') // 5 Iyyar 5708
|
|
1903
1944
|
*/
|
|
1904
1945
|
static fromGematriyaString(str, currentThousands = 5000) {
|
|
1905
|
-
const parts = str.split(' ').filter(
|
|
1946
|
+
const parts = str.split(' ').filter(x => x.length !== 0);
|
|
1906
1947
|
const numParts = parts.length;
|
|
1907
1948
|
if (numParts !== 3 && numParts !== 4) {
|
|
1908
1949
|
throw new RangeError(`Unable to parse gematriya string: "${str}"`);
|
|
@@ -1920,12 +1961,18 @@ class HDate {
|
|
|
1920
1961
|
}
|
|
1921
1962
|
function standardizeUnits(units) {
|
|
1922
1963
|
switch (units) {
|
|
1923
|
-
case 'd':
|
|
1924
|
-
|
|
1925
|
-
case '
|
|
1926
|
-
|
|
1927
|
-
|
|
1928
|
-
|
|
1964
|
+
case 'd':
|
|
1965
|
+
return UNITS_DAY;
|
|
1966
|
+
case 'w':
|
|
1967
|
+
return UNITS_WEEK;
|
|
1968
|
+
case 'M':
|
|
1969
|
+
return UNITS_MONTH;
|
|
1970
|
+
case 'y':
|
|
1971
|
+
return UNITS_YEAR;
|
|
1972
|
+
}
|
|
1973
|
+
const str = String(units || '')
|
|
1974
|
+
.toLowerCase()
|
|
1975
|
+
.replace(/s$/, '');
|
|
1929
1976
|
switch (str) {
|
|
1930
1977
|
case UNITS_DAY:
|
|
1931
1978
|
case UNITS_WEEK:
|
|
@@ -1955,8 +2002,7 @@ function getDayOfTranslation(locale) {
|
|
|
1955
2002
|
/**
|
|
1956
2003
|
* Sets the day of the month of the date. Returns the object it was called upon
|
|
1957
2004
|
* @private
|
|
1958
|
-
* @param
|
|
1959
|
-
* @return {HDate}
|
|
2005
|
+
* @param month A number, or Hebrew month name string
|
|
1960
2006
|
*/
|
|
1961
2007
|
function setMonth(hd, month) {
|
|
1962
2008
|
hd.mm = HDate.monthNum(month);
|
|
@@ -2038,7 +2084,8 @@ const poHeNoNikud = {
|
|
|
2038
2084
|
Locale.addTranslations('he-x-NoNikud', poHeNoNikud);
|
|
2039
2085
|
|
|
2040
2086
|
/**
|
|
2041
|
-
* Holiday flags for Event
|
|
2087
|
+
* Holiday flags for Event. These flags are typically
|
|
2088
|
+
* combined using bitwise arithmetic to form a mask.
|
|
2042
2089
|
* @readonly
|
|
2043
2090
|
* @enum {number}
|
|
2044
2091
|
*/
|
|
@@ -2113,14 +2160,22 @@ const flagToCategory = [
|
|
|
2113
2160
|
[flags.SPECIAL_SHABBAT, 'holiday', 'shabbat'],
|
|
2114
2161
|
[flags.USER_EVENT, 'user'],
|
|
2115
2162
|
];
|
|
2116
|
-
/**
|
|
2163
|
+
/**
|
|
2164
|
+
* Represents an Event with a title, date, and flags.
|
|
2165
|
+
*
|
|
2166
|
+
* Events are used to represent holidays, candle-lighting times,
|
|
2167
|
+
* Torah readings, and more.
|
|
2168
|
+
*
|
|
2169
|
+
* To get the title of the event a language other than English
|
|
2170
|
+
* with Sephardic transliterations, use the `render()` method.
|
|
2171
|
+
*/
|
|
2117
2172
|
class Event {
|
|
2118
2173
|
/**
|
|
2119
2174
|
* Constructs Event
|
|
2120
|
-
* @param
|
|
2121
|
-
* @param
|
|
2122
|
-
* @param
|
|
2123
|
-
* @param
|
|
2175
|
+
* @param date Hebrew date event occurs
|
|
2176
|
+
* @param desc Description (not translated)
|
|
2177
|
+
* @param [mask=0] optional bitmask of holiday flags (see {@link flags})
|
|
2178
|
+
* @param [attrs={}] optional additional attributes (e.g. `eventTimeStr`, `cholHaMoedDay`)
|
|
2124
2179
|
*/
|
|
2125
2180
|
constructor(date, desc, mask = 0, attrs) {
|
|
2126
2181
|
if (!HDate.isHDate(date)) {
|
|
@@ -2138,21 +2193,21 @@ class Event {
|
|
|
2138
2193
|
}
|
|
2139
2194
|
/**
|
|
2140
2195
|
* Hebrew date of this event
|
|
2141
|
-
* @return {HDate}
|
|
2142
2196
|
*/
|
|
2143
2197
|
getDate() {
|
|
2144
2198
|
return this.date;
|
|
2145
2199
|
}
|
|
2146
2200
|
/**
|
|
2147
|
-
* Untranslated
|
|
2148
|
-
*
|
|
2201
|
+
* Untranslated title of this event. Note that these description
|
|
2202
|
+
* strings are always in English and will remain stable across releases.
|
|
2203
|
+
* To get the title of the event in another language, use the
|
|
2204
|
+
* `render()` method.
|
|
2149
2205
|
*/
|
|
2150
2206
|
getDesc() {
|
|
2151
2207
|
return this.desc;
|
|
2152
2208
|
}
|
|
2153
2209
|
/**
|
|
2154
2210
|
* Bitmask of optional event flags. See {@link flags}
|
|
2155
|
-
* @return {number}
|
|
2156
2211
|
*/
|
|
2157
2212
|
getFlags() {
|
|
2158
2213
|
return this.mask;
|
|
@@ -2164,8 +2219,7 @@ class Event {
|
|
|
2164
2219
|
* ev.render('en'); // 'Shavuot'
|
|
2165
2220
|
* ev.render('he'); // 'שָׁבוּעוֹת'
|
|
2166
2221
|
* ev.render('ashkenazi'); // 'Shavuos'
|
|
2167
|
-
* @param
|
|
2168
|
-
* @return {string}
|
|
2222
|
+
* @param [locale] Optional locale name (defaults to active locale).
|
|
2169
2223
|
*/
|
|
2170
2224
|
render(locale) {
|
|
2171
2225
|
return Locale.gettext(this.desc, locale);
|
|
@@ -2174,25 +2228,22 @@ class Event {
|
|
|
2174
2228
|
* Returns a brief (translated) description of this event.
|
|
2175
2229
|
* For most events, this is the same as render(). For some events, it procudes
|
|
2176
2230
|
* a shorter text (e.g. without a time or added description).
|
|
2177
|
-
* @param
|
|
2178
|
-
* @return {string}
|
|
2231
|
+
* @param [locale] Optional locale name (defaults to active locale).
|
|
2179
2232
|
*/
|
|
2180
2233
|
renderBrief(locale) {
|
|
2181
2234
|
return this.render(locale);
|
|
2182
2235
|
}
|
|
2183
2236
|
/**
|
|
2184
2237
|
* Optional holiday-specific Emoji or `null`.
|
|
2185
|
-
* @return {string | null}
|
|
2186
2238
|
*/
|
|
2187
2239
|
getEmoji() {
|
|
2188
2240
|
return this.emoji || null;
|
|
2189
2241
|
}
|
|
2190
2242
|
/**
|
|
2191
2243
|
* Returns a simplified (untranslated) description for this event. For example,
|
|
2192
|
-
* the
|
|
2244
|
+
* the `HolidayEvent` class supports
|
|
2193
2245
|
* "Erev Pesach" => "Pesach", and "Sukkot III (CH''M)" => "Sukkot".
|
|
2194
2246
|
* For many holidays the basename and the event description are the same.
|
|
2195
|
-
* @return {string}
|
|
2196
2247
|
*/
|
|
2197
2248
|
basename() {
|
|
2198
2249
|
return this.getDesc();
|
|
@@ -2200,7 +2251,6 @@ class Event {
|
|
|
2200
2251
|
/**
|
|
2201
2252
|
* Returns a URL to hebcal.com or sefaria.org for more detail on the event.
|
|
2202
2253
|
* Returns `undefined` for events with no detail page.
|
|
2203
|
-
* @return {string | undefined}
|
|
2204
2254
|
*/
|
|
2205
2255
|
url() {
|
|
2206
2256
|
return undefined;
|
|
@@ -2212,7 +2262,6 @@ class Event {
|
|
|
2212
2262
|
* ev1.observedInIsrael(); // false
|
|
2213
2263
|
* const ev2 = new Event(new HDate(26, 'Kislev', 5749), 'Chanukah: 3 Candles', 0);
|
|
2214
2264
|
* ev2.observedInIsrael(); // true
|
|
2215
|
-
* @return {boolean}
|
|
2216
2265
|
*/
|
|
2217
2266
|
observedInIsrael() {
|
|
2218
2267
|
return !(this.mask & flags.CHUL_ONLY);
|
|
@@ -2224,7 +2273,6 @@ class Event {
|
|
|
2224
2273
|
* ev1.observedInDiaspora(); // true
|
|
2225
2274
|
* const ev2 = new Event(new HDate(26, 'Kislev', 5749), 'Chanukah: 3 Candles', 0);
|
|
2226
2275
|
* ev2.observedInDiaspora(); // true
|
|
2227
|
-
* @return {boolean}
|
|
2228
2276
|
*/
|
|
2229
2277
|
observedInDiaspora() {
|
|
2230
2278
|
return !(this.mask & flags.IL_ONLY);
|
|
@@ -2238,19 +2286,18 @@ class Event {
|
|
|
2238
2286
|
* const ev2 = new Event(new HDate(26, 'Kislev', 5749), 'Chanukah: 3 Candles', 0);
|
|
2239
2287
|
* ev2.observedIn(false); // true
|
|
2240
2288
|
* ev2.observedIn(true); // true
|
|
2241
|
-
* @param
|
|
2242
|
-
* @return {boolean}
|
|
2289
|
+
* @param il
|
|
2243
2290
|
*/
|
|
2244
2291
|
observedIn(il) {
|
|
2245
2292
|
return il ? this.observedInIsrael() : this.observedInDiaspora();
|
|
2246
2293
|
}
|
|
2247
2294
|
/**
|
|
2248
2295
|
* Makes a clone of this Event object
|
|
2249
|
-
* @return {Event}
|
|
2250
2296
|
*/
|
|
2251
2297
|
clone() {
|
|
2252
2298
|
const ev = new Event(this.date, this.desc, this.mask);
|
|
2253
2299
|
for (const property in this) {
|
|
2300
|
+
// eslint-disable-next-line no-prototype-builtins
|
|
2254
2301
|
if (this.hasOwnProperty(property)) {
|
|
2255
2302
|
Object.defineProperty(ev, property, { value: this[property] });
|
|
2256
2303
|
}
|
|
@@ -2259,7 +2306,6 @@ class Event {
|
|
|
2259
2306
|
}
|
|
2260
2307
|
/**
|
|
2261
2308
|
* Returns a list of event categories
|
|
2262
|
-
* @return {string[]}
|
|
2263
2309
|
*/
|
|
2264
2310
|
getCategories() {
|
|
2265
2311
|
const mask = this.getFlags();
|
|
@@ -2276,13 +2322,13 @@ class Event {
|
|
|
2276
2322
|
/** Daily Hebrew date ("11th of Sivan, 5780") */
|
|
2277
2323
|
class HebrewDateEvent extends Event {
|
|
2278
2324
|
/**
|
|
2279
|
-
* @param
|
|
2325
|
+
* @param date
|
|
2280
2326
|
*/
|
|
2281
2327
|
constructor(date) {
|
|
2282
2328
|
super(date, date.toString(), flags.HEBREW_DATE);
|
|
2283
2329
|
}
|
|
2284
2330
|
/**
|
|
2285
|
-
* @param
|
|
2331
|
+
* @param [locale] Optional locale name (defaults to active locale).
|
|
2286
2332
|
* @example
|
|
2287
2333
|
* import {HDate, HebrewDateEvent, months} from '@hebcal/core';
|
|
2288
2334
|
*
|
|
@@ -2290,7 +2336,6 @@ class HebrewDateEvent extends Event {
|
|
|
2290
2336
|
* const ev = new HebrewDateEvent(hd);
|
|
2291
2337
|
* console.log(ev.render('en')); // '15th of Cheshvan, 5769'
|
|
2292
2338
|
* console.log(ev.render('he')); // 'ט״ו חֶשְׁוָן תשס״ט'
|
|
2293
|
-
* @return {string}
|
|
2294
2339
|
*/
|
|
2295
2340
|
render(locale) {
|
|
2296
2341
|
const locale1 = locale === null || locale === void 0 ? void 0 : locale.toLowerCase();
|
|
@@ -2308,8 +2353,7 @@ class HebrewDateEvent extends Event {
|
|
|
2308
2353
|
}
|
|
2309
2354
|
/**
|
|
2310
2355
|
* @private
|
|
2311
|
-
* @param
|
|
2312
|
-
* @return {string}
|
|
2356
|
+
* @param locale
|
|
2313
2357
|
*/
|
|
2314
2358
|
renderBriefHebrew(locale) {
|
|
2315
2359
|
const hd = this.getDate();
|
|
@@ -2318,7 +2362,7 @@ class HebrewDateEvent extends Event {
|
|
|
2318
2362
|
return gematriya(dd) + ' ' + mm;
|
|
2319
2363
|
}
|
|
2320
2364
|
/**
|
|
2321
|
-
* @param
|
|
2365
|
+
* @param [locale] Optional locale name (defaults to active locale).
|
|
2322
2366
|
* @example
|
|
2323
2367
|
* import {HDate, HebrewDateEvent, months} from '@hebcal/core';
|
|
2324
2368
|
*
|
|
@@ -2326,7 +2370,6 @@ class HebrewDateEvent extends Event {
|
|
|
2326
2370
|
* const ev = new HebrewDateEvent(hd);
|
|
2327
2371
|
* console.log(ev.renderBrief()); // '15th of Cheshvan'
|
|
2328
2372
|
* console.log(ev.renderBrief('he')); // 'ט״ו חֶשְׁוָן'
|
|
2329
|
-
* @return {string}
|
|
2330
2373
|
*/
|
|
2331
2374
|
renderBrief(locale) {
|
|
2332
2375
|
const locale1 = locale === null || locale === void 0 ? void 0 : locale.toLowerCase();
|
|
@@ -7504,7 +7547,14 @@ const classicCities0 = [
|
|
|
7504
7547
|
['Bogota', 'CO', 4.60971, -74.08175, 'America/Bogota', 2582],
|
|
7505
7548
|
['Boston', 'US', 42.35843, -71.05977, 'America/New_York', 38],
|
|
7506
7549
|
['Budapest', 'HU', 47.49801, 19.03991, 'Europe/Budapest', 104],
|
|
7507
|
-
[
|
|
7550
|
+
[
|
|
7551
|
+
'Buenos Aires',
|
|
7552
|
+
'AR',
|
|
7553
|
+
-34.61315,
|
|
7554
|
+
-58.37723,
|
|
7555
|
+
'America/Argentina/Buenos_Aires',
|
|
7556
|
+
31,
|
|
7557
|
+
],
|
|
7508
7558
|
['Buffalo', 'US', 42.88645, -78.87837, 'America/New_York', 191],
|
|
7509
7559
|
['Chicago', 'US', 41.85003, -87.65005, 'America/Chicago', 180],
|
|
7510
7560
|
['Cincinnati', 'US', 39.162, -84.45689, 'America/New_York', 267],
|
|
@@ -7601,14 +7651,14 @@ function getFormatter(tzid) {
|
|
|
7601
7651
|
class Location extends GeoLocation {
|
|
7602
7652
|
/**
|
|
7603
7653
|
* Initialize a Location instance
|
|
7604
|
-
* @param
|
|
7605
|
-
* @param
|
|
7606
|
-
* @param
|
|
7607
|
-
* @param
|
|
7608
|
-
* @param
|
|
7609
|
-
* @param
|
|
7610
|
-
* @param
|
|
7611
|
-
* @param
|
|
7654
|
+
* @param latitude - Latitude as a decimal, valid range -90 thru +90 (e.g. 41.85003)
|
|
7655
|
+
* @param longitude - Longitude as a decimal, valid range -180 thru +180 (e.g. -87.65005)
|
|
7656
|
+
* @param il - in Israel (true) or Diaspora (false)
|
|
7657
|
+
* @param tzid - Olson timezone ID, e.g. "America/Chicago"
|
|
7658
|
+
* @param [cityName] - optional descriptive city name
|
|
7659
|
+
* @param [countryCode] - ISO 3166 alpha-2 country code (e.g. "FR")
|
|
7660
|
+
* @param [geoid] - optional string or numeric geographic ID
|
|
7661
|
+
* @param [elevation] - in meters (default `0`)
|
|
7612
7662
|
*/
|
|
7613
7663
|
constructor(latitude, longitude, il, tzid, cityName, countryCode, geoid, elevation) {
|
|
7614
7664
|
const lat = typeof latitude === 'number' ? latitude : parseFloat(latitude);
|
|
@@ -7619,23 +7669,20 @@ class Location extends GeoLocation {
|
|
|
7619
7669
|
if (isNaN(long) || long < -180 || long > 180) {
|
|
7620
7670
|
throw new RangeError(`Longitude ${longitude} out of range [-180,180]`);
|
|
7621
7671
|
}
|
|
7622
|
-
const elev =
|
|
7672
|
+
const elev = typeof elevation === 'number' && elevation > 0 ? elevation : 0;
|
|
7623
7673
|
super(cityName || null, lat, long, elev, tzid);
|
|
7624
7674
|
this.il = Boolean(il);
|
|
7625
7675
|
this.cc = countryCode;
|
|
7626
7676
|
this.geoid = geoid;
|
|
7627
7677
|
}
|
|
7628
|
-
/** @return {boolean} */
|
|
7629
7678
|
getIsrael() {
|
|
7630
7679
|
return this.il;
|
|
7631
7680
|
}
|
|
7632
|
-
/** @return {string | null} */
|
|
7633
7681
|
getName() {
|
|
7634
7682
|
return this.getLocationName();
|
|
7635
7683
|
}
|
|
7636
7684
|
/**
|
|
7637
7685
|
* Returns the location name, up to the first comma
|
|
7638
|
-
* @return {string | null}
|
|
7639
7686
|
*/
|
|
7640
7687
|
getShortName() {
|
|
7641
7688
|
const name = this.getLocationName();
|
|
@@ -7654,22 +7701,18 @@ class Location extends GeoLocation {
|
|
|
7654
7701
|
}
|
|
7655
7702
|
return name.substring(0, comma);
|
|
7656
7703
|
}
|
|
7657
|
-
/** @return {string | undefined} */
|
|
7658
7704
|
getCountryCode() {
|
|
7659
7705
|
return this.cc;
|
|
7660
7706
|
}
|
|
7661
|
-
/** @return {string} */
|
|
7662
7707
|
getTzid() {
|
|
7663
7708
|
return this.getTimeZone();
|
|
7664
7709
|
}
|
|
7665
7710
|
/**
|
|
7666
7711
|
* Gets a 24-hour time formatter (e.g. 07:41 or 20:03) for this location
|
|
7667
|
-
* @return {Intl.DateTimeFormat}
|
|
7668
7712
|
*/
|
|
7669
7713
|
getTimeFormatter() {
|
|
7670
7714
|
return getFormatter(this.getTimeZone());
|
|
7671
7715
|
}
|
|
7672
|
-
/** @return {string | number | undefined} */
|
|
7673
7716
|
getGeoId() {
|
|
7674
7717
|
return this.geoid;
|
|
7675
7718
|
}
|
|
@@ -7689,26 +7732,23 @@ class Location extends GeoLocation {
|
|
|
7689
7732
|
* 'San Diego', 'San Francisco', 'Sao Paulo', 'Seattle', 'Sydney',
|
|
7690
7733
|
* 'Tel Aviv', 'Tiberias', 'Toronto', 'Vancouver', 'White Plains',
|
|
7691
7734
|
* 'Washington DC', 'Worcester'
|
|
7692
|
-
* @param
|
|
7693
|
-
* @return {Location|undefined}
|
|
7735
|
+
* @param name
|
|
7694
7736
|
*/
|
|
7695
7737
|
static lookup(name) {
|
|
7696
7738
|
return classicCities.get(name.toLowerCase());
|
|
7697
7739
|
}
|
|
7698
|
-
/** @return {string} */
|
|
7699
7740
|
toString() {
|
|
7700
7741
|
return JSON.stringify(this);
|
|
7701
7742
|
}
|
|
7702
7743
|
/**
|
|
7703
7744
|
* Converts legacy Hebcal timezone to a standard Olson tzid.
|
|
7704
|
-
* @param
|
|
7705
|
-
* @param
|
|
7706
|
-
* @return {string | undefined}
|
|
7745
|
+
* @param tz integer, GMT offset in hours
|
|
7746
|
+
* @param dst 'none', 'eu', 'usa', or 'israel'
|
|
7707
7747
|
*/
|
|
7708
7748
|
static legacyTzToTzid(tz, dst) {
|
|
7709
7749
|
tz = +tz;
|
|
7710
|
-
if (dst
|
|
7711
|
-
if (tz
|
|
7750
|
+
if (dst === 'none') {
|
|
7751
|
+
if (tz === 0) {
|
|
7712
7752
|
return 'UTC';
|
|
7713
7753
|
}
|
|
7714
7754
|
else {
|
|
@@ -7716,19 +7756,24 @@ class Location extends GeoLocation {
|
|
|
7716
7756
|
return `Etc/GMT${plus}${tz}`;
|
|
7717
7757
|
}
|
|
7718
7758
|
}
|
|
7719
|
-
else if (tz
|
|
7759
|
+
else if (tz === 2 && dst === 'israel') {
|
|
7720
7760
|
return 'Asia/Jerusalem';
|
|
7721
7761
|
}
|
|
7722
|
-
else if (dst
|
|
7762
|
+
else if (dst === 'eu') {
|
|
7723
7763
|
switch (tz) {
|
|
7724
|
-
case -2:
|
|
7725
|
-
|
|
7726
|
-
case
|
|
7727
|
-
|
|
7728
|
-
case
|
|
7764
|
+
case -2:
|
|
7765
|
+
return 'Atlantic/Cape_Verde';
|
|
7766
|
+
case -1:
|
|
7767
|
+
return 'Atlantic/Azores';
|
|
7768
|
+
case 0:
|
|
7769
|
+
return 'Europe/London';
|
|
7770
|
+
case 1:
|
|
7771
|
+
return 'Europe/Paris';
|
|
7772
|
+
case 2:
|
|
7773
|
+
return 'Europe/Athens';
|
|
7729
7774
|
}
|
|
7730
7775
|
}
|
|
7731
|
-
else if (dst
|
|
7776
|
+
else if (dst === 'usa') {
|
|
7732
7777
|
return ZIPCODES_TZ_MAP[String(tz * -1)];
|
|
7733
7778
|
}
|
|
7734
7779
|
return undefined;
|
|
@@ -7737,17 +7782,16 @@ class Location extends GeoLocation {
|
|
|
7737
7782
|
* Converts timezone info from Zip-Codes.com to a standard Olson tzid.
|
|
7738
7783
|
* @example
|
|
7739
7784
|
* Location.getUsaTzid('AZ', 7, 'Y') // 'America/Denver'
|
|
7740
|
-
* @param
|
|
7741
|
-
* @param
|
|
7742
|
-
* @param
|
|
7743
|
-
* @return {string}
|
|
7785
|
+
* @param state two-letter all-caps US state abbreviation like 'CA'
|
|
7786
|
+
* @param tz positive number, 5=America/New_York, 8=America/Los_Angeles
|
|
7787
|
+
* @param dst single char 'Y' or 'N'
|
|
7744
7788
|
*/
|
|
7745
7789
|
static getUsaTzid(state, tz, dst) {
|
|
7746
|
-
if (tz
|
|
7790
|
+
if (tz === 10 && state === 'AK') {
|
|
7747
7791
|
return 'America/Adak';
|
|
7748
7792
|
}
|
|
7749
|
-
else if (tz
|
|
7750
|
-
return dst
|
|
7793
|
+
else if (tz === 7 && state === 'AZ') {
|
|
7794
|
+
return dst === 'Y' ? 'America/Denver' : 'America/Phoenix';
|
|
7751
7795
|
}
|
|
7752
7796
|
else {
|
|
7753
7797
|
return ZIPCODES_TZ_MAP[tz];
|
|
@@ -7757,9 +7801,6 @@ class Location extends GeoLocation {
|
|
|
7757
7801
|
* Adds a location name for `Location.lookup()` only if the name isn't
|
|
7758
7802
|
* already being used. Returns `false` if the name is already taken
|
|
7759
7803
|
* and `true` if successfully added.
|
|
7760
|
-
* @param {string} cityName
|
|
7761
|
-
* @param {Location} location
|
|
7762
|
-
* @return {boolean}
|
|
7763
7804
|
*/
|
|
7764
7805
|
static addLocation(cityName, location) {
|
|
7765
7806
|
const name = cityName.toLowerCase();
|
|
@@ -7771,7 +7812,7 @@ class Location extends GeoLocation {
|
|
|
7771
7812
|
}
|
|
7772
7813
|
}
|
|
7773
7814
|
for (const city of classicCities0) {
|
|
7774
|
-
const location = new Location(city[2], city[3], city[1]
|
|
7815
|
+
const location = new Location(city[2], city[3], city[1] === 'IL', city[4], city[0], city[1], undefined, city[5]);
|
|
7775
7816
|
Location.addLocation(city[0], location);
|
|
7776
7817
|
}
|
|
7777
7818
|
|
|
@@ -7795,7 +7836,7 @@ function zdtToDate(zdt) {
|
|
|
7795
7836
|
return res;
|
|
7796
7837
|
}
|
|
7797
7838
|
function getDate(date) {
|
|
7798
|
-
if (
|
|
7839
|
+
if (isDate(date))
|
|
7799
7840
|
return date;
|
|
7800
7841
|
if (HDate.isHDate(date))
|
|
7801
7842
|
return date.greg();
|
|
@@ -7830,10 +7871,10 @@ function getDate(date) {
|
|
|
7830
7871
|
class Zmanim {
|
|
7831
7872
|
/**
|
|
7832
7873
|
* Initialize a Zmanim instance.
|
|
7833
|
-
* @param
|
|
7834
|
-
* @param
|
|
7874
|
+
* @param gloc GeoLocation including latitude, longitude, and timezone
|
|
7875
|
+
* @param date Regular or Hebrew Date. If `date` is a regular `Date`,
|
|
7835
7876
|
* hours, minutes, seconds and milliseconds are ignored.
|
|
7836
|
-
* @param
|
|
7877
|
+
* @param useElevation use elevation for calculations (default `false`).
|
|
7837
7878
|
* If `true`, use elevation to affect the calculation of all sunrise/sunset based
|
|
7838
7879
|
* zmanim. Note: there are some zmanim such as degree-based zmanim that are driven
|
|
7839
7880
|
* by the amount of light in the sky and are not impacted by elevation.
|
|
@@ -7846,7 +7887,7 @@ class Zmanim {
|
|
|
7846
7887
|
const plainDate = Temporal.PlainDate.from({
|
|
7847
7888
|
year: dt.getFullYear(),
|
|
7848
7889
|
month: dt.getMonth() + 1,
|
|
7849
|
-
day: dt.getDate()
|
|
7890
|
+
day: dt.getDate(),
|
|
7850
7891
|
});
|
|
7851
7892
|
this.noaa = new NOAACalculator(gloc, plainDate);
|
|
7852
7893
|
this.useElevation = Boolean(useElevation);
|
|
@@ -7854,14 +7895,13 @@ class Zmanim {
|
|
|
7854
7895
|
/**
|
|
7855
7896
|
* Returns `true` if elevation adjustment is enabled
|
|
7856
7897
|
* for zmanim support elevation adjustment
|
|
7857
|
-
* @return {boolean}
|
|
7858
7898
|
*/
|
|
7859
7899
|
getUseElevation() {
|
|
7860
7900
|
return this.useElevation;
|
|
7861
7901
|
}
|
|
7862
7902
|
/**
|
|
7863
7903
|
* Enables or disables elevation adjustment for zmanim support elevation adjustment
|
|
7864
|
-
* @param
|
|
7904
|
+
* @param useElevation
|
|
7865
7905
|
*/
|
|
7866
7906
|
setUseElevation(useElevation) {
|
|
7867
7907
|
this.useElevation = useElevation;
|
|
@@ -7870,29 +7910,29 @@ class Zmanim {
|
|
|
7870
7910
|
* Convenience function to get the time when sun is above or below the horizon
|
|
7871
7911
|
* for a certain angle (in degrees).
|
|
7872
7912
|
* This function does not support elevation adjustment.
|
|
7873
|
-
* @param
|
|
7874
|
-
* @param
|
|
7875
|
-
* @return {Date}
|
|
7913
|
+
* @param angle
|
|
7914
|
+
* @param rising
|
|
7876
7915
|
*/
|
|
7877
7916
|
timeAtAngle(angle, rising) {
|
|
7878
7917
|
const offsetZenith = 90 + angle;
|
|
7879
|
-
const zdt = rising
|
|
7880
|
-
this.noaa.
|
|
7918
|
+
const zdt = rising
|
|
7919
|
+
? this.noaa.getSunriseOffsetByDegrees(offsetZenith)
|
|
7920
|
+
: this.noaa.getSunsetOffsetByDegrees(offsetZenith);
|
|
7881
7921
|
return zdtToDate(zdt);
|
|
7882
7922
|
}
|
|
7883
7923
|
/**
|
|
7884
7924
|
* Upper edge of the Sun appears over the eastern horizon in the morning (0.833° above horizon)
|
|
7885
7925
|
* If elevation is enabled, this function will include elevation in the calculation.
|
|
7886
|
-
* @return {Date}
|
|
7887
7926
|
*/
|
|
7888
7927
|
sunrise() {
|
|
7889
|
-
const zdt = this.useElevation
|
|
7928
|
+
const zdt = this.useElevation
|
|
7929
|
+
? this.noaa.getSunrise()
|
|
7930
|
+
: this.noaa.getSeaLevelSunrise();
|
|
7890
7931
|
return zdtToDate(zdt);
|
|
7891
7932
|
}
|
|
7892
7933
|
/**
|
|
7893
7934
|
* Upper edge of the Sun appears over the eastern horizon in the morning (0.833° above horizon).
|
|
7894
7935
|
* This function does not support elevation adjustment.
|
|
7895
|
-
* @return {Date}
|
|
7896
7936
|
*/
|
|
7897
7937
|
seaLevelSunrise() {
|
|
7898
7938
|
const zdt = this.noaa.getSeaLevelSunrise();
|
|
@@ -7901,16 +7941,16 @@ class Zmanim {
|
|
|
7901
7941
|
/**
|
|
7902
7942
|
* When the upper edge of the Sun disappears below the horizon (0.833° below horizon).
|
|
7903
7943
|
* If elevation is enabled, this function will include elevation in the calculation.
|
|
7904
|
-
* @return {Date}
|
|
7905
7944
|
*/
|
|
7906
7945
|
sunset() {
|
|
7907
|
-
const zdt = this.useElevation
|
|
7946
|
+
const zdt = this.useElevation
|
|
7947
|
+
? this.noaa.getSunset()
|
|
7948
|
+
: this.noaa.getSeaLevelSunset();
|
|
7908
7949
|
return zdtToDate(zdt);
|
|
7909
7950
|
}
|
|
7910
7951
|
/**
|
|
7911
7952
|
* When the upper edge of the Sun disappears below the horizon (0.833° below horizon).
|
|
7912
7953
|
* This function does not support elevation adjustment.
|
|
7913
|
-
* @return {Date}
|
|
7914
7954
|
*/
|
|
7915
7955
|
seaLevelSunset() {
|
|
7916
7956
|
const zdt = this.noaa.getSeaLevelSunset();
|
|
@@ -7920,7 +7960,6 @@ class Zmanim {
|
|
|
7920
7960
|
* Civil dawn; Sun is 6° below the horizon in the morning.
|
|
7921
7961
|
* Because degree-based functions estimate the amount of light in the sky,
|
|
7922
7962
|
* the result is not impacted by elevation.
|
|
7923
|
-
* @return {Date}
|
|
7924
7963
|
*/
|
|
7925
7964
|
dawn() {
|
|
7926
7965
|
const zdt = this.noaa.getBeginCivilTwilight();
|
|
@@ -7930,7 +7969,6 @@ class Zmanim {
|
|
|
7930
7969
|
* Civil dusk; Sun is 6° below the horizon in the evening.
|
|
7931
7970
|
* Because degree-based functions estimate the amount of light in the sky,
|
|
7932
7971
|
* the result is not impacted by elevation.
|
|
7933
|
-
* @return {Date}
|
|
7934
7972
|
*/
|
|
7935
7973
|
dusk() {
|
|
7936
7974
|
const zdt = this.noaa.getEndCivilTwilight();
|
|
@@ -7939,7 +7977,6 @@ class Zmanim {
|
|
|
7939
7977
|
/**
|
|
7940
7978
|
* Returns sunset for the previous day.
|
|
7941
7979
|
* If elevation is enabled, this function will include elevation in the calculation.
|
|
7942
|
-
* @return {Date}
|
|
7943
7980
|
*/
|
|
7944
7981
|
gregEve() {
|
|
7945
7982
|
const prev = new Date(this.date);
|
|
@@ -7949,14 +7986,12 @@ class Zmanim {
|
|
|
7949
7986
|
}
|
|
7950
7987
|
/**
|
|
7951
7988
|
* @private
|
|
7952
|
-
* @return {number}
|
|
7953
7989
|
*/
|
|
7954
7990
|
nightHour() {
|
|
7955
7991
|
return (this.sunrise().getTime() - this.gregEve().getTime()) / 12; // ms in hour
|
|
7956
7992
|
}
|
|
7957
7993
|
/**
|
|
7958
7994
|
* Midday – Chatzot; Sunrise plus 6 halachic hours
|
|
7959
|
-
* @return {Date}
|
|
7960
7995
|
*/
|
|
7961
7996
|
chatzot() {
|
|
7962
7997
|
const startOfDay = this.noaa.getSeaLevelSunrise();
|
|
@@ -7967,16 +8002,14 @@ class Zmanim {
|
|
|
7967
8002
|
/**
|
|
7968
8003
|
* Midnight – Chatzot; Sunset plus 6 halachic hours.
|
|
7969
8004
|
* If elevation is enabled, this function will include elevation in the calculation.
|
|
7970
|
-
* @return {Date}
|
|
7971
8005
|
*/
|
|
7972
8006
|
chatzotNight() {
|
|
7973
|
-
return new Date(this.sunrise().getTime() -
|
|
8007
|
+
return new Date(this.sunrise().getTime() - this.nightHour() * 6);
|
|
7974
8008
|
}
|
|
7975
8009
|
/**
|
|
7976
8010
|
* Dawn – Alot haShachar; Sun is 16.1° below the horizon in the morning.
|
|
7977
8011
|
* Because degree-based functions estimate the amount of light in the sky,
|
|
7978
8012
|
* the result is not impacted by elevation.
|
|
7979
|
-
* @return {Date}
|
|
7980
8013
|
*/
|
|
7981
8014
|
alotHaShachar() {
|
|
7982
8015
|
return this.timeAtAngle(16.1, true);
|
|
@@ -7985,7 +8018,6 @@ class Zmanim {
|
|
|
7985
8018
|
* Earliest talis & tefillin – Misheyakir; Sun is 11.5° below the horizon in the morning.
|
|
7986
8019
|
* Because degree-based functions estimate the amount of light in the sky,
|
|
7987
8020
|
* the result is not impacted by elevation.
|
|
7988
|
-
* @return {Date}
|
|
7989
8021
|
*/
|
|
7990
8022
|
misheyakir() {
|
|
7991
8023
|
return this.timeAtAngle(11.5, true);
|
|
@@ -7994,7 +8026,6 @@ class Zmanim {
|
|
|
7994
8026
|
* Earliest talis & tefillin – Misheyakir Machmir; Sun is 10.2° below the horizon in the morning.
|
|
7995
8027
|
* Because degree-based functions estimate the amount of light in the sky,
|
|
7996
8028
|
* the result is not impacted by elevation.
|
|
7997
|
-
* @return {Date}
|
|
7998
8029
|
*/
|
|
7999
8030
|
misheyakirMachmir() {
|
|
8000
8031
|
return this.timeAtAngle(10.2, true);
|
|
@@ -8002,12 +8033,15 @@ class Zmanim {
|
|
|
8002
8033
|
/**
|
|
8003
8034
|
* Utility method for using elevation-aware sunrise/sunset
|
|
8004
8035
|
* @private
|
|
8005
|
-
* @param
|
|
8006
|
-
* @return {Date}
|
|
8036
|
+
* @param hours
|
|
8007
8037
|
*/
|
|
8008
8038
|
getShaahZmanisBasedZman(hours) {
|
|
8009
|
-
const startOfDay = this.useElevation
|
|
8010
|
-
|
|
8039
|
+
const startOfDay = this.useElevation
|
|
8040
|
+
? this.noaa.getSunrise()
|
|
8041
|
+
: this.noaa.getSeaLevelSunrise();
|
|
8042
|
+
const endOfDay = this.useElevation
|
|
8043
|
+
? this.noaa.getSunset()
|
|
8044
|
+
: this.noaa.getSeaLevelSunset();
|
|
8011
8045
|
const temporalHour = this.noaa.getTemporalHour(startOfDay, endOfDay);
|
|
8012
8046
|
const offset = Math.round(temporalHour * hours);
|
|
8013
8047
|
const zdt = NOAACalculator.getTimeOffset(startOfDay, offset);
|
|
@@ -8016,9 +8050,9 @@ class Zmanim {
|
|
|
8016
8050
|
/**
|
|
8017
8051
|
* Latest Shema (Gra); Sunrise plus 3 halachic hours, according to the Gra.
|
|
8018
8052
|
* If elevation is enabled, this function will include elevation in the calculation.
|
|
8019
|
-
* @return {Date}
|
|
8020
8053
|
*/
|
|
8021
8054
|
sofZmanShma() {
|
|
8055
|
+
// Gra
|
|
8022
8056
|
return this.getShaahZmanisBasedZman(3);
|
|
8023
8057
|
}
|
|
8024
8058
|
/**
|
|
@@ -8030,9 +8064,9 @@ class Zmanim {
|
|
|
8030
8064
|
* to the [GRA](https://en.wikipedia.org/wiki/Vilna_Gaon).
|
|
8031
8065
|
*
|
|
8032
8066
|
* If elevation is enabled, this function will include elevation in the calculation.
|
|
8033
|
-
* @return {Date}
|
|
8034
8067
|
*/
|
|
8035
8068
|
sofZmanTfilla() {
|
|
8069
|
+
// Gra
|
|
8036
8070
|
return this.getShaahZmanisBasedZman(4);
|
|
8037
8071
|
}
|
|
8038
8072
|
/**
|
|
@@ -8060,9 +8094,9 @@ class Zmanim {
|
|
|
8060
8094
|
* Based on the opinion of the MGA that the day is calculated from
|
|
8061
8095
|
* dawn being fixed 72 minutes before sea-level sunrise, and nightfall is fixed
|
|
8062
8096
|
* 72 minutes after sea-level sunset.
|
|
8063
|
-
* @return {Date}
|
|
8064
8097
|
*/
|
|
8065
8098
|
sofZmanShmaMGA() {
|
|
8099
|
+
// Magen Avraham
|
|
8066
8100
|
const [alot72, temporalHour] = this.getTemporalHour72(true);
|
|
8067
8101
|
const offset = Math.floor(3 * temporalHour);
|
|
8068
8102
|
return new Date(alot72.getTime() + offset);
|
|
@@ -8071,7 +8105,6 @@ class Zmanim {
|
|
|
8071
8105
|
* Latest Shema (MGA); Sunrise plus 3 halachic hours, according to Magen Avraham.
|
|
8072
8106
|
* Based on the opinion of the MGA that the day is calculated from
|
|
8073
8107
|
* dawn to nightfall with both being 16.1° below the horizon.
|
|
8074
|
-
* @return {Date}
|
|
8075
8108
|
*/
|
|
8076
8109
|
sofZmanShmaMGA16Point1() {
|
|
8077
8110
|
const [alot, temporalHour] = this.getTemporalHourByDeg(16.1);
|
|
@@ -8086,7 +8119,6 @@ class Zmanim {
|
|
|
8086
8119
|
* This calculation is based on the position of the sun 90 minutes after sunset in Jerusalem
|
|
8087
8120
|
* around the equinox / equilux which calculates to 19.8° below geometric zenith.
|
|
8088
8121
|
* https://kosherjava.com/2022/01/12/equinox-vs-equilux-zmanim-calculations/
|
|
8089
|
-
* @return {Date}
|
|
8090
8122
|
*/
|
|
8091
8123
|
sofZmanShmaMGA19Point8() {
|
|
8092
8124
|
const [alot, temporalHour] = this.getTemporalHourByDeg(19.8);
|
|
@@ -8095,9 +8127,9 @@ class Zmanim {
|
|
|
8095
8127
|
}
|
|
8096
8128
|
/**
|
|
8097
8129
|
* Latest Shacharit (MGA); Sunrise plus 4 halachic hours, according to Magen Avraham
|
|
8098
|
-
* @return {Date}
|
|
8099
8130
|
*/
|
|
8100
8131
|
sofZmanTfillaMGA() {
|
|
8132
|
+
// Magen Avraham
|
|
8101
8133
|
const [alot72, temporalHour] = this.getTemporalHour72(true);
|
|
8102
8134
|
const offset = Math.floor(4 * temporalHour);
|
|
8103
8135
|
return new Date(alot72.getTime() + offset);
|
|
@@ -8106,7 +8138,6 @@ class Zmanim {
|
|
|
8106
8138
|
* Latest Shacharit (MGA); Sunrise plus 4 halachic hours, according to Magen Avraham.
|
|
8107
8139
|
* Based on the opinion of the MGA that the day is calculated from
|
|
8108
8140
|
* dawn to nightfall with both being 16.1° below the horizon.
|
|
8109
|
-
* @return {Date}
|
|
8110
8141
|
*/
|
|
8111
8142
|
sofZmanTfillaMGA16Point1() {
|
|
8112
8143
|
const [alot, temporalHour] = this.getTemporalHourByDeg(16.1);
|
|
@@ -8121,7 +8152,6 @@ class Zmanim {
|
|
|
8121
8152
|
* This calculation is based on the position of the sun 90 minutes after sunset in Jerusalem
|
|
8122
8153
|
* around the equinox / equilux which calculates to 19.8° below geometric zenith.
|
|
8123
8154
|
* https://kosherjava.com/2022/01/12/equinox-vs-equilux-zmanim-calculations/
|
|
8124
|
-
* @return {Date}
|
|
8125
8155
|
*/
|
|
8126
8156
|
sofZmanTfillaMGA19Point8() {
|
|
8127
8157
|
const [alot, temporalHour] = this.getTemporalHourByDeg(19.8);
|
|
@@ -8140,7 +8170,6 @@ class Zmanim {
|
|
|
8140
8170
|
* The Ramba"m is of the opinion that it is better to delay *mincha* until
|
|
8141
8171
|
* *mincha ketana* while the Ra"sh, Tur, GRA and others are of the
|
|
8142
8172
|
* opinion that *mincha* can be prayed *lechatchila* starting at *mincha gedola*.
|
|
8143
|
-
* @return {Date}
|
|
8144
8173
|
*/
|
|
8145
8174
|
minchaGedola() {
|
|
8146
8175
|
return this.getShaahZmanisBasedZman(6.5);
|
|
@@ -8152,7 +8181,6 @@ class Zmanim {
|
|
|
8152
8181
|
* This method returns the time of *mincha gedola* according to the Magen Avraham
|
|
8153
8182
|
* with the day starting 72 minutes before sunrise and ending 72 minutes after sunset.
|
|
8154
8183
|
* This is the earliest time to pray *mincha*.
|
|
8155
|
-
* @return {Date}
|
|
8156
8184
|
*/
|
|
8157
8185
|
minchaGedolaMGA() {
|
|
8158
8186
|
const [alot72, temporalHour] = this.getTemporalHour72(false);
|
|
@@ -8168,7 +8196,6 @@ class Zmanim {
|
|
|
8168
8196
|
* that is 9.5 *shaos zmaniyos* (solar hours) after sunrise or sea level sunrise
|
|
8169
8197
|
* (depending on the `useElevation` setting), according
|
|
8170
8198
|
* to the [GRA](https://en.wikipedia.org/wiki/Vilna_Gaon).
|
|
8171
|
-
* @return {Date}
|
|
8172
8199
|
*/
|
|
8173
8200
|
minchaKetana() {
|
|
8174
8201
|
return this.getShaahZmanisBasedZman(9.5);
|
|
@@ -8180,7 +8207,6 @@ class Zmanim {
|
|
|
8180
8207
|
* the [Rambam](https://en.wikipedia.org/wiki/Maimonides) and others.
|
|
8181
8208
|
*
|
|
8182
8209
|
* If elevation is enabled, this function will include elevation in the calculation.
|
|
8183
|
-
* @return {Date}
|
|
8184
8210
|
*/
|
|
8185
8211
|
minchaKetanaMGA() {
|
|
8186
8212
|
const [alot72, temporalHour] = this.getTemporalHour72(false);
|
|
@@ -8189,31 +8215,27 @@ class Zmanim {
|
|
|
8189
8215
|
/**
|
|
8190
8216
|
* Plag haMincha; Sunrise plus 10.75 halachic hours.
|
|
8191
8217
|
* If elevation is enabled, this function will include elevation in the calculation.
|
|
8192
|
-
* @return {Date}
|
|
8193
8218
|
*/
|
|
8194
8219
|
plagHaMincha() {
|
|
8195
8220
|
return this.getShaahZmanisBasedZman(10.75);
|
|
8196
8221
|
}
|
|
8197
8222
|
/**
|
|
8198
|
-
* @param
|
|
8223
|
+
* @param [angle=8.5] optional time for solar depression.
|
|
8199
8224
|
* Default is 8.5 degrees for 3 small stars, use 7.083 degrees for 3 medium-sized stars.
|
|
8200
8225
|
* Because degree-based functions estimate the amount of light in the sky,
|
|
8201
8226
|
* the result is not impacted by elevation.
|
|
8202
|
-
* @return {Date}
|
|
8203
8227
|
*/
|
|
8204
8228
|
tzeit(angle = 8.5) {
|
|
8205
8229
|
return this.timeAtAngle(angle, false);
|
|
8206
8230
|
}
|
|
8207
8231
|
/**
|
|
8208
8232
|
* Alias for sunrise
|
|
8209
|
-
* @return {Date}
|
|
8210
8233
|
*/
|
|
8211
8234
|
neitzHaChama() {
|
|
8212
8235
|
return this.sunrise();
|
|
8213
8236
|
}
|
|
8214
8237
|
/**
|
|
8215
8238
|
* Alias for sunset
|
|
8216
|
-
* @return {Date}
|
|
8217
8239
|
*/
|
|
8218
8240
|
shkiah() {
|
|
8219
8241
|
return this.sunset();
|
|
@@ -8225,7 +8247,6 @@ class Zmanim {
|
|
|
8225
8247
|
* it is 13.5 minutes before tzies 7.083.
|
|
8226
8248
|
* Because degree-based functions estimate the amount of light in the sky,
|
|
8227
8249
|
* the result is not impacted by elevation.
|
|
8228
|
-
* @return {Date}
|
|
8229
8250
|
*/
|
|
8230
8251
|
beinHaShmashos() {
|
|
8231
8252
|
const tzeit = this.tzeit(7.083);
|
|
@@ -8233,13 +8254,10 @@ class Zmanim {
|
|
|
8233
8254
|
if (isNaN(millis)) {
|
|
8234
8255
|
return tzeit;
|
|
8235
8256
|
}
|
|
8236
|
-
return new Date(millis -
|
|
8257
|
+
return new Date(millis - 13.5 * 60 * 1000);
|
|
8237
8258
|
}
|
|
8238
8259
|
/**
|
|
8239
8260
|
* Uses timeFormat to return a date like '20:34'
|
|
8240
|
-
* @param {Date} dt
|
|
8241
|
-
* @param {Intl.DateTimeFormat} timeFormat
|
|
8242
|
-
* @return {string}
|
|
8243
8261
|
*/
|
|
8244
8262
|
static formatTime(dt, timeFormat) {
|
|
8245
8263
|
const time = timeFormat.format(dt);
|
|
@@ -8251,8 +8269,7 @@ class Zmanim {
|
|
|
8251
8269
|
}
|
|
8252
8270
|
/**
|
|
8253
8271
|
* Discards seconds, rounding to nearest minute.
|
|
8254
|
-
* @param
|
|
8255
|
-
* @return {Date}
|
|
8272
|
+
* @param dt
|
|
8256
8273
|
*/
|
|
8257
8274
|
static roundTime(dt) {
|
|
8258
8275
|
const millis = dt.getTime();
|
|
@@ -8265,15 +8282,14 @@ class Zmanim {
|
|
|
8265
8282
|
if (seconds === 0 && millisOnly === 0) {
|
|
8266
8283
|
return dt;
|
|
8267
8284
|
}
|
|
8268
|
-
const secAndMillis =
|
|
8269
|
-
const delta =
|
|
8285
|
+
const secAndMillis = seconds * 1000 + millisOnly;
|
|
8286
|
+
const delta = secAndMillis >= 30000 ? 60000 - secAndMillis : -1 * secAndMillis;
|
|
8270
8287
|
return new Date(millis + delta);
|
|
8271
8288
|
}
|
|
8272
8289
|
/**
|
|
8273
8290
|
* Get offset string (like "+05:00" or "-08:00") from tzid (like "Europe/Moscow")
|
|
8274
|
-
* @param
|
|
8275
|
-
* @param
|
|
8276
|
-
* @return {string}
|
|
8291
|
+
* @param tzid
|
|
8292
|
+
* @param date
|
|
8277
8293
|
*/
|
|
8278
8294
|
static timeZoneOffset(tzid, date) {
|
|
8279
8295
|
const offset = getTimezoneOffset(tzid, date);
|
|
@@ -8284,24 +8300,23 @@ class Zmanim {
|
|
|
8284
8300
|
}
|
|
8285
8301
|
/**
|
|
8286
8302
|
* Returns a string like "2022-04-01T13:06:00-11:00"
|
|
8287
|
-
* @param
|
|
8288
|
-
* @param
|
|
8289
|
-
* @return {string}
|
|
8303
|
+
* @param tzid
|
|
8304
|
+
* @param date
|
|
8290
8305
|
*/
|
|
8291
8306
|
static formatISOWithTimeZone(tzid, date) {
|
|
8292
8307
|
if (isNaN(date.getTime())) {
|
|
8293
8308
|
return '0000-00-00T00:00:00Z';
|
|
8294
8309
|
}
|
|
8295
|
-
return getPseudoISO(tzid, date).substring(0, 19) +
|
|
8310
|
+
return (getPseudoISO(tzid, date).substring(0, 19) +
|
|
8311
|
+
Zmanim.timeZoneOffset(tzid, date));
|
|
8296
8312
|
}
|
|
8297
8313
|
/**
|
|
8298
8314
|
* Returns sunrise + `offset` minutes (either positive or negative).
|
|
8299
8315
|
* If elevation is enabled, this function will include elevation in the calculation
|
|
8300
8316
|
* unless `forceSeaLevel` is `true`.
|
|
8301
|
-
* @param
|
|
8302
|
-
* @param
|
|
8303
|
-
* @param
|
|
8304
|
-
* @return {Date}
|
|
8317
|
+
* @param offset minutes
|
|
8318
|
+
* @param roundMinute round time to nearest minute (default true)
|
|
8319
|
+
* @param forceSeaLevel use sea-level sunrise (default false)
|
|
8305
8320
|
*/
|
|
8306
8321
|
sunriseOffset(offset, roundMinute = true, forceSeaLevel = false) {
|
|
8307
8322
|
const sunrise = forceSeaLevel ? this.seaLevelSunrise() : this.sunrise();
|
|
@@ -8315,16 +8330,15 @@ class Zmanim {
|
|
|
8315
8330
|
}
|
|
8316
8331
|
sunrise.setSeconds(0, 0);
|
|
8317
8332
|
}
|
|
8318
|
-
return new Date(sunrise.getTime() +
|
|
8333
|
+
return new Date(sunrise.getTime() + offset * 60 * 1000);
|
|
8319
8334
|
}
|
|
8320
8335
|
/**
|
|
8321
8336
|
* Returns sunset + `offset` minutes (either positive or negative).
|
|
8322
8337
|
* If elevation is enabled, this function will include elevation in the calculation
|
|
8323
8338
|
* unless `forceSeaLevel` is `true`.
|
|
8324
|
-
* @param
|
|
8325
|
-
* @param
|
|
8326
|
-
* @param
|
|
8327
|
-
* @return {Date}
|
|
8339
|
+
* @param offset minutes
|
|
8340
|
+
* @param roundMinute round time to nearest minute (default true)
|
|
8341
|
+
* @param forceSeaLevel use sea-level sunset (default false)
|
|
8328
8342
|
*/
|
|
8329
8343
|
sunsetOffset(offset, roundMinute = true, forceSeaLevel = false) {
|
|
8330
8344
|
const sunset = forceSeaLevel ? this.seaLevelSunset() : this.sunset();
|
|
@@ -8338,19 +8352,29 @@ class Zmanim {
|
|
|
8338
8352
|
}
|
|
8339
8353
|
sunset.setSeconds(0, 0);
|
|
8340
8354
|
}
|
|
8341
|
-
return new Date(sunset.getTime() +
|
|
8355
|
+
return new Date(sunset.getTime() + offset * 60 * 1000);
|
|
8342
8356
|
}
|
|
8343
8357
|
}
|
|
8344
8358
|
|
|
8345
8359
|
const hour12cc = {
|
|
8346
|
-
US: 1,
|
|
8360
|
+
US: 1,
|
|
8361
|
+
CA: 1,
|
|
8362
|
+
BR: 1,
|
|
8363
|
+
AU: 1,
|
|
8364
|
+
NZ: 1,
|
|
8365
|
+
DO: 1,
|
|
8366
|
+
PR: 1,
|
|
8367
|
+
GR: 1,
|
|
8368
|
+
IN: 1,
|
|
8369
|
+
KR: 1,
|
|
8370
|
+
NP: 1,
|
|
8371
|
+
ZA: 1,
|
|
8347
8372
|
};
|
|
8348
8373
|
/**
|
|
8349
8374
|
* @private
|
|
8350
|
-
* @param
|
|
8351
|
-
* @param
|
|
8352
|
-
* @param
|
|
8353
|
-
* @return {string}
|
|
8375
|
+
* @param timeStr - original time like "20:30"
|
|
8376
|
+
* @param suffix - "p" or "pm" or " P.M.". Add leading space if you want it
|
|
8377
|
+
* @param options
|
|
8354
8378
|
*/
|
|
8355
8379
|
function reformatTimeStr(timeStr, suffix, options) {
|
|
8356
8380
|
var _a;
|
|
@@ -8384,7 +8408,7 @@ function reformatTimeStr(timeStr, suffix, options) {
|
|
|
8384
8408
|
/** An event that has an `eventTime` and `eventTimeStr` */
|
|
8385
8409
|
class TimedEvent extends Event {
|
|
8386
8410
|
/**
|
|
8387
|
-
* @param
|
|
8411
|
+
* @param desc Description (not translated)
|
|
8388
8412
|
*/
|
|
8389
8413
|
constructor(date, desc, mask, eventTime, location, linkedEvent, options) {
|
|
8390
8414
|
super(date, desc, mask);
|
|
@@ -8399,21 +8423,18 @@ class TimedEvent extends Event {
|
|
|
8399
8423
|
}
|
|
8400
8424
|
}
|
|
8401
8425
|
/**
|
|
8402
|
-
* @param
|
|
8403
|
-
* @return {string}
|
|
8426
|
+
* @param [locale] Optional locale name (defaults to active locale).
|
|
8404
8427
|
*/
|
|
8405
8428
|
render(locale) {
|
|
8406
8429
|
return Locale.gettext(this.getDesc(), locale) + ': ' + this.fmtTime;
|
|
8407
8430
|
}
|
|
8408
8431
|
/**
|
|
8409
8432
|
* Returns translation of "Candle lighting" without the time.
|
|
8410
|
-
* @param
|
|
8411
|
-
* @return {string}
|
|
8433
|
+
* @param [locale] Optional locale name (defaults to active locale).
|
|
8412
8434
|
*/
|
|
8413
8435
|
renderBrief(locale) {
|
|
8414
8436
|
return Locale.gettext(this.getDesc(), locale);
|
|
8415
8437
|
}
|
|
8416
|
-
/** @return {string[]} */
|
|
8417
8438
|
getCategories() {
|
|
8418
8439
|
const desc = this.getDesc();
|
|
8419
8440
|
switch (desc) {
|
|
@@ -8437,7 +8458,6 @@ class CandleLightingEvent extends TimedEvent {
|
|
|
8437
8458
|
constructor(date, mask, eventTime, location, linkedEvent, options) {
|
|
8438
8459
|
super(date, 'Candle lighting', mask, eventTime, location, linkedEvent, options);
|
|
8439
8460
|
}
|
|
8440
|
-
/** @return {string} */
|
|
8441
8461
|
getEmoji() {
|
|
8442
8462
|
return '🕯️';
|
|
8443
8463
|
}
|
|
@@ -8451,16 +8471,14 @@ class HavdalahEvent extends TimedEvent {
|
|
|
8451
8471
|
}
|
|
8452
8472
|
}
|
|
8453
8473
|
/**
|
|
8454
|
-
* @param
|
|
8455
|
-
* @return {string}
|
|
8474
|
+
* @param [locale] Optional locale name (defaults to active locale).
|
|
8456
8475
|
*/
|
|
8457
8476
|
render(locale) {
|
|
8458
8477
|
return this.renderBrief(locale) + ': ' + this.fmtTime;
|
|
8459
8478
|
}
|
|
8460
8479
|
/**
|
|
8461
8480
|
* Returns translation of "Havdalah" without the time.
|
|
8462
|
-
* @param
|
|
8463
|
-
* @return {string}
|
|
8481
|
+
* @param [locale] Optional locale name (defaults to active locale).
|
|
8464
8482
|
*/
|
|
8465
8483
|
renderBrief(locale) {
|
|
8466
8484
|
let str = Locale.gettext(this.getDesc(), locale);
|
|
@@ -8470,7 +8488,6 @@ class HavdalahEvent extends TimedEvent {
|
|
|
8470
8488
|
}
|
|
8471
8489
|
return str;
|
|
8472
8490
|
}
|
|
8473
|
-
/** @return {string} */
|
|
8474
8491
|
getEmoji() {
|
|
8475
8492
|
return '✨';
|
|
8476
8493
|
}
|
|
@@ -8478,7 +8495,15 @@ class HavdalahEvent extends TimedEvent {
|
|
|
8478
8495
|
|
|
8479
8496
|
/* eslint-disable camelcase */
|
|
8480
8497
|
const shortDayNames = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'];
|
|
8481
|
-
const heDayNames = [
|
|
8498
|
+
const heDayNames = [
|
|
8499
|
+
'רִאשׁוֹן',
|
|
8500
|
+
'שֵׁנִי',
|
|
8501
|
+
'שְׁלִישִׁי',
|
|
8502
|
+
'רְבִיעִי',
|
|
8503
|
+
'חֲמִישִׁי',
|
|
8504
|
+
'שִׁישִּׁי',
|
|
8505
|
+
'שַׁבָּת',
|
|
8506
|
+
];
|
|
8482
8507
|
const night = 'בַּלַּ֥יְלָה';
|
|
8483
8508
|
function getHebrewTimeOfDay(hour) {
|
|
8484
8509
|
if (hour < 5)
|
|
@@ -8497,58 +8522,54 @@ function getHebrewTimeOfDay(hour) {
|
|
|
8497
8522
|
class Molad {
|
|
8498
8523
|
/**
|
|
8499
8524
|
* Calculates the molad for a Hebrew month
|
|
8500
|
-
* @param
|
|
8501
|
-
* @param
|
|
8525
|
+
* @param year
|
|
8526
|
+
* @param month
|
|
8502
8527
|
*/
|
|
8503
8528
|
constructor(year, month) {
|
|
8504
8529
|
this.m = molad(year, month);
|
|
8505
8530
|
}
|
|
8506
8531
|
/**
|
|
8507
|
-
* @return {number}
|
|
8508
8532
|
*/
|
|
8509
8533
|
getYear() {
|
|
8510
8534
|
return this.m.year;
|
|
8511
8535
|
}
|
|
8512
8536
|
/**
|
|
8513
|
-
* @return {number}
|
|
8514
8537
|
*/
|
|
8515
8538
|
getMonth() {
|
|
8516
8539
|
return this.m.month;
|
|
8517
8540
|
}
|
|
8518
8541
|
/**
|
|
8519
|
-
* @return {string}
|
|
8520
8542
|
*/
|
|
8521
8543
|
getMonthName() {
|
|
8522
8544
|
return HDate.getMonthName(this.m.month, this.m.year);
|
|
8523
8545
|
}
|
|
8524
8546
|
/**
|
|
8525
|
-
* @
|
|
8547
|
+
* @returns Day of Week (0=Sunday, 6=Saturday)
|
|
8526
8548
|
*/
|
|
8527
8549
|
getDow() {
|
|
8528
8550
|
return this.m.dayOfWeek;
|
|
8529
8551
|
}
|
|
8530
8552
|
/**
|
|
8531
|
-
* @
|
|
8553
|
+
* @returns hour of day (0-23)
|
|
8532
8554
|
*/
|
|
8533
8555
|
getHour() {
|
|
8534
8556
|
return this.m.hour;
|
|
8535
8557
|
}
|
|
8536
8558
|
/**
|
|
8537
|
-
* @
|
|
8559
|
+
* @returns minutes past hour (0-59)
|
|
8538
8560
|
*/
|
|
8539
8561
|
getMinutes() {
|
|
8540
8562
|
return this.m.minutes;
|
|
8541
8563
|
}
|
|
8542
8564
|
/**
|
|
8543
|
-
* @
|
|
8565
|
+
* @returns parts of a minute (0-17)
|
|
8544
8566
|
*/
|
|
8545
8567
|
getChalakim() {
|
|
8546
8568
|
return this.m.chalakim;
|
|
8547
8569
|
}
|
|
8548
8570
|
/**
|
|
8549
|
-
* @param
|
|
8550
|
-
* @param
|
|
8551
|
-
* @return {string}
|
|
8571
|
+
* @param [locale] Optional locale name (defaults to active locale)
|
|
8572
|
+
* @param options
|
|
8552
8573
|
*/
|
|
8553
8574
|
render(locale, options) {
|
|
8554
8575
|
var _a;
|
|
@@ -8585,10 +8606,10 @@ class Molad {
|
|
|
8585
8606
|
/** Represents a Molad announcement on Shabbat Mevarchim */
|
|
8586
8607
|
class MoladEvent extends Event {
|
|
8587
8608
|
/**
|
|
8588
|
-
* @param
|
|
8589
|
-
* @param
|
|
8590
|
-
* @param
|
|
8591
|
-
* @param
|
|
8609
|
+
* @param date Hebrew date event occurs
|
|
8610
|
+
* @param hyear molad year
|
|
8611
|
+
* @param hmonth molad month
|
|
8612
|
+
* @param options
|
|
8592
8613
|
*/
|
|
8593
8614
|
constructor(date, hyear, hmonth, options) {
|
|
8594
8615
|
const m = new Molad(hyear, hmonth);
|
|
@@ -8598,8 +8619,7 @@ class MoladEvent extends Event {
|
|
|
8598
8619
|
this.options = options;
|
|
8599
8620
|
}
|
|
8600
8621
|
/**
|
|
8601
|
-
* @param
|
|
8602
|
-
* @return {string}
|
|
8622
|
+
* @param [locale] Optional locale name (defaults to active locale).
|
|
8603
8623
|
*/
|
|
8604
8624
|
render(locale) {
|
|
8605
8625
|
return this.molad.render(locale, this.options);
|
|
@@ -8609,8 +8629,8 @@ class MoladEvent extends Event {
|
|
|
8609
8629
|
/** Represents a day 1-49 of counting the Omer from Pesach to Shavuot */
|
|
8610
8630
|
class OmerEvent extends Event {
|
|
8611
8631
|
/**
|
|
8612
|
-
* @param
|
|
8613
|
-
* @param
|
|
8632
|
+
* @param date
|
|
8633
|
+
* @param omerDay
|
|
8614
8634
|
*/
|
|
8615
8635
|
constructor(date, omerDay) {
|
|
8616
8636
|
super(date, `Omer ${omerDay}`, flags.OMER_COUNT);
|
|
@@ -8618,12 +8638,11 @@ class OmerEvent extends Event {
|
|
|
8618
8638
|
throw new RangeError(`Invalid Omer day ${omerDay}`);
|
|
8619
8639
|
}
|
|
8620
8640
|
this.weekNumber = Math.floor((omerDay - 1) / 7) + 1;
|
|
8621
|
-
this.daysWithinWeeks =
|
|
8641
|
+
this.daysWithinWeeks = omerDay % 7 || 7;
|
|
8622
8642
|
this.omer = omerDay;
|
|
8623
8643
|
}
|
|
8624
8644
|
/**
|
|
8625
|
-
* @param
|
|
8626
|
-
* @return {string}
|
|
8645
|
+
* @param lang
|
|
8627
8646
|
*/
|
|
8628
8647
|
sefira(lang = 'en') {
|
|
8629
8648
|
if (lang !== 'he' && lang !== 'translit') {
|
|
@@ -8633,8 +8652,7 @@ class OmerEvent extends Event {
|
|
|
8633
8652
|
}
|
|
8634
8653
|
/**
|
|
8635
8654
|
* @todo use gettext()
|
|
8636
|
-
* @param
|
|
8637
|
-
* @return {string}
|
|
8655
|
+
* @param [locale] Optional locale name (defaults to active locale).
|
|
8638
8656
|
*/
|
|
8639
8657
|
render(locale) {
|
|
8640
8658
|
locale = locale !== null && locale !== void 0 ? locale : Locale.getLocaleName();
|
|
@@ -8648,30 +8666,29 @@ class OmerEvent extends Event {
|
|
|
8648
8666
|
}
|
|
8649
8667
|
/**
|
|
8650
8668
|
* Returns translation of "Omer day 22" without ordinal numbers.
|
|
8651
|
-
* @param
|
|
8652
|
-
* @return {string}
|
|
8669
|
+
* @param [locale] Optional locale name (defaults to active locale).
|
|
8653
8670
|
*/
|
|
8654
8671
|
renderBrief(locale) {
|
|
8655
|
-
return Locale.gettext('Omer', locale) +
|
|
8672
|
+
return (Locale.gettext('Omer', locale) +
|
|
8673
|
+
' ' +
|
|
8674
|
+
Locale.gettext('day', locale) +
|
|
8675
|
+
' ' +
|
|
8676
|
+
this.omer);
|
|
8656
8677
|
}
|
|
8657
|
-
/** @return {string} */
|
|
8658
8678
|
getEmoji() {
|
|
8659
8679
|
if (typeof this.emoji === 'string')
|
|
8660
8680
|
return this.emoji;
|
|
8661
8681
|
return omerEmoji(this.omer);
|
|
8662
8682
|
}
|
|
8663
|
-
/** @return {number} */
|
|
8664
8683
|
getWeeks() {
|
|
8665
8684
|
const day7 = this.daysWithinWeeks === 7;
|
|
8666
8685
|
return day7 ? this.weekNumber : this.weekNumber - 1;
|
|
8667
8686
|
}
|
|
8668
|
-
/** @return {number} */
|
|
8669
8687
|
getDaysWithinWeeks() {
|
|
8670
8688
|
return this.daysWithinWeeks;
|
|
8671
8689
|
}
|
|
8672
8690
|
/**
|
|
8673
|
-
* @param
|
|
8674
|
-
* @return {string}
|
|
8691
|
+
* @param locale
|
|
8675
8692
|
*/
|
|
8676
8693
|
getTodayIs(locale) {
|
|
8677
8694
|
locale = locale !== null && locale !== void 0 ? locale : Locale.getLocaleName();
|
|
@@ -8685,7 +8702,6 @@ class OmerEvent extends Event {
|
|
|
8685
8702
|
}
|
|
8686
8703
|
return str;
|
|
8687
8704
|
}
|
|
8688
|
-
/** @return {string} */
|
|
8689
8705
|
url() {
|
|
8690
8706
|
return `https://www.hebcal.com/omer/${this.getDate().getFullYear()}/${this.omer}`;
|
|
8691
8707
|
}
|
|
@@ -9028,8 +9044,8 @@ function yearType(hyear) {
|
|
|
9028
9044
|
class Sedra {
|
|
9029
9045
|
/**
|
|
9030
9046
|
* Caculates the Parashah HaShavua for an entire Hebrew year
|
|
9031
|
-
* @param
|
|
9032
|
-
* @param
|
|
9047
|
+
* @param hyear - Hebrew year (e.g. 5749)
|
|
9048
|
+
* @param il - Use Israel sedra schedule (false for Diaspora)
|
|
9033
9049
|
*/
|
|
9034
9050
|
constructor(hyear, il) {
|
|
9035
9051
|
hyear = +hyear;
|
|
@@ -9047,7 +9063,7 @@ class Sedra {
|
|
|
9047
9063
|
this.theSedraArray = types[key];
|
|
9048
9064
|
}
|
|
9049
9065
|
else {
|
|
9050
|
-
key = key +
|
|
9066
|
+
key = key + +this.il; // cast to num, then concat
|
|
9051
9067
|
this.theSedraArray = types[key];
|
|
9052
9068
|
}
|
|
9053
9069
|
if (!this.theSedraArray) {
|
|
@@ -9056,24 +9072,22 @@ class Sedra {
|
|
|
9056
9072
|
}
|
|
9057
9073
|
/**
|
|
9058
9074
|
* Returns the parsha (or parshiyot) read on Hebrew date
|
|
9059
|
-
* @param
|
|
9060
|
-
* @return {string[]}
|
|
9075
|
+
* @param hd Hebrew date or R.D. days
|
|
9061
9076
|
*/
|
|
9062
9077
|
get(hd) {
|
|
9063
9078
|
return this.lookup(hd).parsha;
|
|
9064
9079
|
}
|
|
9065
9080
|
/**
|
|
9066
9081
|
* Looks up parsha for the date, then returns a translated or transliterated string
|
|
9067
|
-
* @param
|
|
9068
|
-
* @param
|
|
9069
|
-
* @return {string}
|
|
9082
|
+
* @param hd Hebrew date or R.D. days
|
|
9083
|
+
* @param [locale] Optional locale name (i.e: `'he'`, `'fr'`). Defaults to active locale
|
|
9070
9084
|
*/
|
|
9071
9085
|
getString(hd, locale) {
|
|
9072
9086
|
const parsha = this.get(hd);
|
|
9073
9087
|
const locale0 = locale || Locale.getLocaleName();
|
|
9074
9088
|
let name = Locale.gettext(parsha[0], locale0);
|
|
9075
|
-
if (parsha.length
|
|
9076
|
-
const hyphen = locale0
|
|
9089
|
+
if (parsha.length === 2) {
|
|
9090
|
+
const hyphen = locale0 === 'he' ? '־' : '-';
|
|
9077
9091
|
name += hyphen + Locale.gettext(parsha[1], locale0);
|
|
9078
9092
|
}
|
|
9079
9093
|
name = name.replace(/'/g, '’');
|
|
@@ -9082,8 +9096,7 @@ class Sedra {
|
|
|
9082
9096
|
/**
|
|
9083
9097
|
* Checks to see if this day would be a regular parasha HaShavua
|
|
9084
9098
|
* Torah reading or special holiday reading
|
|
9085
|
-
* @param
|
|
9086
|
-
* @return {boolean}
|
|
9099
|
+
* @param hd Hebrew date or R.D. days
|
|
9087
9100
|
*/
|
|
9088
9101
|
isParsha(hd) {
|
|
9089
9102
|
return !this.lookup(hd).chag;
|
|
@@ -9091,19 +9104,17 @@ class Sedra {
|
|
|
9091
9104
|
/**
|
|
9092
9105
|
* Returns the date that a parsha occurs
|
|
9093
9106
|
* or `null` if the parsha doesn't occur this year
|
|
9094
|
-
* @param {number|string|string[]} parsha
|
|
9095
|
-
* @return {HDate|null}
|
|
9096
9107
|
*/
|
|
9097
9108
|
find(parsha) {
|
|
9098
9109
|
if (typeof parsha === 'number') {
|
|
9099
|
-
if (parsha
|
|
9110
|
+
if (parsha >= parshiot.length || (parsha < 0 && !isValidDouble(parsha))) {
|
|
9100
9111
|
throw new RangeError(`Invalid parsha number: ${parsha}`);
|
|
9101
9112
|
}
|
|
9102
9113
|
const idx = this.theSedraArray.indexOf(parsha);
|
|
9103
9114
|
if (idx === -1) {
|
|
9104
9115
|
return null; // doesn't occur this year
|
|
9105
9116
|
}
|
|
9106
|
-
return new HDate(this.firstSaturday +
|
|
9117
|
+
return new HDate(this.firstSaturday + idx * 7);
|
|
9107
9118
|
}
|
|
9108
9119
|
else if (typeof parsha === 'string') {
|
|
9109
9120
|
const num = parsha2id.get(parsha);
|
|
@@ -9119,57 +9130,53 @@ class Sedra {
|
|
|
9119
9130
|
if (idx === -1) {
|
|
9120
9131
|
return null; // doesn't occur this year
|
|
9121
9132
|
}
|
|
9122
|
-
return new HDate(this.firstSaturday +
|
|
9133
|
+
return new HDate(this.firstSaturday + idx * 7);
|
|
9123
9134
|
}
|
|
9124
9135
|
}
|
|
9125
|
-
else if (Array.isArray(parsha)
|
|
9126
|
-
|
|
9127
|
-
|
|
9128
|
-
|
|
9129
|
-
|
|
9130
|
-
|
|
9136
|
+
else if (Array.isArray(parsha)) {
|
|
9137
|
+
const plen = parsha.length;
|
|
9138
|
+
if ((plen !== 1 && plen !== 2) || typeof parsha[0] !== 'string') {
|
|
9139
|
+
throw new TypeError(`Invalid parsha argument: ${JSON.stringify(parsha)}`);
|
|
9140
|
+
}
|
|
9141
|
+
if (plen === 1) {
|
|
9142
|
+
return this.find(parsha[0]);
|
|
9143
|
+
}
|
|
9131
9144
|
const p1 = parsha[0];
|
|
9132
9145
|
const p2 = parsha[1];
|
|
9133
9146
|
const num1 = parsha2id.get(p1);
|
|
9134
9147
|
const num2 = parsha2id.get(p2);
|
|
9135
|
-
if (
|
|
9136
|
-
|
|
9137
|
-
|
|
9138
|
-
|
|
9148
|
+
if (typeof num1 !== 'number' ||
|
|
9149
|
+
typeof num2 !== 'number' ||
|
|
9150
|
+
num2 !== num1 + 1 ||
|
|
9151
|
+
!isValidDouble(-num1)) {
|
|
9139
9152
|
throw new RangeError(`Unrecognized parsha name: ${p1}-${p2}`);
|
|
9140
9153
|
}
|
|
9154
|
+
return this.find(-num1);
|
|
9141
9155
|
}
|
|
9142
|
-
|
|
9143
|
-
throw new TypeError(`Invalid parsha argument: ${parsha}`);
|
|
9144
|
-
}
|
|
9156
|
+
return null; /* NOTREACHED */
|
|
9145
9157
|
}
|
|
9146
9158
|
/**
|
|
9147
9159
|
* Returns the underlying annual sedra schedule.
|
|
9148
9160
|
* Used by `@hebcal/triennial`
|
|
9149
|
-
* @return {NumberOrString[]}
|
|
9150
9161
|
*/
|
|
9151
9162
|
getSedraArray() {
|
|
9152
9163
|
return this.theSedraArray;
|
|
9153
9164
|
}
|
|
9154
9165
|
/**
|
|
9155
9166
|
* R.D. date of the first Saturday on or after Rosh Hashana
|
|
9156
|
-
* @return {number}
|
|
9157
9167
|
*/
|
|
9158
9168
|
getFirstSaturday() {
|
|
9159
9169
|
return this.firstSaturday;
|
|
9160
9170
|
}
|
|
9161
|
-
/** @return {number} */
|
|
9162
9171
|
getYear() {
|
|
9163
9172
|
return this.year;
|
|
9164
9173
|
}
|
|
9165
9174
|
/**
|
|
9166
9175
|
* Returns an object describing the parsha on the first Saturday on or after `hd`
|
|
9167
|
-
* @param
|
|
9168
|
-
* @return {SedraResult}
|
|
9176
|
+
* @param hd Hebrew date or R.D. days
|
|
9169
9177
|
*/
|
|
9170
9178
|
lookup(hd) {
|
|
9171
|
-
const abs =
|
|
9172
|
-
HDate.isHDate(hd) ? hd.abs() : NaN;
|
|
9179
|
+
const abs = typeof hd === 'number' ? hd : HDate.isHDate(hd) ? hd.abs() : NaN;
|
|
9173
9180
|
if (isNaN(abs)) {
|
|
9174
9181
|
throw new TypeError(`Bad date argument: ${hd}`);
|
|
9175
9182
|
}
|
|
@@ -9238,8 +9245,8 @@ const parshiot = [
|
|
|
9238
9245
|
'Bechukotai',
|
|
9239
9246
|
'Bamidbar',
|
|
9240
9247
|
'Nasso',
|
|
9241
|
-
|
|
9242
|
-
|
|
9248
|
+
"Beha'alotcha",
|
|
9249
|
+
"Sh'lach",
|
|
9243
9250
|
'Korach',
|
|
9244
9251
|
'Chukat',
|
|
9245
9252
|
'Balak',
|
|
@@ -9249,13 +9256,13 @@ const parshiot = [
|
|
|
9249
9256
|
'Devarim',
|
|
9250
9257
|
'Vaetchanan',
|
|
9251
9258
|
'Eikev',
|
|
9252
|
-
|
|
9259
|
+
"Re'eh",
|
|
9253
9260
|
'Shoftim',
|
|
9254
9261
|
'Ki Teitzei',
|
|
9255
9262
|
'Ki Tavo',
|
|
9256
9263
|
'Nitzavim',
|
|
9257
9264
|
'Vayeilech',
|
|
9258
|
-
|
|
9265
|
+
"Ha'azinu",
|
|
9259
9266
|
];
|
|
9260
9267
|
const parsha2id = new Map();
|
|
9261
9268
|
for (let id = 0; id < parshiot.length; id++) {
|
|
@@ -9264,8 +9271,7 @@ for (let id = 0; id < parshiot.length; id++) {
|
|
|
9264
9271
|
}
|
|
9265
9272
|
/**
|
|
9266
9273
|
* @private
|
|
9267
|
-
* @param
|
|
9268
|
-
* @return {boolean}
|
|
9274
|
+
* @param id
|
|
9269
9275
|
*/
|
|
9270
9276
|
function isValidDouble(id) {
|
|
9271
9277
|
switch (id) {
|
|
@@ -9283,8 +9289,7 @@ function isValidDouble(id) {
|
|
|
9283
9289
|
/**
|
|
9284
9290
|
* parsha doubler/undoubler
|
|
9285
9291
|
* @private
|
|
9286
|
-
* @param
|
|
9287
|
-
* @return {number}
|
|
9292
|
+
* @param p
|
|
9288
9293
|
*/
|
|
9289
9294
|
function D(p) {
|
|
9290
9295
|
return -p;
|
|
@@ -9303,9 +9308,8 @@ const SHAVUOT$1 = 'Shavuot'; // 33
|
|
|
9303
9308
|
/**
|
|
9304
9309
|
* Returns an array from start to end
|
|
9305
9310
|
* @private
|
|
9306
|
-
* @param
|
|
9307
|
-
* @param
|
|
9308
|
-
* @return {number[]}
|
|
9311
|
+
* @param start beginning number, inclusive
|
|
9312
|
+
* @param stop ending number, inclusive
|
|
9309
9313
|
*/
|
|
9310
9314
|
function range$1(start, stop) {
|
|
9311
9315
|
return Array.from({ length: stop - start + 1 }, (v, k) => k + start);
|
|
@@ -9326,64 +9330,64 @@ const r4350 = range$1(43, 50);
|
|
|
9326
9330
|
*/
|
|
9327
9331
|
const types = {
|
|
9328
9332
|
/* Hebrew year that starts on Monday, is `incomplete' (Heshvan and
|
|
9329
|
-
|
|
9333
|
+
* Kislev each have 29 days), and has Passover start on Tuesday. */
|
|
9330
9334
|
// e.g. 5753
|
|
9331
9335
|
'020': yearStartVayeilech.concat(r020, D(21), 23, 24, PESACH, 25, D(26), D(28), 30, D(31), r3340, D(41), r4349, D(50)),
|
|
9332
9336
|
/* Hebrew year that starts on Monday, is `complete' (Heshvan and
|
|
9333
|
-
|
|
9337
|
+
* Kislev each have 30 days), and has Passover start on Thursday. */
|
|
9334
9338
|
// e.g. 5756
|
|
9335
9339
|
'0220': yearStartVayeilech.concat(r020, D(21), 23, 24, PESACH, 25, D(26), D(28), 30, D(31), 33, SHAVUOT$1, range$1(34, 37), D(38), 40, D(41), r4349, D(50)),
|
|
9336
9340
|
/* Hebrew year that starts on Thursday, is `regular' (Heshvan has 29
|
|
9337
|
-
|
|
9341
|
+
* days and Kislev has 30 days), and has Passover start on Saturday. */
|
|
9338
9342
|
// e.g. 5701
|
|
9339
9343
|
'0510': yearStartHaazinu.concat(r020, D(21), 23, 24, PESACH1, PESACH8, 25, D(26), D(28), 30, D(31), r3340, D(41), r4350),
|
|
9340
9344
|
/* Hebrew year that starts on Thursday, is `regular' (Heshvan has 29
|
|
9341
|
-
|
|
9345
|
+
* days and Kislev has 30 days), and has Passover start on Saturday. */
|
|
9342
9346
|
// e.g. 5745
|
|
9343
9347
|
'0511': yearStartHaazinu.concat(r020, D(21), 23, 24, PESACH, 25, D(26), D(28), range$1(30, 40), D(41), r4350),
|
|
9344
9348
|
/* Hebrew year that starts on Thursday, is `complete' (Heshvan and
|
|
9345
|
-
|
|
9349
|
+
* Kislev each have 30 days), and has Passover start on Sunday. */
|
|
9346
9350
|
// e.g. 5754
|
|
9347
9351
|
'052': yearStartHaazinu.concat(range$1(0, 24), PESACH7, 25, D(26), D(28), 30, D(31), r3340, D(41), r4350),
|
|
9348
9352
|
/* Hebrew year that starts on Saturday, is `incomplete' (Heshvan and Kislev
|
|
9349
|
-
|
|
9353
|
+
* each have 29 days), and has Passover start on Sunday. */
|
|
9350
9354
|
// e.g. 5761
|
|
9351
9355
|
'070': yearStartRH.concat(r020, D(21), 23, 24, PESACH7, 25, D(26), D(28), 30, D(31), r3340, D(41), r4350),
|
|
9352
9356
|
/* Hebrew year that starts on Saturday, is `complete' (Heshvan and
|
|
9353
|
-
|
|
9357
|
+
* Kislev each have 30 days), and has Passover start on Tuesday. */
|
|
9354
9358
|
// e.g. 5716
|
|
9355
9359
|
'072': yearStartRH.concat(r020, D(21), 23, 24, CHMPESACH, 25, D(26), D(28), 30, D(31), r3340, D(41), r4349, D(50)),
|
|
9356
9360
|
/* -- The leap year types (keviot) -- */
|
|
9357
9361
|
/* Hebrew year that starts on Monday, is `incomplete' (Heshvan and
|
|
9358
|
-
|
|
9362
|
+
* Kislev each have 29 days), and has Passover start on Thursday. */
|
|
9359
9363
|
// e.g. 5746
|
|
9360
9364
|
'1200': yearStartVayeilech.concat(r027, CHMPESACH, range$1(28, 33), SHAVUOT$1, range$1(34, 37), D(38), 40, D(41), r4349, D(50)),
|
|
9361
9365
|
/* Hebrew year that starts on Monday, is `incomplete' (Heshvan and
|
|
9362
|
-
|
|
9366
|
+
* Kislev each have 29 days), and has Passover start on Thursday. */
|
|
9363
9367
|
// e.g. 5746
|
|
9364
9368
|
'1201': yearStartVayeilech.concat(r027, CHMPESACH, range$1(28, 40), D(41), r4349, D(50)),
|
|
9365
9369
|
/* Hebrew year that starts on Monday, is `complete' (Heshvan and
|
|
9366
|
-
|
|
9370
|
+
* Kislev each have 30 days), and has Passover start on Saturday. */
|
|
9367
9371
|
// e.g.5752
|
|
9368
9372
|
'1220': yearStartVayeilech.concat(r027, PESACH1, PESACH8, range$1(28, 40), D(41), r4350),
|
|
9369
9373
|
/* Hebrew year that starts on Monday, is `complete' (Heshvan and
|
|
9370
|
-
|
|
9374
|
+
* Kislev each have 30 days), and has Passover start on Saturday. */
|
|
9371
9375
|
// e.g.5752
|
|
9372
9376
|
'1221': yearStartVayeilech.concat(r027, PESACH, range$1(28, 50)),
|
|
9373
9377
|
/* Hebrew year that starts on Thursday, is `incomplete' (Heshvan and
|
|
9374
|
-
|
|
9378
|
+
* Kislev both have 29 days), and has Passover start on Sunday. */
|
|
9375
9379
|
// e.g. 5768
|
|
9376
9380
|
'150': yearStartHaazinu.concat(range$1(0, 28), PESACH7, range$1(29, 50)),
|
|
9377
9381
|
/* Hebrew year that starts on Thursday, is `complete' (Heshvan and
|
|
9378
|
-
|
|
9382
|
+
* Kislev both have 30 days), and has Passover start on Tuesday. */
|
|
9379
9383
|
// eg. 5771
|
|
9380
9384
|
'152': yearStartHaazinu.concat(range$1(0, 28), CHMPESACH, range$1(29, 49), D(50)),
|
|
9381
9385
|
/* Hebrew year that starts on Saturday, is `incomplete' (Heshvan and
|
|
9382
|
-
|
|
9386
|
+
* Kislev each have 29 days), and has Passover start on Tuesday. */
|
|
9383
9387
|
// e.g.5757
|
|
9384
9388
|
'170': yearStartRH.concat(r027, CHMPESACH, range$1(28, 40), D(41), r4349, D(50)),
|
|
9385
9389
|
/* Hebrew year that starts on Saturday, is `complete' (Heshvan and
|
|
9386
|
-
|
|
9390
|
+
* Kislev each have 30 days), and has Passover start on Thursday. */
|
|
9387
9391
|
'1720': yearStartRH.concat(r027, CHMPESACH, range$1(28, 33), SHAVUOT$1, range$1(34, 37), D(38), 40, D(41), r4349, D(50)),
|
|
9388
9392
|
};
|
|
9389
9393
|
/* Hebrew year that starts on Monday, is `complete' (Heshvan and
|
|
@@ -9411,9 +9415,8 @@ const sedraCache = new QuickLRU({ maxSize: 400 });
|
|
|
9411
9415
|
* Convenience function to create an instance of `Sedra` or reuse a previously
|
|
9412
9416
|
* created and cached instance.
|
|
9413
9417
|
* @private
|
|
9414
|
-
* @param
|
|
9415
|
-
* @param
|
|
9416
|
-
* @return {Sedra}
|
|
9418
|
+
* @param hyear
|
|
9419
|
+
* @param il
|
|
9417
9420
|
*/
|
|
9418
9421
|
function getSedra_(hyear, il) {
|
|
9419
9422
|
const cacheKey = `${hyear}-${il ? 1 : 0}`;
|
|
@@ -9430,11 +9433,8 @@ function getSedra_(hyear, il) {
|
|
|
9430
9433
|
*/
|
|
9431
9434
|
class ParshaEvent extends Event {
|
|
9432
9435
|
/**
|
|
9433
|
-
* @param
|
|
9434
|
-
* @param {string[]} parsha - untranslated name of single or double parsha,
|
|
9436
|
+
* @param parsha - untranslated name of single or double parsha,
|
|
9435
9437
|
* such as ['Bereshit'] or ['Achrei Mot', 'Kedoshim']
|
|
9436
|
-
* @param {boolean} [il]
|
|
9437
|
-
* @param {number|number[]} [num]
|
|
9438
9438
|
*/
|
|
9439
9439
|
constructor(date, parsha, il = false, num = -1) {
|
|
9440
9440
|
if (!Array.isArray(parsha) || parsha.length === 0 || parsha.length > 2) {
|
|
@@ -9447,26 +9447,23 @@ class ParshaEvent extends Event {
|
|
|
9447
9447
|
this.num = num || -1;
|
|
9448
9448
|
}
|
|
9449
9449
|
/**
|
|
9450
|
-
* @param
|
|
9451
|
-
* @return {string}
|
|
9450
|
+
* @param [locale] Optional locale name (i.e: `'he'`, `'fr'`). Defaults to active locale.
|
|
9452
9451
|
*/
|
|
9453
9452
|
render(locale) {
|
|
9454
9453
|
const locale0 = locale !== null && locale !== void 0 ? locale : Locale.getLocaleName();
|
|
9455
9454
|
const parsha = this.parsha;
|
|
9456
9455
|
let name = Locale.gettext(parsha[0], locale);
|
|
9457
|
-
if (parsha.length
|
|
9458
|
-
const hyphen = locale0
|
|
9456
|
+
if (parsha.length === 2) {
|
|
9457
|
+
const hyphen = locale0 === 'he' ? '־' : '-';
|
|
9459
9458
|
name += hyphen + Locale.gettext(parsha[1], locale);
|
|
9460
9459
|
}
|
|
9461
9460
|
name = name.replace(/'/g, '’');
|
|
9462
9461
|
const str = Locale.gettext('Parashat', locale) + ' ' + name;
|
|
9463
9462
|
return str.normalize();
|
|
9464
9463
|
}
|
|
9465
|
-
/** @return {string} */
|
|
9466
9464
|
basename() {
|
|
9467
9465
|
return this.parsha.join('-');
|
|
9468
9466
|
}
|
|
9469
|
-
/** @return {string | undefined} */
|
|
9470
9467
|
url() {
|
|
9471
9468
|
const year = this.getDate().greg().getFullYear();
|
|
9472
9469
|
if (year < 100) {
|
|
@@ -9474,10 +9471,11 @@ class ParshaEvent extends Event {
|
|
|
9474
9471
|
}
|
|
9475
9472
|
const dt = this.urlDateSuffix();
|
|
9476
9473
|
const url = 'https://www.hebcal.com/sedrot/' +
|
|
9477
|
-
this.basename().toLowerCase().replace(/'/g, '').replace(/ /g, '-') +
|
|
9474
|
+
this.basename().toLowerCase().replace(/'/g, '').replace(/ /g, '-') +
|
|
9475
|
+
'-' +
|
|
9476
|
+
dt;
|
|
9478
9477
|
return this.il ? url + '?i=on' : url;
|
|
9479
9478
|
}
|
|
9480
|
-
/** @return {string} */
|
|
9481
9479
|
urlDateSuffix() {
|
|
9482
9480
|
const isoDate = isoDateString(this.getDate().greg());
|
|
9483
9481
|
return isoDate.replace(/-/g, '');
|
|
@@ -9514,13 +9512,13 @@ const YOM_KIPPUR = 'Yom Kippur';
|
|
|
9514
9512
|
const EREV_SUKKOT = 'Erev Sukkot';
|
|
9515
9513
|
const SUKKOT_I = 'Sukkot I';
|
|
9516
9514
|
const SUKKOT_II = 'Sukkot II';
|
|
9517
|
-
const SUKKOT_III_CHM =
|
|
9518
|
-
const SUKKOT_IV_CHM =
|
|
9519
|
-
const SUKKOT_V_CHM =
|
|
9520
|
-
const SUKKOT_VI_CHM =
|
|
9515
|
+
const SUKKOT_III_CHM = "Sukkot III (CH''M)";
|
|
9516
|
+
const SUKKOT_IV_CHM = "Sukkot IV (CH''M)";
|
|
9517
|
+
const SUKKOT_V_CHM = "Sukkot V (CH''M)";
|
|
9518
|
+
const SUKKOT_VI_CHM = "Sukkot VI (CH''M)";
|
|
9521
9519
|
const SHMINI_ATZERET = 'Shmini Atzeret';
|
|
9522
9520
|
const SIMCHAT_TORAH = 'Simchat Torah';
|
|
9523
|
-
const SUKKOT_II_CHM =
|
|
9521
|
+
const SUKKOT_II_CHM = "Sukkot II (CH''M)";
|
|
9524
9522
|
const SUKKOT_VII_HOSHANA_RABA = 'Sukkot VII (Hoshana Raba)';
|
|
9525
9523
|
const CHANUKAH_1_CANDLE = 'Chanukah: 1 Candle';
|
|
9526
9524
|
const TU_BISHVAT = 'Tu BiShvat';
|
|
@@ -9530,11 +9528,11 @@ const SHUSHAN_PURIM = 'Shushan Purim';
|
|
|
9530
9528
|
const EREV_PESACH = 'Erev Pesach';
|
|
9531
9529
|
const PESACH_I = 'Pesach I';
|
|
9532
9530
|
const PESACH_II = 'Pesach II';
|
|
9533
|
-
const PESACH_II_CHM =
|
|
9534
|
-
const PESACH_III_CHM =
|
|
9535
|
-
const PESACH_IV_CHM =
|
|
9536
|
-
const PESACH_V_CHM =
|
|
9537
|
-
const PESACH_VI_CHM =
|
|
9531
|
+
const PESACH_II_CHM = "Pesach II (CH''M)";
|
|
9532
|
+
const PESACH_III_CHM = "Pesach III (CH''M)";
|
|
9533
|
+
const PESACH_IV_CHM = "Pesach IV (CH''M)";
|
|
9534
|
+
const PESACH_V_CHM = "Pesach V (CH''M)";
|
|
9535
|
+
const PESACH_VI_CHM = "Pesach VI (CH''M)";
|
|
9538
9536
|
const PESACH_VII = 'Pesach VII';
|
|
9539
9537
|
const PESACH_VIII = 'Pesach VIII';
|
|
9540
9538
|
const PESACH_SHENI = 'Pesach Sheni';
|
|
@@ -9543,7 +9541,7 @@ const EREV_SHAVUOT = 'Erev Shavuot';
|
|
|
9543
9541
|
const SHAVUOT = 'Shavuot';
|
|
9544
9542
|
const SHAVUOT_I = 'Shavuot I';
|
|
9545
9543
|
const SHAVUOT_II = 'Shavuot II';
|
|
9546
|
-
const TU_BAV =
|
|
9544
|
+
const TU_BAV = "Tu B'Av";
|
|
9547
9545
|
const ROSH_HASHANA_LABEHEMOT = 'Rosh Hashana LaBehemot';
|
|
9548
9546
|
const EREV_ROSH_HASHANA = 'Erev Rosh Hashana';
|
|
9549
9547
|
const YOM_YERUSHALAYIM = 'Yom Yerushalayim';
|
|
@@ -9563,7 +9561,7 @@ const HEBREW_LANGUAGE_DAY = 'Hebrew Language Day';
|
|
|
9563
9561
|
*/
|
|
9564
9562
|
const holidayDesc = {
|
|
9565
9563
|
/** Asara B'Tevet */
|
|
9566
|
-
ASARA_BTEVET:
|
|
9564
|
+
ASARA_BTEVET: "Asara B'Tevet",
|
|
9567
9565
|
/** Birkat Hachamah */
|
|
9568
9566
|
BIRKAT_HACHAMAH: 'Birkat Hachamah',
|
|
9569
9567
|
/** Chag HaBanot */
|
|
@@ -9571,7 +9569,7 @@ const holidayDesc = {
|
|
|
9571
9569
|
/** Chanukah: 8th Day */
|
|
9572
9570
|
CHANUKAH_8TH_DAY: 'Chanukah: 8th Day',
|
|
9573
9571
|
/** Erev Tish'a B'Av */
|
|
9574
|
-
EREV_TISHA_BAV:
|
|
9572
|
+
EREV_TISHA_BAV: "Erev Tish'a B'Av",
|
|
9575
9573
|
/** Leil Selichot */
|
|
9576
9574
|
LEIL_SELICHOT: 'Leil Selichot',
|
|
9577
9575
|
/** Purim Katan */
|
|
@@ -9599,17 +9597,17 @@ const holidayDesc = {
|
|
|
9599
9597
|
/** Shushan Purim Katan */
|
|
9600
9598
|
SHUSHAN_PURIM_KATAN: 'Shushan Purim Katan',
|
|
9601
9599
|
/** Ta'anit Bechorot */
|
|
9602
|
-
TAANIT_BECHOROT:
|
|
9600
|
+
TAANIT_BECHOROT: "Ta'anit Bechorot",
|
|
9603
9601
|
/** Ta'anit Esther */
|
|
9604
|
-
TAANIT_ESTHER:
|
|
9602
|
+
TAANIT_ESTHER: "Ta'anit Esther",
|
|
9605
9603
|
/** Tish'a B'Av */
|
|
9606
|
-
TISHA_BAV:
|
|
9604
|
+
TISHA_BAV: "Tish'a B'Av",
|
|
9607
9605
|
/** Tzom Gedaliah */
|
|
9608
9606
|
TZOM_GEDALIAH: 'Tzom Gedaliah',
|
|
9609
9607
|
/** Tzom Tammuz */
|
|
9610
9608
|
TZOM_TAMMUZ: 'Tzom Tammuz',
|
|
9611
9609
|
/** Yom HaAtzma'ut */
|
|
9612
|
-
YOM_HAATZMA_UT:
|
|
9610
|
+
YOM_HAATZMA_UT: "Yom HaAtzma'ut",
|
|
9613
9611
|
/** Yom HaShoah */
|
|
9614
9612
|
YOM_HASHOAH: 'Yom HaShoah',
|
|
9615
9613
|
/** Yom HaZikaron */
|
|
@@ -9712,128 +9710,403 @@ const holidayDesc = {
|
|
|
9712
9710
|
YOM_YERUSHALAYIM,
|
|
9713
9711
|
};
|
|
9714
9712
|
const staticHolidays = [
|
|
9715
|
-
{
|
|
9713
|
+
{
|
|
9714
|
+
mm: Tishrei,
|
|
9715
|
+
dd: 2,
|
|
9716
|
+
desc: ROSH_HASHANA_II,
|
|
9717
|
+
flags: CHAG$1 | YOM_TOV_ENDS$1,
|
|
9718
|
+
emoji: '🍏🍯',
|
|
9719
|
+
},
|
|
9716
9720
|
{ mm: Tishrei, dd: 9, desc: EREV_YOM_KIPPUR, flags: EREV$2 | LIGHT_CANDLES$1 },
|
|
9717
|
-
{
|
|
9718
|
-
|
|
9719
|
-
|
|
9720
|
-
|
|
9721
|
-
|
|
9722
|
-
|
|
9723
|
-
{
|
|
9724
|
-
|
|
9725
|
-
|
|
9726
|
-
|
|
9727
|
-
|
|
9728
|
-
|
|
9729
|
-
|
|
9730
|
-
{
|
|
9731
|
-
|
|
9732
|
-
|
|
9733
|
-
|
|
9734
|
-
|
|
9735
|
-
|
|
9736
|
-
|
|
9737
|
-
|
|
9738
|
-
|
|
9739
|
-
|
|
9740
|
-
|
|
9741
|
-
flags:
|
|
9721
|
+
{
|
|
9722
|
+
mm: Tishrei,
|
|
9723
|
+
dd: 10,
|
|
9724
|
+
desc: YOM_KIPPUR,
|
|
9725
|
+
flags: CHAG$1 | MAJOR_FAST$2 | YOM_TOV_ENDS$1,
|
|
9726
|
+
},
|
|
9727
|
+
{
|
|
9728
|
+
mm: Tishrei,
|
|
9729
|
+
dd: 14,
|
|
9730
|
+
desc: EREV_SUKKOT,
|
|
9731
|
+
flags: CHUL_ONLY$1 | EREV$2 | LIGHT_CANDLES$1,
|
|
9732
|
+
emoji: emojiSukkot,
|
|
9733
|
+
},
|
|
9734
|
+
{
|
|
9735
|
+
mm: Tishrei,
|
|
9736
|
+
dd: 15,
|
|
9737
|
+
desc: SUKKOT_I,
|
|
9738
|
+
flags: CHUL_ONLY$1 | CHAG$1 | LIGHT_CANDLES_TZEIS$2,
|
|
9739
|
+
emoji: emojiSukkot,
|
|
9740
|
+
},
|
|
9741
|
+
{
|
|
9742
|
+
mm: Tishrei,
|
|
9743
|
+
dd: 16,
|
|
9744
|
+
desc: SUKKOT_II,
|
|
9745
|
+
flags: CHUL_ONLY$1 | CHAG$1 | YOM_TOV_ENDS$1,
|
|
9746
|
+
emoji: emojiSukkot,
|
|
9747
|
+
},
|
|
9748
|
+
{
|
|
9749
|
+
mm: Tishrei,
|
|
9750
|
+
dd: 17,
|
|
9751
|
+
desc: SUKKOT_III_CHM,
|
|
9752
|
+
flags: CHUL_ONLY$1 | CHOL_HAMOED$1,
|
|
9753
|
+
chmDay: 1,
|
|
9754
|
+
emoji: emojiSukkot,
|
|
9755
|
+
},
|
|
9756
|
+
{
|
|
9757
|
+
mm: Tishrei,
|
|
9758
|
+
dd: 18,
|
|
9759
|
+
desc: SUKKOT_IV_CHM,
|
|
9760
|
+
flags: CHUL_ONLY$1 | CHOL_HAMOED$1,
|
|
9761
|
+
chmDay: 2,
|
|
9762
|
+
emoji: emojiSukkot,
|
|
9763
|
+
},
|
|
9764
|
+
{
|
|
9765
|
+
mm: Tishrei,
|
|
9766
|
+
dd: 19,
|
|
9767
|
+
desc: SUKKOT_V_CHM,
|
|
9768
|
+
flags: CHUL_ONLY$1 | CHOL_HAMOED$1,
|
|
9769
|
+
chmDay: 3,
|
|
9770
|
+
emoji: emojiSukkot,
|
|
9771
|
+
},
|
|
9772
|
+
{
|
|
9773
|
+
mm: Tishrei,
|
|
9774
|
+
dd: 20,
|
|
9775
|
+
desc: SUKKOT_VI_CHM,
|
|
9776
|
+
flags: CHUL_ONLY$1 | CHOL_HAMOED$1,
|
|
9777
|
+
chmDay: 4,
|
|
9778
|
+
emoji: emojiSukkot,
|
|
9779
|
+
},
|
|
9780
|
+
{
|
|
9781
|
+
mm: Tishrei,
|
|
9782
|
+
dd: 22,
|
|
9783
|
+
desc: SHMINI_ATZERET,
|
|
9784
|
+
flags: CHUL_ONLY$1 | CHAG$1 | LIGHT_CANDLES_TZEIS$2,
|
|
9785
|
+
},
|
|
9786
|
+
{
|
|
9787
|
+
mm: Tishrei,
|
|
9788
|
+
dd: 23,
|
|
9789
|
+
desc: SIMCHAT_TORAH,
|
|
9790
|
+
flags: CHUL_ONLY$1 | CHAG$1 | YOM_TOV_ENDS$1,
|
|
9791
|
+
},
|
|
9792
|
+
{
|
|
9793
|
+
mm: Tishrei,
|
|
9794
|
+
dd: 14,
|
|
9795
|
+
desc: EREV_SUKKOT,
|
|
9796
|
+
flags: IL_ONLY$2 | EREV$2 | LIGHT_CANDLES$1,
|
|
9797
|
+
emoji: emojiSukkot,
|
|
9798
|
+
},
|
|
9799
|
+
{
|
|
9800
|
+
mm: Tishrei,
|
|
9801
|
+
dd: 15,
|
|
9802
|
+
desc: SUKKOT_I,
|
|
9803
|
+
flags: IL_ONLY$2 | CHAG$1 | YOM_TOV_ENDS$1,
|
|
9804
|
+
emoji: emojiSukkot,
|
|
9805
|
+
},
|
|
9806
|
+
{
|
|
9807
|
+
mm: Tishrei,
|
|
9808
|
+
dd: 16,
|
|
9809
|
+
desc: SUKKOT_II_CHM,
|
|
9810
|
+
flags: IL_ONLY$2 | CHOL_HAMOED$1,
|
|
9811
|
+
chmDay: 1,
|
|
9812
|
+
emoji: emojiSukkot,
|
|
9813
|
+
},
|
|
9814
|
+
{
|
|
9815
|
+
mm: Tishrei,
|
|
9816
|
+
dd: 17,
|
|
9817
|
+
desc: SUKKOT_III_CHM,
|
|
9818
|
+
flags: IL_ONLY$2 | CHOL_HAMOED$1,
|
|
9819
|
+
chmDay: 2,
|
|
9820
|
+
emoji: emojiSukkot,
|
|
9821
|
+
},
|
|
9822
|
+
{
|
|
9823
|
+
mm: Tishrei,
|
|
9824
|
+
dd: 18,
|
|
9825
|
+
desc: SUKKOT_IV_CHM,
|
|
9826
|
+
flags: IL_ONLY$2 | CHOL_HAMOED$1,
|
|
9827
|
+
chmDay: 3,
|
|
9828
|
+
emoji: emojiSukkot,
|
|
9829
|
+
},
|
|
9830
|
+
{
|
|
9831
|
+
mm: Tishrei,
|
|
9832
|
+
dd: 19,
|
|
9833
|
+
desc: SUKKOT_V_CHM,
|
|
9834
|
+
flags: IL_ONLY$2 | CHOL_HAMOED$1,
|
|
9835
|
+
chmDay: 4,
|
|
9836
|
+
emoji: emojiSukkot,
|
|
9837
|
+
},
|
|
9838
|
+
{
|
|
9839
|
+
mm: Tishrei,
|
|
9840
|
+
dd: 20,
|
|
9841
|
+
desc: SUKKOT_VI_CHM,
|
|
9842
|
+
flags: IL_ONLY$2 | CHOL_HAMOED$1,
|
|
9843
|
+
chmDay: 5,
|
|
9844
|
+
emoji: emojiSukkot,
|
|
9845
|
+
},
|
|
9846
|
+
{
|
|
9847
|
+
mm: Tishrei,
|
|
9848
|
+
dd: 22,
|
|
9849
|
+
desc: SHMINI_ATZERET,
|
|
9850
|
+
flags: IL_ONLY$2 | CHAG$1 | YOM_TOV_ENDS$1,
|
|
9851
|
+
},
|
|
9852
|
+
{
|
|
9853
|
+
mm: Tishrei,
|
|
9854
|
+
dd: 21,
|
|
9855
|
+
desc: SUKKOT_VII_HOSHANA_RABA,
|
|
9856
|
+
flags: LIGHT_CANDLES$1 | CHOL_HAMOED$1,
|
|
9857
|
+
chmDay: -1,
|
|
9858
|
+
emoji: emojiSukkot,
|
|
9859
|
+
},
|
|
9860
|
+
{
|
|
9861
|
+
mm: Kislev,
|
|
9862
|
+
dd: 24,
|
|
9863
|
+
desc: CHANUKAH_1_CANDLE,
|
|
9864
|
+
flags: EREV$2 | MINOR_HOLIDAY$2 | CHANUKAH_CANDLES$2,
|
|
9865
|
+
emoji: '🕎1️⃣',
|
|
9866
|
+
},
|
|
9742
9867
|
{ mm: Shvat, dd: 15, desc: TU_BISHVAT, flags: MINOR_HOLIDAY$2, emoji: '🌳' },
|
|
9743
|
-
{
|
|
9868
|
+
{
|
|
9869
|
+
mm: Adar2,
|
|
9870
|
+
dd: 13,
|
|
9871
|
+
desc: EREV_PURIM,
|
|
9872
|
+
flags: EREV$2 | MINOR_HOLIDAY$2,
|
|
9873
|
+
emoji: '🎭️📜',
|
|
9874
|
+
},
|
|
9744
9875
|
{ mm: Adar2, dd: 14, desc: PURIM, flags: MINOR_HOLIDAY$2, emoji: '🎭️📜' },
|
|
9745
|
-
{
|
|
9876
|
+
{
|
|
9877
|
+
mm: Adar2,
|
|
9878
|
+
dd: 15,
|
|
9879
|
+
desc: SHUSHAN_PURIM,
|
|
9880
|
+
flags: MINOR_HOLIDAY$2,
|
|
9881
|
+
emoji: '🎭️📜',
|
|
9882
|
+
},
|
|
9746
9883
|
// Pesach Israel
|
|
9747
|
-
{
|
|
9748
|
-
|
|
9749
|
-
|
|
9750
|
-
|
|
9751
|
-
|
|
9752
|
-
|
|
9753
|
-
|
|
9754
|
-
|
|
9755
|
-
|
|
9756
|
-
|
|
9757
|
-
|
|
9758
|
-
flags: IL_ONLY$2 |
|
|
9759
|
-
|
|
9760
|
-
|
|
9761
|
-
{
|
|
9762
|
-
|
|
9884
|
+
{
|
|
9885
|
+
mm: Nisan,
|
|
9886
|
+
dd: 14,
|
|
9887
|
+
desc: EREV_PESACH,
|
|
9888
|
+
flags: IL_ONLY$2 | EREV$2 | LIGHT_CANDLES$1,
|
|
9889
|
+
emoji: '🫓🍷',
|
|
9890
|
+
},
|
|
9891
|
+
{
|
|
9892
|
+
mm: Nisan,
|
|
9893
|
+
dd: 15,
|
|
9894
|
+
desc: PESACH_I,
|
|
9895
|
+
flags: IL_ONLY$2 | CHAG$1 | YOM_TOV_ENDS$1,
|
|
9896
|
+
emoji: emojiPesach,
|
|
9897
|
+
},
|
|
9898
|
+
{
|
|
9899
|
+
mm: Nisan,
|
|
9900
|
+
dd: 16,
|
|
9901
|
+
desc: PESACH_II_CHM,
|
|
9902
|
+
flags: IL_ONLY$2 | CHOL_HAMOED$1,
|
|
9903
|
+
chmDay: 1,
|
|
9904
|
+
emoji: emojiPesach,
|
|
9905
|
+
},
|
|
9906
|
+
{
|
|
9907
|
+
mm: Nisan,
|
|
9908
|
+
dd: 17,
|
|
9909
|
+
desc: PESACH_III_CHM,
|
|
9910
|
+
flags: IL_ONLY$2 | CHOL_HAMOED$1,
|
|
9911
|
+
chmDay: 2,
|
|
9912
|
+
emoji: emojiPesach,
|
|
9913
|
+
},
|
|
9914
|
+
{
|
|
9915
|
+
mm: Nisan,
|
|
9916
|
+
dd: 18,
|
|
9917
|
+
desc: PESACH_IV_CHM,
|
|
9918
|
+
flags: IL_ONLY$2 | CHOL_HAMOED$1,
|
|
9919
|
+
chmDay: 3,
|
|
9920
|
+
emoji: emojiPesach,
|
|
9921
|
+
},
|
|
9922
|
+
{
|
|
9923
|
+
mm: Nisan,
|
|
9924
|
+
dd: 19,
|
|
9925
|
+
desc: PESACH_V_CHM,
|
|
9926
|
+
flags: IL_ONLY$2 | CHOL_HAMOED$1,
|
|
9927
|
+
chmDay: 4,
|
|
9928
|
+
emoji: emojiPesach,
|
|
9929
|
+
},
|
|
9930
|
+
{
|
|
9931
|
+
mm: Nisan,
|
|
9932
|
+
dd: 20,
|
|
9933
|
+
desc: PESACH_VI_CHM,
|
|
9934
|
+
flags: IL_ONLY$2 | CHOL_HAMOED$1 | LIGHT_CANDLES$1,
|
|
9935
|
+
chmDay: 5,
|
|
9936
|
+
emoji: emojiPesach,
|
|
9937
|
+
},
|
|
9938
|
+
{
|
|
9939
|
+
mm: Nisan,
|
|
9940
|
+
dd: 21,
|
|
9941
|
+
desc: PESACH_VII,
|
|
9942
|
+
flags: IL_ONLY$2 | CHAG$1 | YOM_TOV_ENDS$1,
|
|
9943
|
+
emoji: emojiPesach,
|
|
9944
|
+
},
|
|
9763
9945
|
// Pesach chutz l'aretz
|
|
9764
|
-
{
|
|
9765
|
-
|
|
9766
|
-
|
|
9767
|
-
|
|
9768
|
-
|
|
9769
|
-
|
|
9770
|
-
|
|
9771
|
-
|
|
9772
|
-
|
|
9773
|
-
|
|
9774
|
-
|
|
9775
|
-
flags: CHUL_ONLY$1 |
|
|
9776
|
-
|
|
9777
|
-
|
|
9778
|
-
{
|
|
9779
|
-
|
|
9780
|
-
|
|
9781
|
-
|
|
9946
|
+
{
|
|
9947
|
+
mm: Nisan,
|
|
9948
|
+
dd: 14,
|
|
9949
|
+
desc: EREV_PESACH,
|
|
9950
|
+
flags: CHUL_ONLY$1 | EREV$2 | LIGHT_CANDLES$1,
|
|
9951
|
+
emoji: '🫓🍷',
|
|
9952
|
+
},
|
|
9953
|
+
{
|
|
9954
|
+
mm: Nisan,
|
|
9955
|
+
dd: 15,
|
|
9956
|
+
desc: PESACH_I,
|
|
9957
|
+
flags: CHUL_ONLY$1 | CHAG$1 | LIGHT_CANDLES_TZEIS$2,
|
|
9958
|
+
emoji: '🫓🍷',
|
|
9959
|
+
},
|
|
9960
|
+
{
|
|
9961
|
+
mm: Nisan,
|
|
9962
|
+
dd: 16,
|
|
9963
|
+
desc: PESACH_II,
|
|
9964
|
+
flags: CHUL_ONLY$1 | CHAG$1 | YOM_TOV_ENDS$1,
|
|
9965
|
+
emoji: emojiPesach,
|
|
9966
|
+
},
|
|
9967
|
+
{
|
|
9968
|
+
mm: Nisan,
|
|
9969
|
+
dd: 17,
|
|
9970
|
+
desc: PESACH_III_CHM,
|
|
9971
|
+
flags: CHUL_ONLY$1 | CHOL_HAMOED$1,
|
|
9972
|
+
chmDay: 1,
|
|
9973
|
+
emoji: emojiPesach,
|
|
9974
|
+
},
|
|
9975
|
+
{
|
|
9976
|
+
mm: Nisan,
|
|
9977
|
+
dd: 18,
|
|
9978
|
+
desc: PESACH_IV_CHM,
|
|
9979
|
+
flags: CHUL_ONLY$1 | CHOL_HAMOED$1,
|
|
9980
|
+
chmDay: 2,
|
|
9981
|
+
emoji: emojiPesach,
|
|
9982
|
+
},
|
|
9983
|
+
{
|
|
9984
|
+
mm: Nisan,
|
|
9985
|
+
dd: 19,
|
|
9986
|
+
desc: PESACH_V_CHM,
|
|
9987
|
+
flags: CHUL_ONLY$1 | CHOL_HAMOED$1,
|
|
9988
|
+
chmDay: 3,
|
|
9989
|
+
emoji: emojiPesach,
|
|
9990
|
+
},
|
|
9991
|
+
{
|
|
9992
|
+
mm: Nisan,
|
|
9993
|
+
dd: 20,
|
|
9994
|
+
desc: PESACH_VI_CHM,
|
|
9995
|
+
flags: CHUL_ONLY$1 | CHOL_HAMOED$1 | LIGHT_CANDLES$1,
|
|
9996
|
+
chmDay: 4,
|
|
9997
|
+
emoji: emojiPesach,
|
|
9998
|
+
},
|
|
9999
|
+
{
|
|
10000
|
+
mm: Nisan,
|
|
10001
|
+
dd: 21,
|
|
10002
|
+
desc: PESACH_VII,
|
|
10003
|
+
flags: CHUL_ONLY$1 | CHAG$1 | LIGHT_CANDLES_TZEIS$2,
|
|
10004
|
+
emoji: emojiPesach,
|
|
10005
|
+
},
|
|
10006
|
+
{
|
|
10007
|
+
mm: Nisan,
|
|
10008
|
+
dd: 22,
|
|
10009
|
+
desc: PESACH_VIII,
|
|
10010
|
+
flags: CHUL_ONLY$1 | CHAG$1 | YOM_TOV_ENDS$1,
|
|
10011
|
+
emoji: emojiPesach,
|
|
10012
|
+
},
|
|
9782
10013
|
{ mm: Iyyar, dd: 14, desc: PESACH_SHENI, flags: MINOR_HOLIDAY$2 },
|
|
9783
10014
|
{ mm: Iyyar, dd: 18, desc: LAG_BAOMER, flags: MINOR_HOLIDAY$2, emoji: '🔥' },
|
|
9784
|
-
{
|
|
9785
|
-
|
|
9786
|
-
|
|
9787
|
-
|
|
9788
|
-
|
|
9789
|
-
|
|
9790
|
-
|
|
9791
|
-
|
|
9792
|
-
|
|
9793
|
-
|
|
9794
|
-
|
|
9795
|
-
flags:
|
|
9796
|
-
|
|
9797
|
-
|
|
10015
|
+
{
|
|
10016
|
+
mm: Sivan,
|
|
10017
|
+
dd: 5,
|
|
10018
|
+
desc: EREV_SHAVUOT,
|
|
10019
|
+
flags: EREV$2 | LIGHT_CANDLES$1,
|
|
10020
|
+
emoji: '⛰️🌸',
|
|
10021
|
+
},
|
|
10022
|
+
{
|
|
10023
|
+
mm: Sivan,
|
|
10024
|
+
dd: 6,
|
|
10025
|
+
desc: SHAVUOT,
|
|
10026
|
+
flags: IL_ONLY$2 | CHAG$1 | YOM_TOV_ENDS$1,
|
|
10027
|
+
emoji: '⛰️🌸',
|
|
10028
|
+
},
|
|
10029
|
+
{
|
|
10030
|
+
mm: Sivan,
|
|
10031
|
+
dd: 6,
|
|
10032
|
+
desc: SHAVUOT_I,
|
|
10033
|
+
flags: CHUL_ONLY$1 | CHAG$1 | LIGHT_CANDLES_TZEIS$2,
|
|
10034
|
+
emoji: '⛰️🌸',
|
|
10035
|
+
},
|
|
10036
|
+
{
|
|
10037
|
+
mm: Sivan,
|
|
10038
|
+
dd: 7,
|
|
10039
|
+
desc: SHAVUOT_II,
|
|
10040
|
+
flags: CHUL_ONLY$1 | CHAG$1 | YOM_TOV_ENDS$1,
|
|
10041
|
+
emoji: '⛰️🌸',
|
|
10042
|
+
},
|
|
10043
|
+
{ mm: Av, dd: 15, desc: TU_BAV, flags: MINOR_HOLIDAY$2, emoji: '❤️' },
|
|
10044
|
+
{
|
|
10045
|
+
mm: Elul,
|
|
10046
|
+
dd: 1,
|
|
10047
|
+
desc: ROSH_HASHANA_LABEHEMOT,
|
|
10048
|
+
flags: MINOR_HOLIDAY$2,
|
|
10049
|
+
emoji: '🐑',
|
|
10050
|
+
},
|
|
10051
|
+
{
|
|
10052
|
+
mm: Elul,
|
|
10053
|
+
dd: 29,
|
|
10054
|
+
desc: EREV_ROSH_HASHANA,
|
|
10055
|
+
flags: EREV$2 | LIGHT_CANDLES$1,
|
|
10056
|
+
emoji: '🍏🍯',
|
|
10057
|
+
},
|
|
9798
10058
|
];
|
|
9799
10059
|
const staticModernHolidays = [
|
|
9800
|
-
{ firstYear: 5727, mm: Iyyar, dd: 28, desc: YOM_YERUSHALAYIM,
|
|
9801
|
-
|
|
9802
|
-
|
|
9803
|
-
|
|
10060
|
+
{ firstYear: 5727, mm: Iyyar, dd: 28, desc: YOM_YERUSHALAYIM, chul: true },
|
|
10061
|
+
{
|
|
10062
|
+
firstYear: 5737,
|
|
10063
|
+
mm: Kislev,
|
|
10064
|
+
dd: 6,
|
|
10065
|
+
desc: BEN_GURION_DAY,
|
|
10066
|
+
satPostponeToSun: true,
|
|
10067
|
+
friPostponeToSun: true,
|
|
10068
|
+
},
|
|
9804
10069
|
{ firstYear: 5750, mm: Shvat, dd: 30, desc: FAMILY_DAY },
|
|
9805
|
-
{
|
|
9806
|
-
|
|
9807
|
-
|
|
9808
|
-
|
|
9809
|
-
|
|
9810
|
-
|
|
9811
|
-
|
|
9812
|
-
|
|
9813
|
-
{
|
|
9814
|
-
|
|
10070
|
+
{
|
|
10071
|
+
firstYear: 5758,
|
|
10072
|
+
mm: Cheshvan,
|
|
10073
|
+
dd: 12,
|
|
10074
|
+
desc: YITZHAK_RABIN_MEMORIAL_DAY,
|
|
10075
|
+
friSatMovetoThu: true,
|
|
10076
|
+
},
|
|
10077
|
+
{ firstYear: 5764, mm: Iyyar, dd: 10, desc: HERZL_DAY, satPostponeToSun: true },
|
|
10078
|
+
{
|
|
10079
|
+
firstYear: 5765,
|
|
10080
|
+
mm: Tamuz,
|
|
10081
|
+
dd: 29,
|
|
10082
|
+
desc: JABOTINSKY_DAY,
|
|
10083
|
+
satPostponeToSun: true,
|
|
10084
|
+
},
|
|
10085
|
+
{
|
|
10086
|
+
firstYear: 5769,
|
|
10087
|
+
mm: Cheshvan,
|
|
10088
|
+
dd: 29,
|
|
10089
|
+
desc: SIGD,
|
|
10090
|
+
chul: true,
|
|
10091
|
+
suppressEmoji: true,
|
|
10092
|
+
},
|
|
10093
|
+
{ firstYear: 5777, mm: Nisan, dd: 10, desc: YOM_HAALIYAH, chul: true },
|
|
9815
10094
|
{ firstYear: 5777, mm: Cheshvan, dd: 7, desc: YOM_HAALIYAH_SCHOOL_OBSERVANCE },
|
|
9816
10095
|
// https://www.gov.il/he/departments/policies/2012_des5234
|
|
9817
|
-
{
|
|
9818
|
-
|
|
10096
|
+
{
|
|
10097
|
+
firstYear: 5773,
|
|
10098
|
+
mm: months.TEVET,
|
|
10099
|
+
dd: 21,
|
|
10100
|
+
desc: HEBREW_LANGUAGE_DAY,
|
|
10101
|
+
friSatMovetoThu: true,
|
|
10102
|
+
},
|
|
9819
10103
|
];
|
|
9820
10104
|
|
|
9821
|
-
const minorHolidays = [
|
|
9822
|
-
holidayDesc.LAG_BAOMER,
|
|
9823
|
-
holidayDesc.LEIL_SELICHOT,
|
|
9824
|
-
holidayDesc.PESACH_SHENI,
|
|
9825
|
-
holidayDesc.EREV_PURIM,
|
|
9826
|
-
holidayDesc.PURIM_KATAN,
|
|
9827
|
-
holidayDesc.SHUSHAN_PURIM,
|
|
9828
|
-
holidayDesc.TU_BAV,
|
|
9829
|
-
holidayDesc.TU_BISHVAT,
|
|
9830
|
-
holidayDesc.ROSH_HASHANA_LABEHEMOT,
|
|
9831
|
-
];
|
|
9832
10105
|
/** Represents a built-in holiday like Pesach, Purim or Tu BiShvat */
|
|
9833
10106
|
class HolidayEvent extends Event {
|
|
9834
|
-
/** @return {string} */
|
|
9835
10107
|
basename() {
|
|
9836
|
-
return this.getDesc()
|
|
10108
|
+
return this.getDesc()
|
|
10109
|
+
.replace(/ \d{4}$/, '')
|
|
9837
10110
|
.replace(/ \(CH''M\)$/, '')
|
|
9838
10111
|
.replace(/ \(observed\)$/, '')
|
|
9839
10112
|
.replace(/ \(Hoshana Raba\)$/, '')
|
|
@@ -9842,23 +10115,21 @@ class HolidayEvent extends Event {
|
|
|
9842
10115
|
.replace(/: 8th Day$/, '')
|
|
9843
10116
|
.replace(/^Erev /, '');
|
|
9844
10117
|
}
|
|
9845
|
-
/** @return {string | undefined} */
|
|
9846
10118
|
url() {
|
|
9847
10119
|
const year = this.getDate().greg().getFullYear();
|
|
9848
10120
|
if (year < 100) {
|
|
9849
10121
|
return undefined;
|
|
9850
10122
|
}
|
|
9851
10123
|
const url = 'https://www.hebcal.com/holidays/' +
|
|
9852
|
-
this.basename().toLowerCase().replace(/'/g, '').replace(/ /g, '-') +
|
|
10124
|
+
this.basename().toLowerCase().replace(/'/g, '').replace(/ /g, '-') +
|
|
10125
|
+
'-' +
|
|
9853
10126
|
this.urlDateSuffix();
|
|
9854
|
-
return
|
|
10127
|
+
return this.getFlags() & flags.IL_ONLY ? url + '?i=on' : url;
|
|
9855
10128
|
}
|
|
9856
|
-
/** @return {string} */
|
|
9857
10129
|
urlDateSuffix() {
|
|
9858
10130
|
const year = this.getDate().greg().getFullYear();
|
|
9859
10131
|
return String(year);
|
|
9860
10132
|
}
|
|
9861
|
-
/** @return {string} */
|
|
9862
10133
|
getEmoji() {
|
|
9863
10134
|
if (this.emoji) {
|
|
9864
10135
|
return this.emoji;
|
|
@@ -9870,7 +10141,6 @@ class HolidayEvent extends Event {
|
|
|
9870
10141
|
return '✡️';
|
|
9871
10142
|
}
|
|
9872
10143
|
}
|
|
9873
|
-
/** @return {string[]} */
|
|
9874
10144
|
getCategories() {
|
|
9875
10145
|
if (this.cholHaMoedDay) {
|
|
9876
10146
|
return ['holiday', 'major', 'cholhamoed'];
|
|
@@ -9881,15 +10151,23 @@ class HolidayEvent extends Event {
|
|
|
9881
10151
|
}
|
|
9882
10152
|
// Don't depend on flags.MINOR_HOLIDAY always being set. Look for minor holidays.
|
|
9883
10153
|
const desc = this.getDesc();
|
|
9884
|
-
|
|
9885
|
-
|
|
10154
|
+
switch (desc) {
|
|
10155
|
+
case holidayDesc.LAG_BAOMER:
|
|
10156
|
+
case holidayDesc.LEIL_SELICHOT:
|
|
10157
|
+
case holidayDesc.PESACH_SHENI:
|
|
10158
|
+
case holidayDesc.EREV_PURIM:
|
|
10159
|
+
case holidayDesc.PURIM_KATAN:
|
|
10160
|
+
case holidayDesc.SHUSHAN_PURIM:
|
|
10161
|
+
case holidayDesc.TU_BAV:
|
|
10162
|
+
case holidayDesc.TU_BISHVAT:
|
|
10163
|
+
case holidayDesc.ROSH_HASHANA_LABEHEMOT:
|
|
10164
|
+
return ['holiday', 'minor'];
|
|
9886
10165
|
}
|
|
9887
10166
|
return ['holiday', 'major'];
|
|
9888
10167
|
}
|
|
9889
10168
|
/**
|
|
9890
10169
|
* Returns (translated) description of this event
|
|
9891
|
-
* @param
|
|
9892
|
-
* @return {string}
|
|
10170
|
+
* @param [locale] Optional locale name (defaults to active locale).
|
|
9893
10171
|
*/
|
|
9894
10172
|
render(locale) {
|
|
9895
10173
|
const str = super.render(locale);
|
|
@@ -9899,8 +10177,7 @@ class HolidayEvent extends Event {
|
|
|
9899
10177
|
* Returns a brief (translated) description of this event.
|
|
9900
10178
|
* For most events, this is the same as render(). For some events, it procudes
|
|
9901
10179
|
* a shorter text (e.g. without a time or added description).
|
|
9902
|
-
* @param
|
|
9903
|
-
* @return {string}
|
|
10180
|
+
* @param [locale] Optional locale name (defaults to active locale).
|
|
9904
10181
|
*/
|
|
9905
10182
|
renderBrief(locale) {
|
|
9906
10183
|
const str = super.renderBrief(locale);
|
|
@@ -9908,11 +10185,11 @@ class HolidayEvent extends Event {
|
|
|
9908
10185
|
}
|
|
9909
10186
|
/**
|
|
9910
10187
|
* Makes a clone of this Event object
|
|
9911
|
-
* @return {Event}
|
|
9912
10188
|
*/
|
|
9913
10189
|
clone() {
|
|
9914
10190
|
const ev = new HolidayEvent(this.date, this.desc, this.mask);
|
|
9915
10191
|
for (const property in this) {
|
|
10192
|
+
// eslint-disable-next-line no-prototype-builtins
|
|
9916
10193
|
if (this.hasOwnProperty(property)) {
|
|
9917
10194
|
Object.defineProperty(ev, property, { value: this[property] });
|
|
9918
10195
|
}
|
|
@@ -9925,7 +10202,6 @@ class HolidayEvent extends Event {
|
|
|
9925
10202
|
* we subclass HolidayEvent to override the `url()` method.
|
|
9926
10203
|
*/
|
|
9927
10204
|
class AsaraBTevetEvent extends HolidayEvent {
|
|
9928
|
-
/** @return {string} */
|
|
9929
10205
|
urlDateSuffix() {
|
|
9930
10206
|
const isoDate = isoDateString(this.getDate().greg());
|
|
9931
10207
|
return isoDate.replace(/-/g, '');
|
|
@@ -9935,9 +10211,9 @@ class AsaraBTevetEvent extends HolidayEvent {
|
|
|
9935
10211
|
class RoshHashanaEvent extends HolidayEvent {
|
|
9936
10212
|
/**
|
|
9937
10213
|
* @private
|
|
9938
|
-
* @param
|
|
9939
|
-
* @param
|
|
9940
|
-
* @param
|
|
10214
|
+
* @param date Hebrew date event occurs
|
|
10215
|
+
* @param hyear Hebrew year
|
|
10216
|
+
* @param mask optional holiday flags
|
|
9941
10217
|
*/
|
|
9942
10218
|
constructor(date, hyear, mask) {
|
|
9943
10219
|
super(date, `Rosh Hashana ${hyear}`, mask);
|
|
@@ -9945,13 +10221,11 @@ class RoshHashanaEvent extends HolidayEvent {
|
|
|
9945
10221
|
}
|
|
9946
10222
|
/**
|
|
9947
10223
|
* Returns (translated) description of this event
|
|
9948
|
-
* @param
|
|
9949
|
-
* @return {string}
|
|
10224
|
+
* @param [locale] Optional locale name (defaults to active locale).
|
|
9950
10225
|
*/
|
|
9951
10226
|
render(locale) {
|
|
9952
10227
|
return Locale.gettext('Rosh Hashana', locale) + ' ' + this.hyear;
|
|
9953
10228
|
}
|
|
9954
|
-
/** @return {string} */
|
|
9955
10229
|
getEmoji() {
|
|
9956
10230
|
return '🍏🍯';
|
|
9957
10231
|
}
|
|
@@ -9961,16 +10235,15 @@ const roshChodeshStr = 'Rosh Chodesh';
|
|
|
9961
10235
|
class RoshChodeshEvent extends HolidayEvent {
|
|
9962
10236
|
/**
|
|
9963
10237
|
* Constructs Rosh Chodesh event
|
|
9964
|
-
* @param
|
|
9965
|
-
* @param
|
|
10238
|
+
* @param date Hebrew date event occurs
|
|
10239
|
+
* @param monthName Hebrew month name (not translated)
|
|
9966
10240
|
*/
|
|
9967
10241
|
constructor(date, monthName) {
|
|
9968
10242
|
super(date, `${roshChodeshStr} ${monthName}`, flags.ROSH_CHODESH);
|
|
9969
10243
|
}
|
|
9970
10244
|
/**
|
|
9971
10245
|
* Returns (translated) description of this event
|
|
9972
|
-
* @param
|
|
9973
|
-
* @return {string}
|
|
10246
|
+
* @param [locale] Optional locale name (defaults to active locale).
|
|
9974
10247
|
*/
|
|
9975
10248
|
render(locale) {
|
|
9976
10249
|
const monthName = this.getDesc().substring(roshChodeshStr.length + 1);
|
|
@@ -9978,11 +10251,9 @@ class RoshChodeshEvent extends HolidayEvent {
|
|
|
9978
10251
|
const monthName1 = monthName0.replace(/'/g, '’');
|
|
9979
10252
|
return Locale.gettext(roshChodeshStr, locale) + ' ' + monthName1;
|
|
9980
10253
|
}
|
|
9981
|
-
/** @return {string} */
|
|
9982
10254
|
basename() {
|
|
9983
10255
|
return this.getDesc();
|
|
9984
10256
|
}
|
|
9985
|
-
/** @return {string} */
|
|
9986
10257
|
getEmoji() {
|
|
9987
10258
|
return this.emoji || '🌒';
|
|
9988
10259
|
}
|
|
@@ -9993,9 +10264,9 @@ const mevarchimChodeshStr = 'Shabbat Mevarchim Chodesh';
|
|
|
9993
10264
|
class MevarchimChodeshEvent extends Event {
|
|
9994
10265
|
/**
|
|
9995
10266
|
* Constructs Mevarchim haChodesh event
|
|
9996
|
-
* @param
|
|
9997
|
-
* @param
|
|
9998
|
-
* @param
|
|
10267
|
+
* @param date Hebrew date event occurs
|
|
10268
|
+
* @param monthName Hebrew month name (not translated)
|
|
10269
|
+
* @param [memo]
|
|
9999
10270
|
*/
|
|
10000
10271
|
constructor(date, monthName, memo) {
|
|
10001
10272
|
super(date, `${mevarchimChodeshStr} ${monthName}`, flags.SHABBAT_MEVARCHIM);
|
|
@@ -10006,19 +10277,17 @@ class MevarchimChodeshEvent extends Event {
|
|
|
10006
10277
|
else {
|
|
10007
10278
|
const hyear = date.getFullYear();
|
|
10008
10279
|
const hmonth = date.getMonth();
|
|
10009
|
-
const monNext =
|
|
10280
|
+
const monNext = hmonth === HDate.monthsInYear(hyear) ? months.NISAN : hmonth + 1;
|
|
10010
10281
|
const molad = new Molad(hyear, monNext);
|
|
10011
10282
|
this.memo = molad.render('en', { hour12: false });
|
|
10012
10283
|
}
|
|
10013
10284
|
}
|
|
10014
|
-
/** @return {string} */
|
|
10015
10285
|
basename() {
|
|
10016
10286
|
return this.getDesc();
|
|
10017
10287
|
}
|
|
10018
10288
|
/**
|
|
10019
10289
|
* Returns (translated) description of this event
|
|
10020
|
-
* @param
|
|
10021
|
-
* @return {string}
|
|
10290
|
+
* @param [locale] Optional locale name (defaults to active locale).
|
|
10022
10291
|
*/
|
|
10023
10292
|
render(locale) {
|
|
10024
10293
|
const monthName0 = Locale.gettext(this.monthName, locale);
|
|
@@ -10027,8 +10296,7 @@ class MevarchimChodeshEvent extends Event {
|
|
|
10027
10296
|
}
|
|
10028
10297
|
/**
|
|
10029
10298
|
* Returns (translated) description of this event
|
|
10030
|
-
* @param
|
|
10031
|
-
* @return {string}
|
|
10299
|
+
* @param [locale] Optional locale name (defaults to active locale).
|
|
10032
10300
|
*/
|
|
10033
10301
|
renderBrief(locale) {
|
|
10034
10302
|
const str = this.render(locale);
|
|
@@ -10047,8 +10315,6 @@ const cals = new Map();
|
|
|
10047
10315
|
class DailyLearning {
|
|
10048
10316
|
/**
|
|
10049
10317
|
* Register a new learning calendar.
|
|
10050
|
-
* @param {string} name
|
|
10051
|
-
* @param {Function} calendar
|
|
10052
10318
|
*/
|
|
10053
10319
|
static addCalendar(name, calendar) {
|
|
10054
10320
|
if (typeof calendar !== 'function') {
|
|
@@ -10059,10 +10325,9 @@ class DailyLearning {
|
|
|
10059
10325
|
/**
|
|
10060
10326
|
* Returns an event from daily calendar for a given date. Returns `null` if there
|
|
10061
10327
|
* is no learning from this calendar on this date.
|
|
10062
|
-
* @param
|
|
10063
|
-
* @param
|
|
10064
|
-
* @param
|
|
10065
|
-
* @return {Event | null}
|
|
10328
|
+
* @param name
|
|
10329
|
+
* @param hd
|
|
10330
|
+
* @param il
|
|
10066
10331
|
*/
|
|
10067
10332
|
static lookup(name, hd, il) {
|
|
10068
10333
|
const fn = cals.get(name);
|
|
@@ -10074,7 +10339,7 @@ class DailyLearning {
|
|
|
10074
10339
|
}
|
|
10075
10340
|
|
|
10076
10341
|
/** DO NOT EDIT THIS AUTO-GENERATED FILE! */
|
|
10077
|
-
const version = '5.4.
|
|
10342
|
+
const version = '5.4.10';
|
|
10078
10343
|
|
|
10079
10344
|
/* eslint-disable max-len */
|
|
10080
10345
|
/**
|
|
@@ -10101,11 +10366,15 @@ function makeCandleEvent(ev, hd, options, isFriday, isSaturday) {
|
|
|
10101
10366
|
mask = flags.LIGHT_CANDLES_TZEIS;
|
|
10102
10367
|
}
|
|
10103
10368
|
// if offset is 0 or undefined, we'll use tzeit time
|
|
10104
|
-
const offset = useHavdalahOffset
|
|
10369
|
+
const offset = useHavdalahOffset
|
|
10370
|
+
? options.havdalahMins
|
|
10371
|
+
: options.candleLightingMins;
|
|
10105
10372
|
const location = options.location;
|
|
10106
10373
|
const useElevation = Boolean(options.useElevation);
|
|
10107
10374
|
const zmanim = new Zmanim(location, hd, useElevation);
|
|
10108
|
-
const time = offset
|
|
10375
|
+
const time = offset
|
|
10376
|
+
? zmanim.sunsetOffset(offset, true)
|
|
10377
|
+
: zmanim.tzeit(options.havdalahDeg);
|
|
10109
10378
|
if (isNaN(time.getTime())) {
|
|
10110
10379
|
return undefined; // no sunset
|
|
10111
10380
|
}
|
|
@@ -10134,13 +10403,13 @@ function makeFastStartEnd(ev, options) {
|
|
|
10134
10403
|
const fastEndDeg = options.fastEndDeg;
|
|
10135
10404
|
const useElevation = Boolean(options.useElevation);
|
|
10136
10405
|
const zmanim = new Zmanim(location, dt, useElevation);
|
|
10137
|
-
if (desc ===
|
|
10406
|
+
if (desc === "Erev Tish'a B'Av") {
|
|
10138
10407
|
const sunset = zmanim.sunset();
|
|
10139
10408
|
if (!isNaN(sunset.getTime())) {
|
|
10140
10409
|
ev.startEvent = makeTimedEvent(ev, sunset, FAST_BEGINS, options);
|
|
10141
10410
|
}
|
|
10142
10411
|
}
|
|
10143
|
-
else if (desc.startsWith(
|
|
10412
|
+
else if (desc.startsWith("Tish'a B'Av")) {
|
|
10144
10413
|
const tzeit = zmanim.tzeit(fastEndDeg);
|
|
10145
10414
|
if (!isNaN(tzeit.getTime())) {
|
|
10146
10415
|
ev.endEvent = makeTimedEvent(ev, tzeit, FAST_ENDS, options);
|
|
@@ -10151,7 +10420,8 @@ function makeFastStartEnd(ev, options) {
|
|
|
10151
10420
|
if (!isNaN(dawn.getTime())) {
|
|
10152
10421
|
ev.startEvent = makeTimedEvent(ev, dawn, FAST_BEGINS, options);
|
|
10153
10422
|
}
|
|
10154
|
-
if (dt.getDay() !== 5 &&
|
|
10423
|
+
if (dt.getDay() !== 5 &&
|
|
10424
|
+
!(hd.getDate() === 14 && hd.getMonth() === months.NISAN)) {
|
|
10155
10425
|
const tzeit = zmanim.tzeit(fastEndDeg);
|
|
10156
10426
|
if (!isNaN(tzeit.getTime())) {
|
|
10157
10427
|
ev.endEvent = makeTimedEvent(ev, tzeit, FAST_ENDS, options);
|
|
@@ -10202,34 +10472,39 @@ const HALF = 1;
|
|
|
10202
10472
|
const WHOLE = 2;
|
|
10203
10473
|
/**
|
|
10204
10474
|
* @private
|
|
10205
|
-
* @param {Event[]} events
|
|
10206
|
-
* @param {HDate} hdate
|
|
10207
|
-
* @return {number}
|
|
10208
10475
|
*/
|
|
10209
10476
|
function hallel_(events, hdate) {
|
|
10210
|
-
const whole = events
|
|
10477
|
+
const whole = events
|
|
10478
|
+
.filter(ev => {
|
|
10211
10479
|
const desc = ev.getDesc();
|
|
10212
10480
|
const hd = ev.getDate();
|
|
10213
10481
|
const month = hd.getMonth();
|
|
10214
10482
|
const mday = hd.getDate();
|
|
10215
|
-
return desc.startsWith('Chanukah') ||
|
|
10483
|
+
return (desc.startsWith('Chanukah') ||
|
|
10216
10484
|
desc.startsWith('Shavuot') ||
|
|
10217
10485
|
desc.startsWith('Sukkot') ||
|
|
10218
|
-
(month === months.NISAN &&
|
|
10219
|
-
|
|
10220
|
-
|
|
10221
|
-
|
|
10486
|
+
(month === months.NISAN &&
|
|
10487
|
+
(mday === 15 || mday === 16) &&
|
|
10488
|
+
ev.getFlags() & flags.CHAG) || // Pesach
|
|
10489
|
+
desc === "Yom HaAtzma'ut" ||
|
|
10490
|
+
desc === 'Yom Yerushalayim');
|
|
10491
|
+
})
|
|
10492
|
+
.map(ev => {
|
|
10222
10493
|
return ev.getDate().abs();
|
|
10223
10494
|
});
|
|
10224
10495
|
const abs = hdate.abs();
|
|
10225
10496
|
if (whole.includes(abs)) {
|
|
10226
10497
|
return WHOLE;
|
|
10227
10498
|
}
|
|
10228
|
-
const half = events
|
|
10499
|
+
const half = events
|
|
10500
|
+
.filter(ev => {
|
|
10229
10501
|
const desc = ev.getDesc();
|
|
10230
|
-
return ev.getFlags() & flags.ROSH_CHODESH ||
|
|
10231
|
-
(desc.startsWith('Pesach') &&
|
|
10232
|
-
|
|
10502
|
+
return (ev.getFlags() & flags.ROSH_CHODESH ||
|
|
10503
|
+
(desc.startsWith('Pesach') &&
|
|
10504
|
+
desc !== 'Pesach I' &&
|
|
10505
|
+
desc !== 'Pesach II'));
|
|
10506
|
+
})
|
|
10507
|
+
.map(ev => {
|
|
10233
10508
|
return ev.getDate().abs();
|
|
10234
10509
|
});
|
|
10235
10510
|
if (half.includes(abs)) {
|
|
@@ -10252,8 +10527,7 @@ const IYYAR = months.IYYAR;
|
|
|
10252
10527
|
* on the following Monday.
|
|
10253
10528
|
* http://www.ushmm.org/remembrance/dor/calendar/
|
|
10254
10529
|
* @private
|
|
10255
|
-
* @param
|
|
10256
|
-
* @return {HDate|null}
|
|
10530
|
+
* @param year
|
|
10257
10531
|
*/
|
|
10258
10532
|
function dateYomHaShoah(year) {
|
|
10259
10533
|
if (year < 5711) {
|
|
@@ -10271,8 +10545,7 @@ function dateYomHaShoah(year) {
|
|
|
10271
10545
|
/**
|
|
10272
10546
|
* Yom HaAtzma'ut only celebrated after 1948
|
|
10273
10547
|
* @private
|
|
10274
|
-
* @param
|
|
10275
|
-
* @return {HDate|null}
|
|
10548
|
+
* @param year
|
|
10276
10549
|
*/
|
|
10277
10550
|
function dateYomHaZikaron(year) {
|
|
10278
10551
|
if (year < 5708) {
|
|
@@ -10304,21 +10577,19 @@ const ykk = 'Yom Kippur Katan';
|
|
|
10304
10577
|
class YomKippurKatanEvent extends HolidayEvent {
|
|
10305
10578
|
/**
|
|
10306
10579
|
* @private
|
|
10307
|
-
* @param
|
|
10308
|
-
* @param
|
|
10580
|
+
* @param date Hebrew date event occurs
|
|
10581
|
+
* @param nextMonthName name of the upcoming month
|
|
10309
10582
|
*/
|
|
10310
10583
|
constructor(date, nextMonthName) {
|
|
10311
10584
|
super(date, `${ykk} ${nextMonthName}`, flags.MINOR_FAST | flags.YOM_KIPPUR_KATAN);
|
|
10312
10585
|
this.nextMonthName = nextMonthName;
|
|
10313
10586
|
this.memo = `Minor Day of Atonement on the day preceeding Rosh Chodesh ${nextMonthName}`;
|
|
10314
10587
|
}
|
|
10315
|
-
/** @return {string} */
|
|
10316
10588
|
basename() {
|
|
10317
10589
|
return this.getDesc();
|
|
10318
10590
|
}
|
|
10319
10591
|
/**
|
|
10320
|
-
* @param
|
|
10321
|
-
* @return {string}
|
|
10592
|
+
* @param [locale] Optional locale name (defaults to active locale).
|
|
10322
10593
|
*/
|
|
10323
10594
|
render(locale) {
|
|
10324
10595
|
const monthName0 = Locale.gettext(this.nextMonthName, locale);
|
|
@@ -10326,13 +10597,11 @@ class YomKippurKatanEvent extends HolidayEvent {
|
|
|
10326
10597
|
return Locale.gettext(ykk, locale) + ' ' + monthName;
|
|
10327
10598
|
}
|
|
10328
10599
|
/**
|
|
10329
|
-
* @param
|
|
10330
|
-
* @return {string}
|
|
10600
|
+
* @param [locale] Optional locale name (defaults to active locale).
|
|
10331
10601
|
*/
|
|
10332
10602
|
renderBrief(locale) {
|
|
10333
10603
|
return Locale.gettext(ykk, locale);
|
|
10334
10604
|
}
|
|
10335
|
-
/** @return {string | undefined} */
|
|
10336
10605
|
url() {
|
|
10337
10606
|
return undefined;
|
|
10338
10607
|
}
|
|
@@ -10385,8 +10654,16 @@ const emojiIsraelFlag = { emoji: '🇮🇱' };
|
|
|
10385
10654
|
const chanukahEmoji = '🕎';
|
|
10386
10655
|
const yearCache = new QuickLRU({ maxSize: 400 });
|
|
10387
10656
|
const KEYCAP_DIGITS = [
|
|
10388
|
-
'0️⃣',
|
|
10389
|
-
'
|
|
10657
|
+
'0️⃣',
|
|
10658
|
+
'1️⃣',
|
|
10659
|
+
'2️⃣',
|
|
10660
|
+
'3️⃣',
|
|
10661
|
+
'4️⃣',
|
|
10662
|
+
'5️⃣',
|
|
10663
|
+
'6️⃣',
|
|
10664
|
+
'7️⃣',
|
|
10665
|
+
'8️⃣',
|
|
10666
|
+
'9️⃣',
|
|
10390
10667
|
];
|
|
10391
10668
|
/**
|
|
10392
10669
|
* Lower-level holidays interface, which returns a `Map` of `Event`s indexed by
|
|
@@ -10441,14 +10718,18 @@ function getHolidaysForYear_(year) {
|
|
|
10441
10718
|
add(new HolidayEvent(new HDate(tzomGedaliahDay, TISHREI$2, year), holidayDesc.TZOM_GEDALIAH, MINOR_FAST$1));
|
|
10442
10719
|
// first SAT after RH
|
|
10443
10720
|
add(new HolidayEvent(new HDate(HDate.dayOnOrBefore(SAT$1, 7 + RH.abs())), holidayDesc.SHABBAT_SHUVA, SPECIAL_SHABBAT$1));
|
|
10444
|
-
const rchTevet = HDate.shortKislev(year)
|
|
10445
|
-
new HDate(1, TEVET, year)
|
|
10721
|
+
const rchTevet = HDate.shortKislev(year)
|
|
10722
|
+
? new HDate(1, TEVET, year)
|
|
10723
|
+
: new HDate(30, KISLEV, year);
|
|
10446
10724
|
add(new HolidayEvent(rchTevet, holidayDesc.CHAG_HABANOT, MINOR_HOLIDAY$1));
|
|
10447
10725
|
// yes, we know Kislev 30-32 are wrong
|
|
10448
10726
|
// HDate() corrects the month automatically
|
|
10449
10727
|
for (let candles = 2; candles <= 8; candles++) {
|
|
10450
10728
|
const hd = new HDate(23 + candles, KISLEV, year);
|
|
10451
|
-
add(new HolidayEvent(hd, `Chanukah: ${candles} Candles`, MINOR_HOLIDAY$1 | CHANUKAH_CANDLES$1, {
|
|
10729
|
+
add(new HolidayEvent(hd, `Chanukah: ${candles} Candles`, MINOR_HOLIDAY$1 | CHANUKAH_CANDLES$1, {
|
|
10730
|
+
chanukahDay: candles - 1,
|
|
10731
|
+
emoji: chanukahEmoji + KEYCAP_DIGITS[candles],
|
|
10732
|
+
}));
|
|
10452
10733
|
}
|
|
10453
10734
|
add(new HolidayEvent(new HDate(32, KISLEV, year), holidayDesc.CHANUKAH_8TH_DAY, MINOR_HOLIDAY$1, { chanukahDay: 8, emoji: chanukahEmoji }));
|
|
10454
10735
|
add(new AsaraBTevetEvent(new HDate(10, TEVET, year), holidayDesc.ASARA_BTEVET, MINOR_FAST$1));
|
|
@@ -10457,9 +10738,9 @@ function getHolidaysForYear_(year) {
|
|
|
10457
10738
|
const haChodeshAbs = HDate.dayOnOrBefore(SAT$1, pesachAbs - 14);
|
|
10458
10739
|
add(new HolidayEvent(new HDate(haChodeshAbs - 7), holidayDesc.SHABBAT_PARAH, SPECIAL_SHABBAT$1), new HolidayEvent(new HDate(haChodeshAbs), holidayDesc.SHABBAT_HACHODESH, SPECIAL_SHABBAT$1), new HolidayEvent(new HDate(HDate.dayOnOrBefore(SAT$1, pesachAbs - 1)), holidayDesc.SHABBAT_HAGADOL, SPECIAL_SHABBAT$1), new HolidayEvent(
|
|
10459
10740
|
// if the fast falls on Shabbat, move to Thursday
|
|
10460
|
-
pesach.prev().getDay() === SAT$1
|
|
10461
|
-
pesach.onOrBefore(THU)
|
|
10462
|
-
new HDate(14, NISAN$1, year), holidayDesc.TAANIT_BECHOROT, MINOR_FAST$1));
|
|
10741
|
+
pesach.prev().getDay() === SAT$1
|
|
10742
|
+
? pesach.onOrBefore(THU)
|
|
10743
|
+
: new HDate(14, NISAN$1, year), holidayDesc.TAANIT_BECHOROT, MINOR_FAST$1));
|
|
10463
10744
|
add(new HolidayEvent(new HDate(HDate.dayOnOrBefore(SAT$1, new HDate(1, TISHREI$2, year + 1).abs() - 4)), holidayDesc.LEIL_SELICHOT, MINOR_HOLIDAY$1, { emoji: '🕍' }));
|
|
10464
10745
|
if (pesach.getDay() === SUN) {
|
|
10465
10746
|
add(new HolidayEvent(new HDate(16, ADAR_II, year), holidayDesc.PURIM_MESHULASH, MINOR_HOLIDAY$1));
|
|
@@ -10489,7 +10770,7 @@ function getHolidaysForYear_(year) {
|
|
|
10489
10770
|
else if (h.satPostponeToSun && dow === SAT$1) {
|
|
10490
10771
|
hd = hd.next();
|
|
10491
10772
|
}
|
|
10492
|
-
const mask = h.chul ? MODERN_HOLIDAY$1 :
|
|
10773
|
+
const mask = h.chul ? MODERN_HOLIDAY$1 : MODERN_HOLIDAY$1 | IL_ONLY$1;
|
|
10493
10774
|
const ev = new HolidayEvent(hd, h.desc, mask);
|
|
10494
10775
|
if (!h.suppressEmoji) {
|
|
10495
10776
|
ev.emoji = '🇮🇱';
|
|
@@ -10517,9 +10798,9 @@ function getHolidaysForYear_(year) {
|
|
|
10517
10798
|
const monthsInYear = HDate.monthsInYear(year);
|
|
10518
10799
|
for (let month = 1; month <= monthsInYear; month++) {
|
|
10519
10800
|
const monthName = HDate.getMonthName(month, year);
|
|
10520
|
-
if ((month === NISAN$1
|
|
10521
|
-
HDate.daysInMonth(HDate.monthsInYear(year - 1), year - 1)
|
|
10522
|
-
HDate.daysInMonth(month - 1, year)) === 30) {
|
|
10801
|
+
if ((month === NISAN$1
|
|
10802
|
+
? HDate.daysInMonth(HDate.monthsInYear(year - 1), year - 1)
|
|
10803
|
+
: HDate.daysInMonth(month - 1, year)) === 30) {
|
|
10523
10804
|
add(new RoshChodeshEvent(new HDate(1, month, year), monthName));
|
|
10524
10805
|
add(new RoshChodeshEvent(new HDate(30, month - 1, year), monthName));
|
|
10525
10806
|
}
|
|
@@ -10534,7 +10815,9 @@ function getHolidaysForYear_(year) {
|
|
|
10534
10815
|
// Yom Kippur Katan is not observed on the day before Rosh Hashanah.
|
|
10535
10816
|
// Not observed prior to Rosh Chodesh Cheshvan because Yom Kippur has just passed.
|
|
10536
10817
|
// Not observed before Rosh Chodesh Tevet, because that day is Hanukkah.
|
|
10537
|
-
if (nextMonth === TISHREI$2 ||
|
|
10818
|
+
if (nextMonth === TISHREI$2 ||
|
|
10819
|
+
nextMonth === months.CHESHVAN ||
|
|
10820
|
+
nextMonth === TEVET) {
|
|
10538
10821
|
continue;
|
|
10539
10822
|
}
|
|
10540
10823
|
let ykk = new HDate(29, month, year);
|
|
@@ -10623,7 +10906,7 @@ function tachanun0(hdate, il, checkNext) {
|
|
|
10623
10906
|
ret.mincha = tmp.shacharit;
|
|
10624
10907
|
}
|
|
10625
10908
|
else {
|
|
10626
|
-
ret.mincha =
|
|
10909
|
+
ret.mincha = dow !== 5;
|
|
10627
10910
|
}
|
|
10628
10911
|
if (ret.allCongs && !ret.mincha && !ret.shacharit) {
|
|
10629
10912
|
return NONE;
|
|
@@ -10645,37 +10928,31 @@ function tachanunYear(year, il) {
|
|
|
10645
10928
|
new HDate(2, months.TISHREI, year), // Rosh Hashana II
|
|
10646
10929
|
].concat(
|
|
10647
10930
|
// Rosh Chodesh - 1st of every month. Also includes RH day 1 (1 Tishrei)
|
|
10648
|
-
range(1, monthsInYear)
|
|
10649
|
-
.map((month) => new HDate(1, month, year)),
|
|
10931
|
+
range(1, monthsInYear).map(month => new HDate(1, month, year)),
|
|
10650
10932
|
// Rosh Chodesh - 30th of months that have one
|
|
10651
10933
|
range(1, monthsInYear)
|
|
10652
|
-
.filter(
|
|
10653
|
-
.map(
|
|
10934
|
+
.filter(month => HDate.daysInMonth(month, year) === 30)
|
|
10935
|
+
.map(month => new HDate(30, month, year)),
|
|
10654
10936
|
// entire month of Nisan
|
|
10655
|
-
range(1, HDate.daysInMonth(months.NISAN, year))
|
|
10656
|
-
.map((mday) => new HDate(mday, months.NISAN, year)), new HDate(18, months.IYYAR, year), // Lag BaOmer
|
|
10937
|
+
range(1, HDate.daysInMonth(months.NISAN, year)).map(mday => new HDate(mday, months.NISAN, year)), new HDate(18, months.IYYAR, year), // Lag BaOmer
|
|
10657
10938
|
// Rosh Chodesh Sivan thru Isru Chag
|
|
10658
|
-
range(1, 8 - (il ? 1 : 0))
|
|
10659
|
-
.map((mday) => new HDate(mday, months.SIVAN, year)), av9dt, // Tisha B'Av
|
|
10939
|
+
range(1, 8 - (il ? 1 : 0)).map(mday => new HDate(mday, months.SIVAN, year)), av9dt, // Tisha B'Av
|
|
10660
10940
|
new HDate(15, months.AV, year), // Tu B'Av
|
|
10661
10941
|
new HDate(29, months.ELUL, year), // Erev Rosh Hashanah
|
|
10662
10942
|
// Erev Yom Kippur thru Isru Chag
|
|
10663
|
-
range(9, 24 - (il ? 1 : 0))
|
|
10664
|
-
.map((mday) => new HDate(mday, months.TISHREI, year)),
|
|
10943
|
+
range(9, 24 - (il ? 1 : 0)).map(mday => new HDate(mday, months.TISHREI, year)),
|
|
10665
10944
|
// Chanukah
|
|
10666
|
-
range(25, 33)
|
|
10667
|
-
.map((mday) => new HDate(mday, months.KISLEV, year)), new HDate(15, months.SHVAT, year), // Tu BiShvat
|
|
10945
|
+
range(25, 33).map(mday => new HDate(mday, months.KISLEV, year)), new HDate(15, months.SHVAT, year), // Tu BiShvat
|
|
10668
10946
|
new HDate(14, months.ADAR_II, year), // Purim
|
|
10669
|
-
shushPurim, leap ? new HDate(14, months.ADAR_I, year) : []
|
|
10947
|
+
shushPurim, leap ? new HDate(14, months.ADAR_I, year) : [] // Purim Katan
|
|
10948
|
+
);
|
|
10670
10949
|
const some = [
|
|
10671
10950
|
new HDate(14, months.IYYAR, year), // Pesach Sheini
|
|
10672
10951
|
].concat(
|
|
10673
10952
|
// Until 14 Sivan
|
|
10674
|
-
range(1, 13)
|
|
10675
|
-
.map((mday) => new HDate(mday, months.SIVAN, year)),
|
|
10953
|
+
range(1, 13).map(mday => new HDate(mday, months.SIVAN, year)),
|
|
10676
10954
|
// Until after Rosh Chodesh Cheshvan
|
|
10677
|
-
range(20, 31)
|
|
10678
|
-
.map((mday) => new HDate(mday, months.TISHREI, year)),
|
|
10955
|
+
range(20, 31).map(mday => new HDate(mday, months.TISHREI, year)),
|
|
10679
10956
|
// Yom HaAtzma'ut, which changes based on day of week
|
|
10680
10957
|
year >= 5708 ? dateYomHaZikaron(year).next() : [],
|
|
10681
10958
|
// Yom Yerushalayim
|
|
@@ -10686,9 +10963,9 @@ function tachanunYear(year, il) {
|
|
|
10686
10963
|
new HDate(14, months.IYYAR, year), // Pesach Sheini
|
|
10687
10964
|
];
|
|
10688
10965
|
return {
|
|
10689
|
-
none: none.map(
|
|
10690
|
-
some: some.map(
|
|
10691
|
-
yesPrev: yesPrev.map(
|
|
10966
|
+
none: none.map(hd => hd.abs()).sort((a, b) => a - b),
|
|
10967
|
+
some: some.map(hd => hd.abs()).sort((a, b) => a - b),
|
|
10968
|
+
yesPrev: yesPrev.map(hd => hd.abs()).sort((a, b) => a - b),
|
|
10692
10969
|
};
|
|
10693
10970
|
}
|
|
10694
10971
|
|
|
@@ -10698,10 +10975,10 @@ const TISHREI$1 = months.TISHREI;
|
|
|
10698
10975
|
* @private
|
|
10699
10976
|
*/
|
|
10700
10977
|
function getAbs(d) {
|
|
10701
|
-
if (typeof d
|
|
10978
|
+
if (typeof d === 'number')
|
|
10702
10979
|
return d;
|
|
10703
|
-
if (
|
|
10704
|
-
return
|
|
10980
|
+
if (isDate(d))
|
|
10981
|
+
return greg2abs(d);
|
|
10705
10982
|
if (HDate.isHDate(d))
|
|
10706
10983
|
return d.abs();
|
|
10707
10984
|
throw new TypeError(`Invalid date type: ${d}`);
|
|
@@ -10710,8 +10987,9 @@ function getYear(options) {
|
|
|
10710
10987
|
if (typeof options.year !== 'undefined') {
|
|
10711
10988
|
return Number(options.year);
|
|
10712
10989
|
}
|
|
10713
|
-
return options.isHebrewYear
|
|
10714
|
-
new
|
|
10990
|
+
return options.isHebrewYear
|
|
10991
|
+
? new HDate().getFullYear()
|
|
10992
|
+
: new Date().getFullYear();
|
|
10715
10993
|
}
|
|
10716
10994
|
/**
|
|
10717
10995
|
* Parse options object to determine start & end days
|
|
@@ -10758,10 +11036,10 @@ function startEndGregorian(theMonth, theYear, numYears) {
|
|
|
10758
11036
|
if (theYear < 100) {
|
|
10759
11037
|
startGreg.setFullYear(theYear);
|
|
10760
11038
|
}
|
|
10761
|
-
const startAbs =
|
|
11039
|
+
const startAbs = greg2abs(startGreg);
|
|
10762
11040
|
let endAbs;
|
|
10763
11041
|
if (theMonth) {
|
|
10764
|
-
endAbs = startAbs +
|
|
11042
|
+
endAbs = startAbs + daysInGregMonth(theMonth, theYear) - 1;
|
|
10765
11043
|
}
|
|
10766
11044
|
else {
|
|
10767
11045
|
const endYear = theYear + numYears;
|
|
@@ -10769,16 +11047,16 @@ function startEndGregorian(theMonth, theYear, numYears) {
|
|
|
10769
11047
|
if (endYear < 100) {
|
|
10770
11048
|
endGreg.setFullYear(endYear);
|
|
10771
11049
|
}
|
|
10772
|
-
endAbs =
|
|
11050
|
+
endAbs = greg2abs(endGreg) - 1;
|
|
10773
11051
|
}
|
|
10774
11052
|
return [startAbs, endAbs];
|
|
10775
11053
|
}
|
|
10776
11054
|
function startEndHebrew(theMonth, theYear, numYears) {
|
|
10777
11055
|
const startDate = new HDate(1, theMonth || TISHREI$1, theYear);
|
|
10778
11056
|
let startAbs = startDate.abs();
|
|
10779
|
-
const endAbs = theMonth
|
|
10780
|
-
startAbs + startDate.daysInMonth()
|
|
10781
|
-
new HDate(1, TISHREI$1, theYear + numYears).abs() - 1;
|
|
11057
|
+
const endAbs = theMonth
|
|
11058
|
+
? startAbs + startDate.daysInMonth()
|
|
11059
|
+
: new HDate(1, TISHREI$1, theYear + numYears).abs() - 1;
|
|
10782
11060
|
// for full Hebrew year, start on Erev Rosh Hashana which
|
|
10783
11061
|
// is technically in the previous Hebrew year
|
|
10784
11062
|
// (but conveniently lets us get candle-lighting time for Erev)
|
|
@@ -10876,19 +11154,20 @@ const RECOGNIZED_OPTIONS = {
|
|
|
10876
11154
|
*/
|
|
10877
11155
|
function warnUnrecognizedOptions(options) {
|
|
10878
11156
|
for (const k of Object.keys(options)) {
|
|
10879
|
-
if (typeof RECOGNIZED_OPTIONS[k] === 'undefined' &&
|
|
11157
|
+
if (typeof RECOGNIZED_OPTIONS[k] === 'undefined' &&
|
|
11158
|
+
!unrecognizedAlreadyWarned.has(k)) {
|
|
10880
11159
|
console.warn(`Ignoring unrecognized HebrewCalendar option: ${k}`);
|
|
10881
11160
|
unrecognizedAlreadyWarned.add(k);
|
|
10882
11161
|
}
|
|
10883
11162
|
}
|
|
10884
11163
|
}
|
|
10885
11164
|
const israelCityOffset = {
|
|
10886
|
-
|
|
10887
|
-
|
|
10888
|
-
|
|
10889
|
-
|
|
11165
|
+
Jerusalem: 40,
|
|
11166
|
+
Haifa: 30,
|
|
11167
|
+
"Zikhron Ya'aqov": 30,
|
|
11168
|
+
"Zikhron Ya'akov": 30,
|
|
10890
11169
|
'Zikhron Yaakov': 30,
|
|
10891
|
-
|
|
11170
|
+
"Zichron Ya'akov": 30,
|
|
10892
11171
|
'Zichron Yaakov': 30,
|
|
10893
11172
|
};
|
|
10894
11173
|
const geoIdCandleOffset = {
|
|
@@ -10918,7 +11197,6 @@ const TZEIT_3MEDIUM_STARS = 7.0833333;
|
|
|
10918
11197
|
/**
|
|
10919
11198
|
* Modifies options in-place
|
|
10920
11199
|
* @private
|
|
10921
|
-
* @param {CalOptions} options
|
|
10922
11200
|
*/
|
|
10923
11201
|
function checkCandleOptions(options) {
|
|
10924
11202
|
if (!options.candlelighting) {
|
|
@@ -10928,7 +11206,8 @@ function checkCandleOptions(options) {
|
|
|
10928
11206
|
if (typeof location === 'undefined' || !(location instanceof Location)) {
|
|
10929
11207
|
throw new TypeError('options.candlelighting requires valid options.location');
|
|
10930
11208
|
}
|
|
10931
|
-
if (typeof options.havdalahMins === 'number' &&
|
|
11209
|
+
if (typeof options.havdalahMins === 'number' &&
|
|
11210
|
+
typeof options.havdalahDeg === 'number') {
|
|
10932
11211
|
throw new TypeError('options.havdalahMins and options.havdalahDeg are mutually exclusive');
|
|
10933
11212
|
}
|
|
10934
11213
|
let min = Number(options.candleLightingMins) || 18;
|
|
@@ -10969,8 +11248,6 @@ function overrideIsraelCandleMins(location, min) {
|
|
|
10969
11248
|
/**
|
|
10970
11249
|
* Mask to filter Holiday array
|
|
10971
11250
|
* @private
|
|
10972
|
-
* @param {CalOptions} options
|
|
10973
|
-
* @return {number}
|
|
10974
11251
|
*/
|
|
10975
11252
|
function getMaskFromOptions(options) {
|
|
10976
11253
|
var _a;
|
|
@@ -10981,9 +11258,19 @@ function getMaskFromOptions(options) {
|
|
|
10981
11258
|
let mask = 0;
|
|
10982
11259
|
// default options
|
|
10983
11260
|
if (!options.noHolidays) {
|
|
10984
|
-
mask |=
|
|
10985
|
-
|
|
10986
|
-
|
|
11261
|
+
mask |=
|
|
11262
|
+
ROSH_CHODESH |
|
|
11263
|
+
YOM_TOV_ENDS |
|
|
11264
|
+
MINOR_FAST |
|
|
11265
|
+
SPECIAL_SHABBAT |
|
|
11266
|
+
MODERN_HOLIDAY |
|
|
11267
|
+
MAJOR_FAST |
|
|
11268
|
+
MINOR_HOLIDAY |
|
|
11269
|
+
EREV |
|
|
11270
|
+
CHOL_HAMOED |
|
|
11271
|
+
LIGHT_CANDLES |
|
|
11272
|
+
LIGHT_CANDLES_TZEIS |
|
|
11273
|
+
CHANUKAH_CANDLES;
|
|
10987
11274
|
}
|
|
10988
11275
|
if (options.candlelighting) {
|
|
10989
11276
|
mask |= LIGHT_CANDLES | LIGHT_CANDLES_TZEIS | YOM_TOV_ENDS;
|
|
@@ -11038,15 +11325,10 @@ function getMaskFromOptions(options) {
|
|
|
11038
11325
|
}
|
|
11039
11326
|
return mask;
|
|
11040
11327
|
}
|
|
11041
|
-
const MASK_LIGHT_CANDLES = LIGHT_CANDLES |
|
|
11042
|
-
LIGHT_CANDLES_TZEIS |
|
|
11043
|
-
CHANUKAH_CANDLES |
|
|
11044
|
-
YOM_TOV_ENDS;
|
|
11328
|
+
const MASK_LIGHT_CANDLES = LIGHT_CANDLES | LIGHT_CANDLES_TZEIS | CHANUKAH_CANDLES | YOM_TOV_ENDS;
|
|
11045
11329
|
const defaultLocation = new Location(0, 0, false, 'UTC');
|
|
11046
11330
|
/**
|
|
11047
11331
|
* @private
|
|
11048
|
-
* @param {CalOptions} options
|
|
11049
|
-
* @return {number}
|
|
11050
11332
|
*/
|
|
11051
11333
|
function setOptionsFromMask(options) {
|
|
11052
11334
|
const m = options.mask || 0;
|
|
@@ -11085,16 +11367,12 @@ function setOptionsFromMask(options) {
|
|
|
11085
11367
|
}
|
|
11086
11368
|
/**
|
|
11087
11369
|
* @private
|
|
11088
|
-
* @param {Event} ev
|
|
11089
|
-
* @return {boolean}
|
|
11090
11370
|
*/
|
|
11091
11371
|
function observedInIsrael(ev) {
|
|
11092
11372
|
return ev.observedInIsrael();
|
|
11093
11373
|
}
|
|
11094
11374
|
/**
|
|
11095
11375
|
* @private
|
|
11096
|
-
* @param {Event} ev
|
|
11097
|
-
* @return {boolean}
|
|
11098
11376
|
*/
|
|
11099
11377
|
function observedInDiaspora(ev) {
|
|
11100
11378
|
return ev.observedInDiaspora();
|
|
@@ -11106,6 +11384,7 @@ function observedInDiaspora(ev) {
|
|
|
11106
11384
|
* Event names can be rendered in several languges using the `locale` option.
|
|
11107
11385
|
*/
|
|
11108
11386
|
class HebrewCalendar {
|
|
11387
|
+
constructor() { }
|
|
11109
11388
|
/**
|
|
11110
11389
|
* Calculates holidays and other Hebrew calendar events based on {@link CalOptions}.
|
|
11111
11390
|
*
|
|
@@ -11212,21 +11491,21 @@ class HebrewCalendar {
|
|
|
11212
11491
|
* const date = hd.greg();
|
|
11213
11492
|
* console.log(date.toLocaleDateString(), ev.render('en'), hd.toString());
|
|
11214
11493
|
* }
|
|
11215
|
-
* @param {CalOptions} [options={}]
|
|
11216
|
-
* @return {Event[]}
|
|
11217
11494
|
*/
|
|
11218
11495
|
static calendar(options = {}) {
|
|
11219
11496
|
options = Object.assign({}, options); // so we can modify freely
|
|
11220
11497
|
checkCandleOptions(options);
|
|
11221
|
-
const location = options.location = options.location || defaultLocation;
|
|
11222
|
-
const il = options.il = options.il || location.getIsrael() || false;
|
|
11498
|
+
const location = (options.location = options.location || defaultLocation);
|
|
11499
|
+
const il = (options.il = options.il || location.getIsrael() || false);
|
|
11223
11500
|
const hasUserMask = typeof options.mask === 'number';
|
|
11224
11501
|
options.mask = getMaskFromOptions(options);
|
|
11225
11502
|
if (options.ashkenazi || options.locale) {
|
|
11226
11503
|
if (options.locale && typeof options.locale !== 'string') {
|
|
11227
11504
|
throw new TypeError(`Invalid options.locale: ${options.locale}`);
|
|
11228
11505
|
}
|
|
11229
|
-
const locale = options.ashkenazi
|
|
11506
|
+
const locale = options.ashkenazi
|
|
11507
|
+
? 'ashkenazi'
|
|
11508
|
+
: options.locale;
|
|
11230
11509
|
const translationObj = Locale.useLocale(locale);
|
|
11231
11510
|
if (!translationObj) {
|
|
11232
11511
|
throw new TypeError(`Locale '${locale}' not found; did you forget to import @hebcal/locales?`);
|
|
@@ -11245,14 +11524,14 @@ class HebrewCalendar {
|
|
|
11245
11524
|
warnUnrecognizedOptions(options);
|
|
11246
11525
|
const startAbs = startAndEnd[0];
|
|
11247
11526
|
const endAbs = startAndEnd[1];
|
|
11248
|
-
const startGreg =
|
|
11527
|
+
const startGreg = abs2greg(startAbs);
|
|
11249
11528
|
if (startGreg.getFullYear() < 100) {
|
|
11250
11529
|
options.candlelighting = false;
|
|
11251
11530
|
}
|
|
11252
11531
|
for (let abs = startAbs; abs <= endAbs; abs++) {
|
|
11253
11532
|
const hd = new HDate(abs);
|
|
11254
11533
|
const hyear = hd.getFullYear();
|
|
11255
|
-
if (hyear
|
|
11534
|
+
if (hyear !== currentYear) {
|
|
11256
11535
|
currentYear = hyear;
|
|
11257
11536
|
holidaysYear = getHolidaysForYear_(currentYear);
|
|
11258
11537
|
if (options.sedrot) {
|
|
@@ -11299,16 +11578,17 @@ class HebrewCalendar {
|
|
|
11299
11578
|
}
|
|
11300
11579
|
}
|
|
11301
11580
|
// suppress Havdalah when options.havdalahMins=0 or options.havdalahDeg=0
|
|
11302
|
-
if (candlesEv instanceof HavdalahEvent &&
|
|
11581
|
+
if (candlesEv instanceof HavdalahEvent &&
|
|
11582
|
+
(options.havdalahMins === 0 || options.havdalahDeg === 0)) {
|
|
11303
11583
|
candlesEv = undefined;
|
|
11304
11584
|
}
|
|
11305
11585
|
if (candlesEv) {
|
|
11306
11586
|
evts.push(candlesEv);
|
|
11307
11587
|
}
|
|
11308
11588
|
if (options.addHebrewDates ||
|
|
11309
|
-
(options.addHebrewDatesForEvents && prevEventsLength
|
|
11589
|
+
(options.addHebrewDatesForEvents && prevEventsLength !== evts.length)) {
|
|
11310
11590
|
const e2 = new HebrewDateEvent(hd);
|
|
11311
|
-
if (prevEventsLength
|
|
11591
|
+
if (prevEventsLength === evts.length) {
|
|
11312
11592
|
evts.push(e2);
|
|
11313
11593
|
}
|
|
11314
11594
|
else {
|
|
@@ -11340,9 +11620,9 @@ class HebrewCalendar {
|
|
|
11340
11620
|
* const dt = new Date(2014, 2, 2); // '2014-03-02' == '30 Adar I 5774'
|
|
11341
11621
|
* const hd = HebrewCalendar.getBirthdayOrAnniversary(5780, dt); // '1 Nisan 5780'
|
|
11342
11622
|
* console.log(hd.greg().toLocaleDateString('en-US')); // '3/26/2020'
|
|
11343
|
-
* @param
|
|
11344
|
-
* @param
|
|
11345
|
-
* @
|
|
11623
|
+
* @param hyear Hebrew year
|
|
11624
|
+
* @param gdate Gregorian or Hebrew date of event
|
|
11625
|
+
* @returns anniversary occurring in `hyear`
|
|
11346
11626
|
*/
|
|
11347
11627
|
static getBirthdayOrAnniversary(hyear, gdate) {
|
|
11348
11628
|
const dt = getBirthdayHD(hyear, gdate);
|
|
@@ -11381,9 +11661,9 @@ class HebrewCalendar {
|
|
|
11381
11661
|
* const dt = new Date(2014, 2, 2); // '2014-03-02' == '30 Adar I 5774'
|
|
11382
11662
|
* const hd = HebrewCalendar.getYahrzeit(5780, dt); // '30 Sh\'vat 5780'
|
|
11383
11663
|
* console.log(hd.greg().toLocaleDateString('en-US')); // '2/25/2020'
|
|
11384
|
-
* @param
|
|
11385
|
-
* @param
|
|
11386
|
-
* @
|
|
11664
|
+
* @param hyear Hebrew year
|
|
11665
|
+
* @param gdate Gregorian or Hebrew date of death
|
|
11666
|
+
* @returns anniversary occurring in hyear
|
|
11387
11667
|
*/
|
|
11388
11668
|
static getYahrzeit(hyear, gdate) {
|
|
11389
11669
|
const dt = getYahrzeitHD(hyear, gdate);
|
|
@@ -11396,18 +11676,15 @@ class HebrewCalendar {
|
|
|
11396
11676
|
* Lower-level holidays interface, which returns a `Map` of `Event`s indexed by
|
|
11397
11677
|
* `HDate.toString()`. These events must filtered especially for `flags.IL_ONLY`
|
|
11398
11678
|
* or `flags.CHUL_ONLY` depending on Israel vs. Diaspora holiday scheme.
|
|
11399
|
-
* @
|
|
11400
|
-
* @param {number} year Hebrew year
|
|
11401
|
-
* @return {HolidayYearMap}
|
|
11679
|
+
* @param year Hebrew year
|
|
11402
11680
|
*/
|
|
11403
11681
|
static getHolidaysForYear(year) {
|
|
11404
11682
|
return getHolidaysForYear_(year);
|
|
11405
11683
|
}
|
|
11406
11684
|
/**
|
|
11407
11685
|
* Returns an array of holidays for the year
|
|
11408
|
-
* @param
|
|
11409
|
-
* @param
|
|
11410
|
-
* @return {HolidayEvent[]}
|
|
11686
|
+
* @param year Hebrew year
|
|
11687
|
+
* @param il use the Israeli schedule for holidays
|
|
11411
11688
|
*/
|
|
11412
11689
|
static getHolidaysForYearArray(year, il) {
|
|
11413
11690
|
const yearMap = getHolidaysForYear_(year);
|
|
@@ -11427,9 +11704,8 @@ class HebrewCalendar {
|
|
|
11427
11704
|
}
|
|
11428
11705
|
/**
|
|
11429
11706
|
* Returns an array of Events on this date (or `undefined` if no events)
|
|
11430
|
-
* @param
|
|
11431
|
-
* @param
|
|
11432
|
-
* @return {HolidayEvent[] | undefined}
|
|
11707
|
+
* @param date Hebrew Date, Gregorian date, or absolute R.D. day number
|
|
11708
|
+
* @param [il] use the Israeli schedule for holidays
|
|
11433
11709
|
*/
|
|
11434
11710
|
static getHolidaysOnDate(date, il) {
|
|
11435
11711
|
const hd = HDate.isHDate(date) ? date : new HDate(date);
|
|
@@ -11446,9 +11722,6 @@ class HebrewCalendar {
|
|
|
11446
11722
|
}
|
|
11447
11723
|
/**
|
|
11448
11724
|
* Eruv Tavshilin
|
|
11449
|
-
* @param {Date | HDate} date
|
|
11450
|
-
* @param {boolean} il
|
|
11451
|
-
* @return {boolean}
|
|
11452
11725
|
*/
|
|
11453
11726
|
static eruvTavshilin(date, il) {
|
|
11454
11727
|
if (date.getDay() < 3 || date.getDay() > 4) {
|
|
@@ -11468,25 +11741,19 @@ class HebrewCalendar {
|
|
|
11468
11741
|
* locale.
|
|
11469
11742
|
* If `options.hour12` is `false`, locale is ignored and always returns 24-hour time.
|
|
11470
11743
|
* If `options.hour12` is `true`, locale is ignored and always returns 12-hour time.
|
|
11471
|
-
* @param
|
|
11472
|
-
* @param
|
|
11473
|
-
* @param
|
|
11474
|
-
* @return {string}
|
|
11744
|
+
* @param timeStr - original time like "20:30"
|
|
11745
|
+
* @param suffix - "p" or "pm" or " P.M.". Add leading space if you want it
|
|
11746
|
+
* @param options
|
|
11475
11747
|
*/
|
|
11476
11748
|
static reformatTimeStr(timeStr, suffix, options) {
|
|
11477
11749
|
return reformatTimeStr(timeStr, suffix, options);
|
|
11478
11750
|
}
|
|
11479
|
-
/** @return {string} */
|
|
11480
11751
|
static version() {
|
|
11481
11752
|
return version;
|
|
11482
11753
|
}
|
|
11483
11754
|
/**
|
|
11484
11755
|
* Convenience function to create an instance of `Sedra` or reuse a previously
|
|
11485
11756
|
* created and cached instance.
|
|
11486
|
-
* @function
|
|
11487
|
-
* @param {number} hyear
|
|
11488
|
-
* @param {boolean} il
|
|
11489
|
-
* @return {Sedra}
|
|
11490
11757
|
*/
|
|
11491
11758
|
static getSedra(hyear, il) {
|
|
11492
11759
|
return getSedra_(hyear, il);
|
|
@@ -11504,10 +11771,6 @@ class HebrewCalendar {
|
|
|
11504
11771
|
* 0 - No Hallel
|
|
11505
11772
|
* 1 - Half Hallel
|
|
11506
11773
|
* 2 - Whole Hallel
|
|
11507
|
-
*
|
|
11508
|
-
* @param {HDate} hdate
|
|
11509
|
-
* @param {boolean} il
|
|
11510
|
-
* @return {number}
|
|
11511
11774
|
*/
|
|
11512
11775
|
static hallel(hdate, il) {
|
|
11513
11776
|
const events = HebrewCalendar.getHolidaysForYearArray(hdate.getFullYear(), il);
|
|
@@ -11528,9 +11791,6 @@ class HebrewCalendar {
|
|
|
11528
11791
|
* Tachanun is not said at Mincha on days before it is not said at Shacharit.
|
|
11529
11792
|
*
|
|
11530
11793
|
* Tachanun is not said at Shacharit on Shabbat, but is at Mincha, usually.
|
|
11531
|
-
* @param {HDate} hdate
|
|
11532
|
-
* @param {boolean} il
|
|
11533
|
-
* @return {TachanunResult}
|
|
11534
11794
|
*/
|
|
11535
11795
|
static tachanun(hdate, il) {
|
|
11536
11796
|
return tachanun_(hdate, il);
|
|
@@ -11538,13 +11798,10 @@ class HebrewCalendar {
|
|
|
11538
11798
|
}
|
|
11539
11799
|
/**
|
|
11540
11800
|
* @private
|
|
11541
|
-
* @param {HDate} date
|
|
11542
|
-
* @param {boolean} il
|
|
11543
|
-
* @return {boolean}
|
|
11544
11801
|
*/
|
|
11545
11802
|
function isChag(date, il) {
|
|
11546
11803
|
const events = HebrewCalendar.getHolidaysOnDate(date, il) || [];
|
|
11547
|
-
const chag = events.filter(
|
|
11804
|
+
const chag = events.filter(ev => ev.getFlags() & flags.CHAG);
|
|
11548
11805
|
return chag.length !== 0;
|
|
11549
11806
|
}
|
|
11550
11807
|
/**
|
|
@@ -11558,19 +11815,20 @@ function appendHolidayAndRelated(candlesEv, events, ev, options, isFriday, isSat
|
|
|
11558
11815
|
return candlesEv; // holiday isn't observed here; bail out early
|
|
11559
11816
|
}
|
|
11560
11817
|
const eFlags = ev.getFlags();
|
|
11561
|
-
if ((!options.yomKippurKatan &&
|
|
11562
|
-
(options.noModern &&
|
|
11818
|
+
if ((!options.yomKippurKatan && eFlags & YOM_KIPPUR_KATAN) ||
|
|
11819
|
+
(options.noModern && eFlags & MODERN_HOLIDAY)) {
|
|
11563
11820
|
return candlesEv; // bail out early
|
|
11564
11821
|
}
|
|
11565
11822
|
const isMajorFast = Boolean(eFlags & MAJOR_FAST);
|
|
11566
11823
|
const isMinorFast = Boolean(eFlags & MINOR_FAST);
|
|
11567
11824
|
if (options.candlelighting && (isMajorFast || isMinorFast)) {
|
|
11568
11825
|
ev = makeFastStartEnd(ev, options);
|
|
11569
|
-
if (ev.startEvent &&
|
|
11826
|
+
if (ev.startEvent &&
|
|
11827
|
+
(isMajorFast || (isMinorFast && !options.noMinorFast))) {
|
|
11570
11828
|
events.push(ev.startEvent);
|
|
11571
11829
|
}
|
|
11572
11830
|
}
|
|
11573
|
-
if (
|
|
11831
|
+
if (eFlags & Number(options.mask) || (!eFlags && !hasUserMask)) {
|
|
11574
11832
|
if (options.candlelighting && eFlags & MASK_LIGHT_CANDLES) {
|
|
11575
11833
|
const hd = ev.getDate();
|
|
11576
11834
|
candlesEv = makeCandleEvent(ev, hd, options, isFriday, isSaturday);
|
|
@@ -11588,7 +11846,8 @@ function appendHolidayAndRelated(candlesEv, events, ev, options, isFriday, isSat
|
|
|
11588
11846
|
candlesEv = undefined;
|
|
11589
11847
|
}
|
|
11590
11848
|
}
|
|
11591
|
-
if (!options.noHolidays ||
|
|
11849
|
+
if (!options.noHolidays ||
|
|
11850
|
+
(options.yomKippurKatan && eFlags & YOM_KIPPUR_KATAN)) {
|
|
11592
11851
|
events.push(ev); // the original event itself
|
|
11593
11852
|
}
|
|
11594
11853
|
}
|
|
@@ -11601,9 +11860,9 @@ function makeMoladAndMevarchimChodesh(hd, options) {
|
|
|
11601
11860
|
const evts = [];
|
|
11602
11861
|
const hmonth = hd.getMonth();
|
|
11603
11862
|
const hdate = hd.getDate();
|
|
11604
|
-
if (hmonth
|
|
11863
|
+
if (hmonth !== ELUL && hdate >= 23 && hdate <= 29) {
|
|
11605
11864
|
const hyear = hd.getFullYear();
|
|
11606
|
-
const monNext =
|
|
11865
|
+
const monNext = hmonth === HDate.monthsInYear(hyear) ? NISAN : hmonth + 1;
|
|
11607
11866
|
if (options.molad) {
|
|
11608
11867
|
evts.push(new MoladEvent(hd, hyear, monNext, options));
|
|
11609
11868
|
}
|
|
@@ -11678,3 +11937,4 @@ exports.holidayDesc = holidayDesc;
|
|
|
11678
11937
|
exports.months = months;
|
|
11679
11938
|
exports.parshiot = parshiot;
|
|
11680
11939
|
exports.version = version;
|
|
11940
|
+
//# sourceMappingURL=index.cjs.map
|