@hebcal/core 6.0.6 → 6.0.7
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 +42 -27
- package/dist/bundle.js +13 -8
- package/dist/bundle.js.map +1 -1
- package/dist/bundle.min.js +3 -3
- package/dist/bundle.min.js.map +1 -1
- package/dist/esm/DailyLearning.js +1 -1
- package/dist/esm/HebrewDateEvent.js +1 -1
- package/dist/esm/HolidayEvent.js +1 -1
- package/dist/esm/MevarchimChodeshEvent.js +1 -1
- package/dist/esm/ParshaEvent.js +1 -1
- package/dist/esm/TimedEvent.js +1 -1
- package/dist/esm/YomKippurKatanEvent.js +1 -1
- package/dist/esm/ashkenazi.po.js +1 -1
- package/dist/esm/calendar.js +1 -1
- package/dist/esm/candles.js +1 -1
- package/dist/esm/event.js +1 -1
- package/dist/esm/getStartAndEnd.js +1 -1
- package/dist/esm/hallel.js +1 -1
- package/dist/esm/he-x-NoNikud.po.d.ts +2 -0
- package/dist/esm/he-x-NoNikud.po.js +2 -2
- package/dist/esm/he-x-NoNikud.po.js.map +1 -1
- package/dist/esm/he.po.d.ts +1 -0
- package/dist/esm/he.po.js +2 -2
- package/dist/esm/he.po.js.map +1 -1
- package/dist/esm/hebcal.js +1 -1
- package/dist/esm/holidays.js +1 -1
- package/dist/esm/index.js +1 -1
- package/dist/esm/isAssurBemlacha.js +1 -1
- package/dist/esm/locale.js +1 -1
- package/dist/esm/location.js +2 -2
- package/dist/esm/location.js.map +1 -1
- package/dist/esm/modern.js +1 -1
- package/dist/esm/molad.js +1 -1
- package/dist/esm/omer.js +1 -1
- package/dist/esm/parshaName.js +1 -1
- package/dist/esm/parshaYear.d.ts +2 -2
- package/dist/esm/parshaYear.js +1 -1
- package/dist/esm/parshaYear.js.map +1 -1
- package/dist/esm/pkgVersion.d.ts +1 -1
- package/dist/esm/pkgVersion.js +2 -2
- package/dist/esm/pkgVersion.js.map +1 -1
- package/dist/esm/reformatTimeStr.js +1 -1
- package/dist/esm/sedra.d.ts +5 -1
- package/dist/esm/sedra.js +9 -3
- package/dist/esm/sedra.js.map +1 -1
- package/dist/esm/staticHolidays.js +1 -2
- package/dist/esm/staticHolidays.js.map +1 -1
- package/dist/esm/tachanun.js +1 -1
- package/dist/esm/zmanim.js +1 -1
- package/dist/he-x-NoNikud.po.d.ts +2 -0
- package/dist/he.po.d.ts +1 -0
- package/dist/parshaYear.d.ts +2 -2
- package/dist/pkgVersion.d.ts +1 -1
- package/dist/po2json.d.ts +1 -0
- package/dist/po2json.js +41 -0
- package/dist/sedra.d.ts +5 -1
- package/dist/size-demo/dist/getHoliday.d.ts +1944 -0
- package/dist/size-demo/dist/getHoliday.js +3712 -0
- package/dist/size-demo/dist/parshiyot.js +10662 -0
- package/dist/size-demo/dist/sedra.d.ts +1411 -0
- package/dist/size-demo/dist/sedra.js +2359 -0
- package/dist/size-demo/dist/tachanun.d.ts +1015 -0
- package/dist/size-demo/dist/tachanun.js +1755 -0
- package/dist/size-demo/getHoliday.d.ts +1 -0
- package/dist/size-demo/getHoliday.js +3 -0
- package/dist/size-demo/parshiyot.d.ts +1 -0
- package/dist/size-demo/parshiyot.js +11 -0
- package/dist/size-demo/rollup.config.d.ts +3 -0
- package/dist/size-demo/rollup.config.js +47 -0
- package/dist/size-demo/sedra.d.ts +1 -0
- package/dist/size-demo/sedra.js +3 -0
- package/dist/size-demo/tachanun.d.ts +1 -0
- package/dist/size-demo/tachanun.js +3 -0
- package/dist/src/CalOptions.d.ts +168 -0
- package/dist/src/CalOptions.js +1 -0
- package/dist/src/DailyLearning.d.ts +32 -0
- package/dist/src/DailyLearning.js +55 -0
- package/dist/src/HebrewDateEvent.d.ts +37 -0
- package/dist/src/HebrewDateEvent.js +72 -0
- package/dist/src/HolidayEvent.d.ts +83 -0
- package/dist/src/HolidayEvent.js +186 -0
- package/dist/src/MevarchimChodeshEvent.d.ts +26 -0
- package/dist/src/MevarchimChodeshEvent.js +50 -0
- package/dist/src/ParshaEvent.d.ts +19 -0
- package/dist/src/ParshaEvent.js +43 -0
- package/dist/src/TimedEvent.d.ts +47 -0
- package/dist/src/TimedEvent.js +92 -0
- package/dist/src/YomKippurKatanEvent.d.ts +23 -0
- package/dist/src/YomKippurKatanEvent.js +38 -0
- package/dist/src/ashkenazi.po.d.ts +70 -0
- package/dist/src/ashkenazi.po.js +1 -0
- package/dist/src/calendar.d.ts +111 -0
- package/dist/src/calendar.js +660 -0
- package/dist/src/candles.d.ts +44 -0
- package/dist/src/candles.js +163 -0
- package/dist/src/event.d.ts +188 -0
- package/dist/src/event.js +233 -0
- package/dist/src/getStartAndEnd.d.ts +6 -0
- package/dist/src/getStartAndEnd.js +97 -0
- package/dist/src/hallel.d.ts +6 -0
- package/dist/src/hallel.js +47 -0
- package/dist/src/he-x-NoNikud.po.d.ts +15 -0
- package/dist/src/he-x-NoNikud.po.js +1 -0
- package/dist/src/he.po.d.ts +195 -0
- package/dist/src/he.po.js +1 -0
- package/dist/src/hebcal.d.ts +260 -0
- package/dist/src/hebcal.js +332 -0
- package/dist/src/holidays.d.ts +22 -0
- package/dist/src/holidays.js +288 -0
- package/dist/src/index.d.ts +26 -0
- package/dist/src/index.js +24 -0
- package/dist/src/isAssurBemlacha.d.ts +9 -0
- package/dist/src/isAssurBemlacha.js +62 -0
- package/dist/src/locale.d.ts +2 -0
- package/dist/src/locale.js +11 -0
- package/dist/src/location.d.ts +73 -0
- package/dist/src/location.js +306 -0
- package/dist/src/modern.d.ts +18 -0
- package/dist/src/modern.js +59 -0
- package/dist/src/molad.d.ts +62 -0
- package/dist/src/molad.js +169 -0
- package/dist/src/omer.d.ts +53 -0
- package/dist/src/omer.js +302 -0
- package/dist/src/parshaName.d.ts +2 -0
- package/dist/src/parshaName.js +13 -0
- package/dist/src/parshaYear.d.ts +9 -0
- package/dist/src/parshaYear.js +24 -0
- package/dist/src/pkgVersion.d.ts +2 -0
- package/dist/src/pkgVersion.js +2 -0
- package/dist/src/reformatTimeStr.d.ts +8 -0
- package/dist/src/reformatTimeStr.js +48 -0
- package/dist/src/sedra.d.ts +95 -0
- package/dist/src/sedra.js +477 -0
- package/dist/src/staticHolidays.d.ts +176 -0
- package/dist/src/staticHolidays.js +614 -0
- package/dist/src/tachanun.d.ts +29 -0
- package/dist/src/tachanun.js +120 -0
- package/dist/src/zmanim.d.ts +347 -0
- package/dist/src/zmanim.js +579 -0
- package/dist/version.d.ts +1 -0
- package/dist/version.js +9 -0
- package/package.json +11 -8
|
@@ -0,0 +1,3712 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
3
|
+
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
4
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
5
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
6
|
+
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
7
|
+
};
|
|
8
|
+
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
9
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
10
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
11
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
12
|
+
};
|
|
13
|
+
var _QuickLRU_instances, _QuickLRU_size, _QuickLRU_cache, _QuickLRU_oldCache, _QuickLRU_maxSize, _QuickLRU_maxAge, _QuickLRU_onEviction, _QuickLRU_emitEvictions, _QuickLRU_deleteIfExpired, _QuickLRU_getOrDeleteIfExpired, _QuickLRU_getItemValue, _QuickLRU_peek, _QuickLRU_set, _QuickLRU_moveToRecent, _QuickLRU_entriesAscending;
|
|
14
|
+
/*! @hebcal/hdate v0.21.1, distributed under GPLv2 https://www.gnu.org/licenses/gpl-2.0.txt */
|
|
15
|
+
/* eslint-disable @typescript-eslint/no-namespace, no-inner-declarations */
|
|
16
|
+
/** @private */
|
|
17
|
+
const lengths = [0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
|
|
18
|
+
/** @private */
|
|
19
|
+
const monthLengths = [lengths, lengths.slice()];
|
|
20
|
+
monthLengths[1][2] = 29;
|
|
21
|
+
/**
|
|
22
|
+
* @private
|
|
23
|
+
*/
|
|
24
|
+
function mod$1(x, y) {
|
|
25
|
+
return x - y * Math.floor(x / y);
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* @private
|
|
29
|
+
*/
|
|
30
|
+
function quotient(x, y) {
|
|
31
|
+
return Math.floor(x / y);
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* @private
|
|
35
|
+
* @param abs - R.D. number of days
|
|
36
|
+
*/
|
|
37
|
+
function yearFromFixed(abs) {
|
|
38
|
+
const l0 = abs - 1;
|
|
39
|
+
const n400 = quotient(l0, 146097);
|
|
40
|
+
const d1 = mod$1(l0, 146097);
|
|
41
|
+
const n100 = quotient(d1, 36524);
|
|
42
|
+
const d2 = mod$1(d1, 36524);
|
|
43
|
+
const n4 = quotient(d2, 1461);
|
|
44
|
+
const d3 = mod$1(d2, 1461);
|
|
45
|
+
const n1 = quotient(d3, 365);
|
|
46
|
+
const year = 400 * n400 + 100 * n100 + 4 * n4 + n1;
|
|
47
|
+
return n100 !== 4 && n1 !== 4 ? year + 1 : year;
|
|
48
|
+
}
|
|
49
|
+
/*
|
|
50
|
+
const ABS_14SEP1752 = 639797;
|
|
51
|
+
const ABS_2SEP1752 = 639785;
|
|
52
|
+
*/
|
|
53
|
+
/*
|
|
54
|
+
* Formerly in namespace, now top-level
|
|
55
|
+
*/
|
|
56
|
+
/**
|
|
57
|
+
* Returns true if the Gregorian year is a leap year
|
|
58
|
+
* @param year Gregorian year
|
|
59
|
+
*/
|
|
60
|
+
function isGregLeapYear(year) {
|
|
61
|
+
return !(year % 4) && (!!(year % 100) || !(year % 400));
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Number of days in the Gregorian month for given year
|
|
65
|
+
* @param month Gregorian month (1=January, 12=December)
|
|
66
|
+
* @param year Gregorian year
|
|
67
|
+
*/
|
|
68
|
+
function daysInGregMonth(month, year) {
|
|
69
|
+
// 1 based months
|
|
70
|
+
return monthLengths[+isGregLeapYear(year)][month];
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Returns true if the object is a Javascript Date
|
|
74
|
+
*/
|
|
75
|
+
function isDate(obj) {
|
|
76
|
+
// eslint-disable-next-line no-prototype-builtins
|
|
77
|
+
return typeof obj === 'object' && Date.prototype.isPrototypeOf(obj);
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* @private
|
|
81
|
+
* @param year
|
|
82
|
+
* @param month (1-12)
|
|
83
|
+
* @param day (1-31)
|
|
84
|
+
*/
|
|
85
|
+
function toFixed(year, month, day) {
|
|
86
|
+
const py = year - 1;
|
|
87
|
+
return (365 * py +
|
|
88
|
+
quotient(py, 4) -
|
|
89
|
+
quotient(py, 100) +
|
|
90
|
+
quotient(py, 400) +
|
|
91
|
+
quotient(367 * month - 362, 12) +
|
|
92
|
+
(month <= 2 ? 0 : isGregLeapYear(year) ? -1 : -2) +
|
|
93
|
+
day);
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Converts Gregorian date to absolute R.D. (Rata Die) days
|
|
97
|
+
* @param date Gregorian date
|
|
98
|
+
*/
|
|
99
|
+
function greg2abs(date) {
|
|
100
|
+
if (!isDate(date)) {
|
|
101
|
+
throw new TypeError(`not a Date: ${date}`);
|
|
102
|
+
}
|
|
103
|
+
else if (isNaN(date.getTime())) {
|
|
104
|
+
throw new RangeError('Invalid Date');
|
|
105
|
+
}
|
|
106
|
+
const abs = toFixed(date.getFullYear(), date.getMonth() + 1, date.getDate());
|
|
107
|
+
/*
|
|
108
|
+
if (abs < ABS_14SEP1752 && abs > ABS_2SEP1752) {
|
|
109
|
+
throw new RangeError(`Invalid Date: ${date}`);
|
|
110
|
+
}
|
|
111
|
+
*/
|
|
112
|
+
return abs;
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Converts from Rata Die (R.D. number) to Gregorian date.
|
|
116
|
+
* See the footnote on page 384 of ``Calendrical Calculations, Part II:
|
|
117
|
+
* Three Historical Calendars'' by E. M. Reingold, N. Dershowitz, and S. M.
|
|
118
|
+
* Clamen, Software--Practice and Experience, Volume 23, Number 4
|
|
119
|
+
* (April, 1993), pages 383-404 for an explanation.
|
|
120
|
+
*
|
|
121
|
+
* Note that this function returns the daytime portion of the date.
|
|
122
|
+
* For example, the 15th of Cheshvan 5769 began at sundown on
|
|
123
|
+
* 12 November 2008 and continues through 13 November 2008. This
|
|
124
|
+
* function would return only the date 13 November 2008.
|
|
125
|
+
* @param abs - R.D. number of days
|
|
126
|
+
* @example
|
|
127
|
+
* const abs = hebrew2abs(5769, months.CHESHVAN, 15);
|
|
128
|
+
* const date = abs2greg(abs); // 13 November 2008
|
|
129
|
+
* const year = date.getFullYear(); // 2008
|
|
130
|
+
* const monthNum = date.getMonth() + 1; // 11
|
|
131
|
+
* const day = date.getDate(); // 13
|
|
132
|
+
*/
|
|
133
|
+
function abs2greg(abs) {
|
|
134
|
+
if (typeof abs !== 'number' || isNaN(abs)) {
|
|
135
|
+
throw new TypeError(`not a Number: ${abs}`);
|
|
136
|
+
}
|
|
137
|
+
abs = Math.trunc(abs);
|
|
138
|
+
/*
|
|
139
|
+
if (abs < ABS_14SEP1752 && abs > ABS_2SEP1752) {
|
|
140
|
+
throw new RangeError(`Invalid Date: ${abs}`);
|
|
141
|
+
}
|
|
142
|
+
*/
|
|
143
|
+
const year = yearFromFixed(abs);
|
|
144
|
+
const priorDays = abs - toFixed(year, 1, 1);
|
|
145
|
+
const correction = abs < toFixed(year, 3, 1) ? 0 : isGregLeapYear(year) ? 1 : 2;
|
|
146
|
+
const month = quotient(12 * (priorDays + correction) + 373, 367);
|
|
147
|
+
const day = abs - toFixed(year, month, 1) + 1;
|
|
148
|
+
const dt = new Date(year, month - 1, day);
|
|
149
|
+
if (year < 100 && year >= 0) {
|
|
150
|
+
dt.setFullYear(year);
|
|
151
|
+
}
|
|
152
|
+
return dt;
|
|
153
|
+
}
|
|
154
|
+
/*! @hebcal/hdate v0.21.1, distributed under GPLv2 https://www.gnu.org/licenses/gpl-2.0.txt */
|
|
155
|
+
/* eslint-disable @typescript-eslint/no-explicit-any, @typescript-eslint/no-namespace */
|
|
156
|
+
/**
|
|
157
|
+
* Gregorian date helper functions
|
|
158
|
+
*/
|
|
159
|
+
var greg;
|
|
160
|
+
(function (greg) {
|
|
161
|
+
})(greg || (greg = {}));
|
|
162
|
+
greg.abs2greg = abs2greg;
|
|
163
|
+
greg.daysInMonth = daysInGregMonth;
|
|
164
|
+
greg.greg2abs = greg2abs;
|
|
165
|
+
greg.isDate = isDate;
|
|
166
|
+
greg.isLeapYear = isGregLeapYear;
|
|
167
|
+
/*! @hebcal/hdate v0.21.1, distributed under GPLv2 https://www.gnu.org/licenses/gpl-2.0.txt */
|
|
168
|
+
/**
|
|
169
|
+
* Removes niqqud from Hebrew string
|
|
170
|
+
*/
|
|
171
|
+
function hebrewStripNikkud(str) {
|
|
172
|
+
const a = str.normalize();
|
|
173
|
+
// now strip out niqqud and trope
|
|
174
|
+
return a.replace(/[\u0590-\u05bd]/g, '').replace(/[\u05bf-\u05c7]/g, '');
|
|
175
|
+
}
|
|
176
|
+
/*! @hebcal/hdate v0.21.1, distributed under GPLv2 https://www.gnu.org/licenses/gpl-2.0.txt */
|
|
177
|
+
/*
|
|
178
|
+
* More minimal HDate
|
|
179
|
+
*/
|
|
180
|
+
const NISAN$2 = 1;
|
|
181
|
+
const IYYAR$1 = 2;
|
|
182
|
+
const SIVAN = 3;
|
|
183
|
+
const TAMUZ$1 = 4;
|
|
184
|
+
const AV$1 = 5;
|
|
185
|
+
const ELUL = 6;
|
|
186
|
+
const TISHREI$1 = 7;
|
|
187
|
+
const CHESHVAN = 8;
|
|
188
|
+
const KISLEV$1 = 9;
|
|
189
|
+
const TEVET$1 = 10;
|
|
190
|
+
const SHVAT = 11;
|
|
191
|
+
const ADAR_I$1 = 12;
|
|
192
|
+
const ADAR_II$1 = 13;
|
|
193
|
+
/**
|
|
194
|
+
* Hebrew months of the year (NISAN=1, TISHREI=7)
|
|
195
|
+
* @readonly
|
|
196
|
+
* @enum {number}
|
|
197
|
+
*/
|
|
198
|
+
const months = {
|
|
199
|
+
/** Nissan / ניסן */
|
|
200
|
+
NISAN: NISAN$2,
|
|
201
|
+
/** Iyyar / אייר */
|
|
202
|
+
IYYAR: IYYAR$1,
|
|
203
|
+
/** Sivan / סיון */
|
|
204
|
+
SIVAN,
|
|
205
|
+
/** Tamuz (sometimes Tammuz) / תמוז */
|
|
206
|
+
TAMUZ: TAMUZ$1,
|
|
207
|
+
/** Av / אב */
|
|
208
|
+
AV: AV$1,
|
|
209
|
+
/** Elul / אלול */
|
|
210
|
+
ELUL,
|
|
211
|
+
/** Tishrei / תִּשְׁרֵי */
|
|
212
|
+
TISHREI: TISHREI$1,
|
|
213
|
+
/** Cheshvan / חשון */
|
|
214
|
+
CHESHVAN,
|
|
215
|
+
/** Kislev / כסלו */
|
|
216
|
+
KISLEV: KISLEV$1,
|
|
217
|
+
/** Tevet / טבת */
|
|
218
|
+
TEVET: TEVET$1,
|
|
219
|
+
/** Sh'vat / שבט */
|
|
220
|
+
SHVAT,
|
|
221
|
+
/** Adar or Adar Rishon / אדר */
|
|
222
|
+
ADAR_I: ADAR_I$1,
|
|
223
|
+
/** Adar Sheini (only on leap years) / אדר ב׳ */
|
|
224
|
+
ADAR_II: ADAR_II$1,
|
|
225
|
+
};
|
|
226
|
+
const NISAN_STR = 'Nisan';
|
|
227
|
+
const monthNames0 = [
|
|
228
|
+
'',
|
|
229
|
+
NISAN_STR,
|
|
230
|
+
'Iyyar',
|
|
231
|
+
'Sivan',
|
|
232
|
+
'Tamuz',
|
|
233
|
+
'Av',
|
|
234
|
+
'Elul',
|
|
235
|
+
'Tishrei',
|
|
236
|
+
'Cheshvan',
|
|
237
|
+
'Kislev',
|
|
238
|
+
'Tevet',
|
|
239
|
+
"Sh'vat",
|
|
240
|
+
];
|
|
241
|
+
/*
|
|
242
|
+
* Transliterations of Hebrew month names.
|
|
243
|
+
* Regular years are index 0 and leap years are index 1.
|
|
244
|
+
* @private
|
|
245
|
+
*/
|
|
246
|
+
const monthNames = [
|
|
247
|
+
[...monthNames0, 'Adar', NISAN_STR],
|
|
248
|
+
[...monthNames0, 'Adar I', 'Adar II', NISAN_STR],
|
|
249
|
+
];
|
|
250
|
+
const edCache = new Map();
|
|
251
|
+
const EPOCH = -1373428;
|
|
252
|
+
// Avg year length in the cycle (19 solar years with 235 lunar months)
|
|
253
|
+
const AVG_HEBYEAR_DAYS = 365.24682220597794;
|
|
254
|
+
/**
|
|
255
|
+
* @private
|
|
256
|
+
*/
|
|
257
|
+
function assertNumber(n, name) {
|
|
258
|
+
if (typeof n !== 'number' || isNaN(n)) {
|
|
259
|
+
throw new TypeError(`param '${name}' not a number: ${n}`);
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
/**
|
|
263
|
+
* Converts Hebrew date to R.D. (Rata Die) fixed days.
|
|
264
|
+
* R.D. 1 is the imaginary date Monday, January 1, 1 on the Gregorian
|
|
265
|
+
* Calendar.
|
|
266
|
+
* @param year Hebrew year
|
|
267
|
+
* @param month Hebrew month
|
|
268
|
+
* @param day Hebrew date (1-30)
|
|
269
|
+
* @example
|
|
270
|
+
* const abs = hebrew2abs(5769, months.CHESHVAN, 15);
|
|
271
|
+
*/
|
|
272
|
+
function hebrew2abs(year, month, day) {
|
|
273
|
+
assertNumber(year, 'year');
|
|
274
|
+
assertNumber(month, 'month');
|
|
275
|
+
assertNumber(day, 'day');
|
|
276
|
+
if (year < 1) {
|
|
277
|
+
throw new RangeError(`hebrew2abs: invalid year ${year}`);
|
|
278
|
+
}
|
|
279
|
+
let tempabs = day;
|
|
280
|
+
if (month < TISHREI$1) {
|
|
281
|
+
for (let m = TISHREI$1; m <= monthsInYear(year); m++) {
|
|
282
|
+
tempabs += daysInMonth(m, year);
|
|
283
|
+
}
|
|
284
|
+
for (let m = NISAN$2; m < month; m++) {
|
|
285
|
+
tempabs += daysInMonth(m, year);
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
else {
|
|
289
|
+
for (let m = TISHREI$1; m < month; m++) {
|
|
290
|
+
tempabs += daysInMonth(m, year);
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
return EPOCH + elapsedDays(year) + tempabs - 1;
|
|
294
|
+
}
|
|
295
|
+
/**
|
|
296
|
+
* @private
|
|
297
|
+
*/
|
|
298
|
+
function newYear(year) {
|
|
299
|
+
return EPOCH + elapsedDays(year);
|
|
300
|
+
}
|
|
301
|
+
/**
|
|
302
|
+
* Converts absolute R.D. days to Hebrew date
|
|
303
|
+
* @param abs absolute R.D. days
|
|
304
|
+
*/
|
|
305
|
+
function abs2hebrew(abs) {
|
|
306
|
+
assertNumber(abs, 'abs');
|
|
307
|
+
abs = Math.trunc(abs);
|
|
308
|
+
if (abs <= EPOCH) {
|
|
309
|
+
throw new RangeError(`abs2hebrew: ${abs} is before epoch`);
|
|
310
|
+
}
|
|
311
|
+
// first, quickly approximate year
|
|
312
|
+
let year = Math.floor((abs - EPOCH) / AVG_HEBYEAR_DAYS);
|
|
313
|
+
while (newYear(year) <= abs) {
|
|
314
|
+
++year;
|
|
315
|
+
}
|
|
316
|
+
--year;
|
|
317
|
+
let month = abs < hebrew2abs(year, 1, 1) ? 7 : 1;
|
|
318
|
+
while (abs > hebrew2abs(year, month, daysInMonth(month, year))) {
|
|
319
|
+
++month;
|
|
320
|
+
}
|
|
321
|
+
const day = 1 + abs - hebrew2abs(year, month, 1);
|
|
322
|
+
return { yy: year, mm: month, dd: day };
|
|
323
|
+
}
|
|
324
|
+
/**
|
|
325
|
+
* Returns true if Hebrew year is a leap year
|
|
326
|
+
* @param year Hebrew year
|
|
327
|
+
*/
|
|
328
|
+
function isLeapYear(year) {
|
|
329
|
+
return (1 + year * 7) % 19 < 7;
|
|
330
|
+
}
|
|
331
|
+
/**
|
|
332
|
+
* Number of months in this Hebrew year (either 12 or 13 depending on leap year)
|
|
333
|
+
* @param year Hebrew year
|
|
334
|
+
*/
|
|
335
|
+
function monthsInYear(year) {
|
|
336
|
+
return 12 + +isLeapYear(year); // boolean is cast to 1 or 0
|
|
337
|
+
}
|
|
338
|
+
/**
|
|
339
|
+
* Number of days in Hebrew month in a given year (29 or 30)
|
|
340
|
+
* @param month Hebrew month (e.g. months.TISHREI)
|
|
341
|
+
* @param year Hebrew year
|
|
342
|
+
*/
|
|
343
|
+
function daysInMonth(month, year) {
|
|
344
|
+
switch (month) {
|
|
345
|
+
case IYYAR$1:
|
|
346
|
+
case TAMUZ$1:
|
|
347
|
+
case ELUL:
|
|
348
|
+
case TEVET$1:
|
|
349
|
+
case ADAR_II$1:
|
|
350
|
+
return 29;
|
|
351
|
+
}
|
|
352
|
+
if ((month === ADAR_I$1 && !isLeapYear(year)) ||
|
|
353
|
+
(month === CHESHVAN && !longCheshvan(year)) ||
|
|
354
|
+
(month === KISLEV$1 && shortKislev(year))) {
|
|
355
|
+
return 29;
|
|
356
|
+
}
|
|
357
|
+
else {
|
|
358
|
+
return 30;
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
/**
|
|
362
|
+
* Returns a transliterated string name of Hebrew month in year,
|
|
363
|
+
* for example 'Elul' or 'Cheshvan'.
|
|
364
|
+
* @param month Hebrew month (e.g. months.TISHREI)
|
|
365
|
+
* @param year Hebrew year
|
|
366
|
+
*/
|
|
367
|
+
function getMonthName(month, year) {
|
|
368
|
+
assertNumber(month, 'month');
|
|
369
|
+
assertNumber(year, 'year');
|
|
370
|
+
if (month < 1 || month > 14) {
|
|
371
|
+
throw new TypeError(`bad monthNum: ${month}`);
|
|
372
|
+
}
|
|
373
|
+
return monthNames[+isLeapYear(year)][month];
|
|
374
|
+
}
|
|
375
|
+
/**
|
|
376
|
+
* Days from sunday prior to start of Hebrew calendar to mean
|
|
377
|
+
* conjunction of Tishrei in Hebrew YEAR
|
|
378
|
+
* @param year Hebrew year
|
|
379
|
+
*/
|
|
380
|
+
function elapsedDays(year) {
|
|
381
|
+
const n = edCache.get(year);
|
|
382
|
+
if (typeof n === 'number') {
|
|
383
|
+
return n;
|
|
384
|
+
}
|
|
385
|
+
const elapsed = elapsedDays0(year);
|
|
386
|
+
edCache.set(year, elapsed);
|
|
387
|
+
return elapsed;
|
|
388
|
+
}
|
|
389
|
+
/**
|
|
390
|
+
* Days from sunday prior to start of Hebrew calendar to mean
|
|
391
|
+
* conjunction of Tishrei in Hebrew YEAR
|
|
392
|
+
* @private
|
|
393
|
+
* @param year Hebrew year
|
|
394
|
+
*/
|
|
395
|
+
function elapsedDays0(year) {
|
|
396
|
+
const prevYear = year - 1;
|
|
397
|
+
const mElapsed = 235 * Math.floor(prevYear / 19) + // Months in complete 19 year lunar (Metonic) cycles so far
|
|
398
|
+
12 * (prevYear % 19) + // Regular months in this cycle
|
|
399
|
+
Math.floor(((prevYear % 19) * 7 + 1) / 19); // Leap months this cycle
|
|
400
|
+
const pElapsed = 204 + 793 * (mElapsed % 1080);
|
|
401
|
+
const hElapsed = 5 +
|
|
402
|
+
12 * mElapsed +
|
|
403
|
+
793 * Math.floor(mElapsed / 1080) +
|
|
404
|
+
Math.floor(pElapsed / 1080);
|
|
405
|
+
const parts = (pElapsed % 1080) + 1080 * (hElapsed % 24);
|
|
406
|
+
const day = 1 + 29 * mElapsed + Math.floor(hElapsed / 24);
|
|
407
|
+
let altDay = day;
|
|
408
|
+
if (parts >= 19440 ||
|
|
409
|
+
(2 === day % 7 && parts >= 9924 && !isLeapYear(year)) ||
|
|
410
|
+
(1 === day % 7 && parts >= 16789 && isLeapYear(prevYear))) {
|
|
411
|
+
altDay++;
|
|
412
|
+
}
|
|
413
|
+
if (altDay % 7 === 0 || altDay % 7 === 3 || altDay % 7 === 5) {
|
|
414
|
+
return altDay + 1;
|
|
415
|
+
}
|
|
416
|
+
else {
|
|
417
|
+
return altDay;
|
|
418
|
+
}
|
|
419
|
+
}
|
|
420
|
+
/**
|
|
421
|
+
* Number of days in the hebrew YEAR.
|
|
422
|
+
* A common Hebrew calendar year can have a length of 353, 354 or 355 days
|
|
423
|
+
* A leap Hebrew calendar year can have a length of 383, 384 or 385 days
|
|
424
|
+
* @param year Hebrew year
|
|
425
|
+
*/
|
|
426
|
+
function daysInYear(year) {
|
|
427
|
+
return elapsedDays(year + 1) - elapsedDays(year);
|
|
428
|
+
}
|
|
429
|
+
/**
|
|
430
|
+
* true if Cheshvan is long in Hebrew year
|
|
431
|
+
* @param year Hebrew year
|
|
432
|
+
*/
|
|
433
|
+
function longCheshvan(year) {
|
|
434
|
+
return daysInYear(year) % 10 === 5;
|
|
435
|
+
}
|
|
436
|
+
/**
|
|
437
|
+
* true if Kislev is short in Hebrew year
|
|
438
|
+
* @param year Hebrew year
|
|
439
|
+
*/
|
|
440
|
+
function shortKislev(year) {
|
|
441
|
+
return daysInYear(year) % 10 === 3;
|
|
442
|
+
}
|
|
443
|
+
/**
|
|
444
|
+
* Converts Hebrew month string name to numeric
|
|
445
|
+
* @param monthName monthName
|
|
446
|
+
*/
|
|
447
|
+
function monthFromName(monthName) {
|
|
448
|
+
if (typeof monthName === 'number') {
|
|
449
|
+
if (isNaN(monthName) || monthName < 1 || monthName > 14) {
|
|
450
|
+
throw new RangeError(`bad monthName: ${monthName}`);
|
|
451
|
+
}
|
|
452
|
+
return monthName;
|
|
453
|
+
}
|
|
454
|
+
let c = monthName.trim().toLowerCase();
|
|
455
|
+
// remove all niqud and trailing gershayim (for Adar Alef/Bet)
|
|
456
|
+
c = hebrewStripNikkud(c).replace(/׳$/, '');
|
|
457
|
+
// If Hebrew month starts with a bet (for example `בתמוז`) then ignore it
|
|
458
|
+
if (c[0] === 'ב') {
|
|
459
|
+
c = c.substring(1);
|
|
460
|
+
}
|
|
461
|
+
/*
|
|
462
|
+
the Hebrew months are unique to their second letter
|
|
463
|
+
N Nisan (November?)
|
|
464
|
+
I Iyyar
|
|
465
|
+
E Elul
|
|
466
|
+
C Cheshvan
|
|
467
|
+
K Kislev
|
|
468
|
+
1 1Adar
|
|
469
|
+
2 2Adar
|
|
470
|
+
Si Sh Sivan, Shvat
|
|
471
|
+
Ta Ti Te Tamuz, Tishrei, Tevet
|
|
472
|
+
Av Ad Av, Adar
|
|
473
|
+
|
|
474
|
+
אב אד אי אל אב אדר אייר אלול
|
|
475
|
+
ח חשון
|
|
476
|
+
ט טבת
|
|
477
|
+
כ כסלו
|
|
478
|
+
נ ניסן
|
|
479
|
+
ס סיון
|
|
480
|
+
ש שבט
|
|
481
|
+
תמ תש תמוז תשרי
|
|
482
|
+
*/
|
|
483
|
+
switch (c[0]) {
|
|
484
|
+
case 'n':
|
|
485
|
+
case 'נ':
|
|
486
|
+
if (c[1] === 'o') {
|
|
487
|
+
break; /* this catches "november" */
|
|
488
|
+
}
|
|
489
|
+
return NISAN$2;
|
|
490
|
+
case 'i':
|
|
491
|
+
return IYYAR$1;
|
|
492
|
+
case 'e':
|
|
493
|
+
return ELUL;
|
|
494
|
+
case 'c':
|
|
495
|
+
case 'ח':
|
|
496
|
+
return CHESHVAN;
|
|
497
|
+
case 'k':
|
|
498
|
+
case 'כ':
|
|
499
|
+
return KISLEV$1;
|
|
500
|
+
case 's':
|
|
501
|
+
switch (c[1]) {
|
|
502
|
+
case 'i':
|
|
503
|
+
return SIVAN;
|
|
504
|
+
case 'h':
|
|
505
|
+
return SHVAT;
|
|
506
|
+
}
|
|
507
|
+
break;
|
|
508
|
+
case 't':
|
|
509
|
+
switch (c[1]) {
|
|
510
|
+
case 'a':
|
|
511
|
+
return TAMUZ$1;
|
|
512
|
+
case 'i':
|
|
513
|
+
return TISHREI$1;
|
|
514
|
+
case 'e':
|
|
515
|
+
return TEVET$1;
|
|
516
|
+
}
|
|
517
|
+
break;
|
|
518
|
+
case 'a':
|
|
519
|
+
switch (c[1]) {
|
|
520
|
+
case 'v':
|
|
521
|
+
return AV$1;
|
|
522
|
+
case 'd':
|
|
523
|
+
if (/(1|[^i]i|a|א)$/i.test(c)) {
|
|
524
|
+
return ADAR_I$1;
|
|
525
|
+
}
|
|
526
|
+
return ADAR_II$1; // else assume sheini
|
|
527
|
+
}
|
|
528
|
+
break;
|
|
529
|
+
case 'ס':
|
|
530
|
+
return SIVAN;
|
|
531
|
+
case 'ט':
|
|
532
|
+
return TEVET$1;
|
|
533
|
+
case 'ש':
|
|
534
|
+
return SHVAT;
|
|
535
|
+
case 'א':
|
|
536
|
+
switch (c[1]) {
|
|
537
|
+
case 'ב':
|
|
538
|
+
return AV$1;
|
|
539
|
+
case 'ד':
|
|
540
|
+
if (/(1|[^i]i|a|א)$/i.test(c)) {
|
|
541
|
+
return ADAR_I$1;
|
|
542
|
+
}
|
|
543
|
+
return ADAR_II$1; // else assume sheini
|
|
544
|
+
case 'י':
|
|
545
|
+
return IYYAR$1;
|
|
546
|
+
case 'ל':
|
|
547
|
+
return ELUL;
|
|
548
|
+
}
|
|
549
|
+
break;
|
|
550
|
+
case 'ת':
|
|
551
|
+
switch (c[1]) {
|
|
552
|
+
case 'מ':
|
|
553
|
+
return TAMUZ$1;
|
|
554
|
+
case 'ש':
|
|
555
|
+
return TISHREI$1;
|
|
556
|
+
}
|
|
557
|
+
break;
|
|
558
|
+
}
|
|
559
|
+
throw new RangeError(`bad monthName: ${monthName}`);
|
|
560
|
+
}
|
|
561
|
+
/*! @hebcal/hdate v0.21.1, distributed under GPLv2 https://www.gnu.org/licenses/gpl-2.0.txt */
|
|
562
|
+
const GERESH = '׳';
|
|
563
|
+
const GERSHAYIM = '״';
|
|
564
|
+
const heb2num = {
|
|
565
|
+
א: 1,
|
|
566
|
+
ב: 2,
|
|
567
|
+
ג: 3,
|
|
568
|
+
ד: 4,
|
|
569
|
+
ה: 5,
|
|
570
|
+
ו: 6,
|
|
571
|
+
ז: 7,
|
|
572
|
+
ח: 8,
|
|
573
|
+
ט: 9,
|
|
574
|
+
י: 10,
|
|
575
|
+
כ: 20,
|
|
576
|
+
ל: 30,
|
|
577
|
+
מ: 40,
|
|
578
|
+
נ: 50,
|
|
579
|
+
ס: 60,
|
|
580
|
+
ע: 70,
|
|
581
|
+
פ: 80,
|
|
582
|
+
צ: 90,
|
|
583
|
+
ק: 100,
|
|
584
|
+
ר: 200,
|
|
585
|
+
ש: 300,
|
|
586
|
+
ת: 400,
|
|
587
|
+
};
|
|
588
|
+
const num2heb = {};
|
|
589
|
+
for (const [key, val] of Object.entries(heb2num)) {
|
|
590
|
+
num2heb[val] = key;
|
|
591
|
+
}
|
|
592
|
+
function num2digits(num) {
|
|
593
|
+
const digits = [];
|
|
594
|
+
while (num > 0) {
|
|
595
|
+
if (num === 15 || num === 16) {
|
|
596
|
+
digits.push(9);
|
|
597
|
+
digits.push(num - 9);
|
|
598
|
+
break;
|
|
599
|
+
}
|
|
600
|
+
let incr = 100;
|
|
601
|
+
let i;
|
|
602
|
+
for (i = 400; i > num; i -= incr) {
|
|
603
|
+
if (i === incr) {
|
|
604
|
+
incr = incr / 10;
|
|
605
|
+
}
|
|
606
|
+
}
|
|
607
|
+
digits.push(i);
|
|
608
|
+
num -= i;
|
|
609
|
+
}
|
|
610
|
+
return digits;
|
|
611
|
+
}
|
|
612
|
+
/**
|
|
613
|
+
* Converts a numerical value to a string of Hebrew letters.
|
|
614
|
+
*
|
|
615
|
+
* When specifying years of the Hebrew calendar in the present millennium,
|
|
616
|
+
* we omit the thousands (which is presently 5 [ה]).
|
|
617
|
+
* @example
|
|
618
|
+
* gematriya(5774) // 'תשע״ד' - cropped to 774
|
|
619
|
+
* gematriya(25) // 'כ״ה'
|
|
620
|
+
* gematriya(60) // 'ס׳'
|
|
621
|
+
* gematriya(3761) // 'ג׳תשס״א'
|
|
622
|
+
* gematriya(1123) // 'א׳קכ״ג'
|
|
623
|
+
*/
|
|
624
|
+
function gematriya(num) {
|
|
625
|
+
const num1 = parseInt(num, 10);
|
|
626
|
+
if (!num1 || num1 < 0) {
|
|
627
|
+
throw new TypeError(`invalid number: ${num}`);
|
|
628
|
+
}
|
|
629
|
+
let str = '';
|
|
630
|
+
const thousands = Math.floor(num1 / 1000);
|
|
631
|
+
if (thousands > 0 && thousands !== 5) {
|
|
632
|
+
const tdigits = num2digits(thousands);
|
|
633
|
+
for (const tdig of tdigits) {
|
|
634
|
+
str += num2heb[tdig];
|
|
635
|
+
}
|
|
636
|
+
str += GERESH;
|
|
637
|
+
}
|
|
638
|
+
const digits = num2digits(num1 % 1000);
|
|
639
|
+
if (digits.length === 1) {
|
|
640
|
+
return str + num2heb[digits[0]] + GERESH;
|
|
641
|
+
}
|
|
642
|
+
for (let i = 0; i < digits.length; i++) {
|
|
643
|
+
if (i + 1 === digits.length) {
|
|
644
|
+
str += GERSHAYIM;
|
|
645
|
+
}
|
|
646
|
+
str += num2heb[digits[i]];
|
|
647
|
+
}
|
|
648
|
+
return str;
|
|
649
|
+
}
|
|
650
|
+
/**
|
|
651
|
+
* Converts a string of Hebrew letters to a numerical value.
|
|
652
|
+
*
|
|
653
|
+
* Only considers the value of Hebrew letters `א` through `ת`.
|
|
654
|
+
* Ignores final Hebrew letters such as `ך` (kaf sofit) or `ם` (mem sofit)
|
|
655
|
+
* and vowels (nekudot).
|
|
656
|
+
*/
|
|
657
|
+
function gematriyaStrToNum(str) {
|
|
658
|
+
let num = 0;
|
|
659
|
+
const gereshIdx = str.indexOf(GERESH);
|
|
660
|
+
if (gereshIdx !== -1 && gereshIdx !== str.length - 1) {
|
|
661
|
+
const thousands = str.substring(0, gereshIdx);
|
|
662
|
+
num += gematriyaStrToNum(thousands) * 1000;
|
|
663
|
+
str = str.substring(gereshIdx);
|
|
664
|
+
}
|
|
665
|
+
for (const ch of str) {
|
|
666
|
+
const n = heb2num[ch];
|
|
667
|
+
if (typeof n === 'number') {
|
|
668
|
+
num += n;
|
|
669
|
+
}
|
|
670
|
+
}
|
|
671
|
+
return num;
|
|
672
|
+
}
|
|
673
|
+
/*! @hebcal/hdate v0.21.1, distributed under GPLv2 https://www.gnu.org/licenses/gpl-2.0.txt */
|
|
674
|
+
/**
|
|
675
|
+
* Formats a number with leading zeros so the resulting string is 4 digits long.
|
|
676
|
+
* Similar to `string.padStart(4, '0')` but will also format
|
|
677
|
+
* negative numbers similar to how the JavaScript date formats
|
|
678
|
+
* negative year numbers (e.g. `-37` is formatted as `-000037`).
|
|
679
|
+
*/
|
|
680
|
+
function pad4(num) {
|
|
681
|
+
if (num < 0) {
|
|
682
|
+
return '-00' + pad4(-num);
|
|
683
|
+
}
|
|
684
|
+
else if (num < 10) {
|
|
685
|
+
return '000' + num;
|
|
686
|
+
}
|
|
687
|
+
else if (num < 100) {
|
|
688
|
+
return '00' + num;
|
|
689
|
+
}
|
|
690
|
+
else if (num < 1000) {
|
|
691
|
+
return '0' + num;
|
|
692
|
+
}
|
|
693
|
+
return String(num);
|
|
694
|
+
}
|
|
695
|
+
/**
|
|
696
|
+
* Formats a number with leading zeros so the resulting string is 2 digits long.
|
|
697
|
+
* Similar to `string.padStart(2, '0')`.
|
|
698
|
+
*/
|
|
699
|
+
function pad2(num) {
|
|
700
|
+
if (num >= 0 && num < 10) {
|
|
701
|
+
return '0' + num;
|
|
702
|
+
}
|
|
703
|
+
return String(num);
|
|
704
|
+
}
|
|
705
|
+
/*! @hebcal/hdate v0.21.1, distributed under GPLv2 https://www.gnu.org/licenses/gpl-2.0.txt */
|
|
706
|
+
/**
|
|
707
|
+
* Returns YYYY-MM-DD in the local timezone
|
|
708
|
+
*/
|
|
709
|
+
function isoDateString(dt) {
|
|
710
|
+
return (pad4(dt.getFullYear()) +
|
|
711
|
+
'-' +
|
|
712
|
+
pad2(dt.getMonth() + 1) +
|
|
713
|
+
'-' +
|
|
714
|
+
pad2(dt.getDate()));
|
|
715
|
+
}
|
|
716
|
+
/*! @hebcal/hdate v0.21.1, distributed under GPLv2 https://www.gnu.org/licenses/gpl-2.0.txt */
|
|
717
|
+
var poAshkenazi$1 = { "headers": { "plural-forms": "nplurals=2; plural=(n > 1);", "language": "en_CA@ashkenazi" }, "contexts": { "": { "Tevet": ["Teves"] } } };
|
|
718
|
+
/*! @hebcal/hdate v0.21.1, distributed under GPLv2 https://www.gnu.org/licenses/gpl-2.0.txt */
|
|
719
|
+
var poHe$1 = { "headers": { "plural-forms": "nplurals=2; plural=(n > 1);", "language": "he" }, "contexts": { "": { "Adar": ["אֲדָר"], "Adar I": ["אֲדָר א׳"], "Adar II": ["אֲדָר ב׳"], "Av": ["אָב"], "Cheshvan": ["חֶשְׁוָן"], "Elul": ["אֱלוּל"], "Iyyar": ["אִיָּיר"], "Kislev": ["כִּסְלֵו"], "Nisan": ["נִיסָן"], "Sh'vat": ["שְׁבָט"], "Sivan": ["סִיוָן"], "Tamuz": ["תַּמּוּז"], "Tevet": ["טֵבֵת"], "Tishrei": ["תִּשְׁרֵי"] } } };
|
|
720
|
+
/*! @hebcal/hdate v0.21.1, distributed under GPLv2 https://www.gnu.org/licenses/gpl-2.0.txt */
|
|
721
|
+
const noopLocale = {
|
|
722
|
+
headers: { 'plural-forms': 'nplurals=2; plural=(n!=1);' },
|
|
723
|
+
contexts: { '': {} },
|
|
724
|
+
};
|
|
725
|
+
const alias = {
|
|
726
|
+
h: 'he',
|
|
727
|
+
a: 'ashkenazi',
|
|
728
|
+
s: 'en',
|
|
729
|
+
'': 'en',
|
|
730
|
+
};
|
|
731
|
+
/** @private */
|
|
732
|
+
const locales = new Map();
|
|
733
|
+
/** @private */
|
|
734
|
+
function getEnOrdinal(n) {
|
|
735
|
+
const s = ['th', 'st', 'nd', 'rd'];
|
|
736
|
+
const v = n % 100;
|
|
737
|
+
return n + (s[(v - 20) % 10] || s[v] || s[0]);
|
|
738
|
+
}
|
|
739
|
+
/** @private */
|
|
740
|
+
function checkLocale(locale) {
|
|
741
|
+
if (typeof locale !== 'string') {
|
|
742
|
+
throw new TypeError(`Invalid locale name: ${locale}`);
|
|
743
|
+
}
|
|
744
|
+
locale = alias[locale] || locale;
|
|
745
|
+
return locale.toLowerCase();
|
|
746
|
+
}
|
|
747
|
+
/** @private */
|
|
748
|
+
function getExistingLocale(locale) {
|
|
749
|
+
const locale1 = checkLocale(locale);
|
|
750
|
+
const loc = locales.get(locale1);
|
|
751
|
+
if (!loc) {
|
|
752
|
+
throw new RangeError(`Locale '${locale}' not found`);
|
|
753
|
+
}
|
|
754
|
+
return loc;
|
|
755
|
+
}
|
|
756
|
+
/**
|
|
757
|
+
* A locale in Hebcal is used for translations/transliterations of
|
|
758
|
+
* holidays. `@hebcal/hdate` supports four locales by default
|
|
759
|
+
* * `en` - default, Sephardic transliterations (e.g. "Shabbat")
|
|
760
|
+
* * `ashkenazi` - Ashkenazi transliterations (e.g. "Shabbos")
|
|
761
|
+
* * `he` - Hebrew (e.g. "שַׁבָּת")
|
|
762
|
+
* * `he-x-NoNikud` - Hebrew without nikud (e.g. "שבת")
|
|
763
|
+
*/
|
|
764
|
+
class Locale {
|
|
765
|
+
/**
|
|
766
|
+
* Returns translation only if `locale` offers a non-empty translation for `id`.
|
|
767
|
+
* Otherwise, returns `undefined`.
|
|
768
|
+
* @param id Message ID to translate
|
|
769
|
+
* @param [locale] Optional locale name (i.e: `'he'`, `'fr'`). Defaults to no-op locale.
|
|
770
|
+
*/
|
|
771
|
+
static lookupTranslation(id, locale) {
|
|
772
|
+
const loc = (typeof locale === 'string' && locales.get(checkLocale(locale))) ||
|
|
773
|
+
noopLocale.contexts[''];
|
|
774
|
+
const array = loc[id];
|
|
775
|
+
if ((array === null || array === void 0 ? void 0 : array.length) && array[0].length) {
|
|
776
|
+
return array[0];
|
|
777
|
+
}
|
|
778
|
+
return undefined;
|
|
779
|
+
}
|
|
780
|
+
/**
|
|
781
|
+
* By default, if no translation was found, returns `id`.
|
|
782
|
+
* @param id Message ID to translate
|
|
783
|
+
* @param [locale] Optional locale name (i.e: `'he'`, `'fr'`). Defaults to no-op locale.
|
|
784
|
+
*/
|
|
785
|
+
static gettext(id, locale) {
|
|
786
|
+
const text = this.lookupTranslation(id, locale);
|
|
787
|
+
if (typeof text === 'undefined') {
|
|
788
|
+
return id;
|
|
789
|
+
}
|
|
790
|
+
return text;
|
|
791
|
+
}
|
|
792
|
+
/**
|
|
793
|
+
* Register locale translations.
|
|
794
|
+
* @param locale Locale name (i.e.: `'he'`, `'fr'`)
|
|
795
|
+
* @param data parsed data from a `.po` file.
|
|
796
|
+
*/
|
|
797
|
+
static addLocale(locale, data) {
|
|
798
|
+
locale = checkLocale(locale);
|
|
799
|
+
const ctx = data.contexts;
|
|
800
|
+
if (typeof ctx !== 'object' || typeof ctx[''] !== 'object') {
|
|
801
|
+
throw new TypeError(`Locale '${locale}' invalid compact format`);
|
|
802
|
+
}
|
|
803
|
+
locales.set(locale, ctx['']);
|
|
804
|
+
}
|
|
805
|
+
/**
|
|
806
|
+
* Adds a translation to `locale`, replacing any previous translation.
|
|
807
|
+
* @param locale Locale name (i.e: `'he'`, `'fr'`).
|
|
808
|
+
* @param id Message ID to translate
|
|
809
|
+
* @param translation Translation text
|
|
810
|
+
*/
|
|
811
|
+
static addTranslation(locale, id, translation) {
|
|
812
|
+
const loc = getExistingLocale(locale);
|
|
813
|
+
if (typeof id !== 'string' || id.length === 0) {
|
|
814
|
+
throw new TypeError(`Invalid id string: ${id}`);
|
|
815
|
+
}
|
|
816
|
+
const isArray = Array.isArray(translation);
|
|
817
|
+
if (isArray) {
|
|
818
|
+
const t0 = translation[0];
|
|
819
|
+
if (typeof t0 !== 'string' || t0.length === 0) {
|
|
820
|
+
throw new TypeError(`Invalid translation array: ${translation}`);
|
|
821
|
+
}
|
|
822
|
+
}
|
|
823
|
+
else if (typeof translation !== 'string') {
|
|
824
|
+
throw new TypeError(`Invalid translation string: ${translation}`);
|
|
825
|
+
}
|
|
826
|
+
loc[id] = isArray ? translation : [translation];
|
|
827
|
+
}
|
|
828
|
+
/**
|
|
829
|
+
* Adds multiple translations to `locale`, replacing any previous translations.
|
|
830
|
+
* @param locale Locale name (i.e: `'he'`, `'fr'`).
|
|
831
|
+
* @param data parsed data from a `.po` file.
|
|
832
|
+
*/
|
|
833
|
+
static addTranslations(locale, data) {
|
|
834
|
+
const loc = getExistingLocale(locale);
|
|
835
|
+
const ctx = data.contexts;
|
|
836
|
+
if (typeof ctx !== 'object' || typeof ctx[''] !== 'object') {
|
|
837
|
+
throw new TypeError(`Locale '${locale}' invalid compact format`);
|
|
838
|
+
}
|
|
839
|
+
Object.assign(loc, ctx['']);
|
|
840
|
+
}
|
|
841
|
+
/**
|
|
842
|
+
* Returns the names of registered locales
|
|
843
|
+
*/
|
|
844
|
+
static getLocaleNames() {
|
|
845
|
+
const keys = Array.from(locales.keys());
|
|
846
|
+
return keys.sort((a, b) => a.localeCompare(b));
|
|
847
|
+
}
|
|
848
|
+
/**
|
|
849
|
+
* Checks whether a locale has been registered
|
|
850
|
+
* @param locale Locale name (i.e: `'he'`, `'fr'`).
|
|
851
|
+
*/
|
|
852
|
+
static hasLocale(locale) {
|
|
853
|
+
const locale1 = checkLocale(locale);
|
|
854
|
+
return locales.has(locale1);
|
|
855
|
+
}
|
|
856
|
+
/**
|
|
857
|
+
* Renders a number in ordinal, such as 1st, 2nd or 3rd
|
|
858
|
+
* @param [locale] Optional locale name (i.e: `'he'`, `'fr'`). Defaults to no-op locale.
|
|
859
|
+
*/
|
|
860
|
+
static ordinal(n, locale) {
|
|
861
|
+
let locale0 = locale === null || locale === void 0 ? void 0 : locale.toLowerCase();
|
|
862
|
+
if (!locale0) {
|
|
863
|
+
return getEnOrdinal(n);
|
|
864
|
+
}
|
|
865
|
+
locale0 = alias[locale0] || locale0;
|
|
866
|
+
switch (locale0) {
|
|
867
|
+
case 'en':
|
|
868
|
+
case 'ashkenazi':
|
|
869
|
+
return getEnOrdinal(n);
|
|
870
|
+
case 'es':
|
|
871
|
+
return n + 'º';
|
|
872
|
+
case 'he':
|
|
873
|
+
case 'he-x-nonikud':
|
|
874
|
+
return String(n);
|
|
875
|
+
}
|
|
876
|
+
if (locale0.startsWith('ashkenazi')) {
|
|
877
|
+
return getEnOrdinal(n);
|
|
878
|
+
}
|
|
879
|
+
return n + '.';
|
|
880
|
+
}
|
|
881
|
+
/**
|
|
882
|
+
* Removes nekudot from Hebrew string
|
|
883
|
+
*/
|
|
884
|
+
static hebrewStripNikkud(str) {
|
|
885
|
+
return hebrewStripNikkud(str);
|
|
886
|
+
}
|
|
887
|
+
/**
|
|
888
|
+
* Makes a copy of entire Hebrew locale with no niqqud
|
|
889
|
+
*/
|
|
890
|
+
static copyLocaleNoNikud(data) {
|
|
891
|
+
const strs = data.contexts[''];
|
|
892
|
+
const m = {};
|
|
893
|
+
for (const [key, val] of Object.entries(strs)) {
|
|
894
|
+
m[key] = [hebrewStripNikkud(val[0])];
|
|
895
|
+
}
|
|
896
|
+
return {
|
|
897
|
+
headers: data.headers,
|
|
898
|
+
contexts: { '': m },
|
|
899
|
+
};
|
|
900
|
+
}
|
|
901
|
+
}
|
|
902
|
+
Locale.addLocale('en', noopLocale);
|
|
903
|
+
/* Ashkenazic transliterations */
|
|
904
|
+
Locale.addLocale('ashkenazi', poAshkenazi$1);
|
|
905
|
+
/* Hebrew with nikkud */
|
|
906
|
+
Locale.addLocale('he', poHe$1);
|
|
907
|
+
/* Hebrew without nikkud */
|
|
908
|
+
const poHeNoNikud$1 = Locale.copyLocaleNoNikud(poHe$1);
|
|
909
|
+
Locale.addLocale('he-x-NoNikud', poHeNoNikud$1);
|
|
910
|
+
/*! @hebcal/hdate v0.21.1, distributed under GPLv2 https://www.gnu.org/licenses/gpl-2.0.txt */
|
|
911
|
+
/*
|
|
912
|
+
Hebcal - A Jewish Calendar Generator
|
|
913
|
+
Copyright (c) 1994-2020 Danny Sadinoff
|
|
914
|
+
Portions copyright Eyal Schachter and Michael J. Radwin
|
|
915
|
+
|
|
916
|
+
https://github.com/hebcal/hebcal-es6
|
|
917
|
+
|
|
918
|
+
This program is free software; you can redistribute it and/or
|
|
919
|
+
modify it under the terms of the GNU General Public License
|
|
920
|
+
as published by the Free Software Foundation; either version 2
|
|
921
|
+
of the License, or (at your option) any later version.
|
|
922
|
+
|
|
923
|
+
This program is distributed in the hope that it will be useful,
|
|
924
|
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
925
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
926
|
+
GNU General Public License for more details.
|
|
927
|
+
|
|
928
|
+
You should have received a copy of the GNU General Public License
|
|
929
|
+
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
930
|
+
*/
|
|
931
|
+
function mod(x, y) {
|
|
932
|
+
return x - y * Math.floor(x / y);
|
|
933
|
+
}
|
|
934
|
+
function isSimpleHebrewDate(obj) {
|
|
935
|
+
return obj.yy !== undefined;
|
|
936
|
+
}
|
|
937
|
+
const UNITS_DAY = 'day';
|
|
938
|
+
const UNITS_WEEK = 'week';
|
|
939
|
+
const UNITS_MONTH = 'month';
|
|
940
|
+
const UNITS_YEAR = 'year';
|
|
941
|
+
/**
|
|
942
|
+
* A `HDate` represents a Hebrew calendar date.
|
|
943
|
+
*
|
|
944
|
+
* An instance of this class encapsulates a date in the Hebrew calendar system.
|
|
945
|
+
* It consists of a year, month, and day, without any associated time or location data.
|
|
946
|
+
* The Hebrew calendar is a lunisolar calendar, meaning it is based on both lunar and solar cycles.
|
|
947
|
+
*
|
|
948
|
+
* A Hebrew date internally stores three numbers:
|
|
949
|
+
* - year: The Hebrew year (1-9999). Counted from the traditional Hebrew date of creation (3761 BCE in the Gregorian calendar)
|
|
950
|
+
* - 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.
|
|
951
|
+
* - day: The day of the month (1-30)
|
|
952
|
+
*
|
|
953
|
+
* This class uses Rata Die to convert between the Hebrew and Gregorian calendars.
|
|
954
|
+
*
|
|
955
|
+
* To calculate times of day, use `Zmanim` class from `@hebcal/core`
|
|
956
|
+
* @see {@link https://en.wikipedia.org/wiki/Rata_Die | Rata Die}
|
|
957
|
+
* @see {@link https://hebcal.github.io/api/core/classes/Zmanim.html | Zmanim}
|
|
958
|
+
*/
|
|
959
|
+
class HDate {
|
|
960
|
+
/**
|
|
961
|
+
* Create a Hebrew date. There are 3 basic forms for the `HDate()` constructor.
|
|
962
|
+
*
|
|
963
|
+
* 1. No parameters - represents the current Hebrew date at time of instantiation
|
|
964
|
+
* 2. One parameter
|
|
965
|
+
* * `Date` - represents the Hebrew date corresponding to the Gregorian date using
|
|
966
|
+
* local time. Hours, minutes, seconds and milliseconds are ignored.
|
|
967
|
+
* * `HDate` - clones a copy of the given Hebrew date
|
|
968
|
+
* * `number` - Converts absolute R.D. days to Hebrew date.
|
|
969
|
+
* R.D. 1 == the imaginary date January 1, 1 (Gregorian)
|
|
970
|
+
* 3. Three parameters: Hebrew day, Hebrew month, Hebrew year. Hebrew day should
|
|
971
|
+
* be a number between 1-30, Hebrew month can be a number or string, and
|
|
972
|
+
* Hebrew year is always a number.
|
|
973
|
+
* @example
|
|
974
|
+
* import {HDate, months} from '@hebcal/hdate';
|
|
975
|
+
*
|
|
976
|
+
* const hd1 = new HDate();
|
|
977
|
+
* const hd2 = new HDate(new Date(2008, 10, 13));
|
|
978
|
+
* const hd3 = new HDate(15, 'Cheshvan', 5769);
|
|
979
|
+
* const hd4 = new HDate(15, months.CHESHVAN, 5769);
|
|
980
|
+
* const hd5 = new HDate(733359); // ==> 15 Cheshvan 5769
|
|
981
|
+
* const monthName = 'אייר';
|
|
982
|
+
* const hd6 = new HDate(5, monthName, 5773);
|
|
983
|
+
* @param [day] - Day of month (1-30) if a `number`.
|
|
984
|
+
* If a `Date` is specified, represents the Hebrew date corresponding to the
|
|
985
|
+
* Gregorian date using local time.
|
|
986
|
+
* If an `HDate` is specified, clones a copy of the given Hebrew date.
|
|
987
|
+
* @param [month] - Hebrew month of year (1=NISAN, 7=TISHREI)
|
|
988
|
+
* @param [year] - Hebrew year
|
|
989
|
+
*/
|
|
990
|
+
constructor(day, month, year) {
|
|
991
|
+
if (arguments.length === 2 || arguments.length > 3) {
|
|
992
|
+
throw new TypeError('HDate constructor requires 0, 1 or 3 arguments');
|
|
993
|
+
}
|
|
994
|
+
if (arguments.length === 3) {
|
|
995
|
+
// Hebrew day, Hebrew month, Hebrew year
|
|
996
|
+
this.dd = this.mm = 1;
|
|
997
|
+
const yy = typeof year === 'string' ? parseInt(year, 10) : year;
|
|
998
|
+
if (isNaN(yy)) {
|
|
999
|
+
throw new TypeError(`HDate called with bad year: ${year}`);
|
|
1000
|
+
}
|
|
1001
|
+
this.yy = yy;
|
|
1002
|
+
setMonth(this, month); // will throw if we can't parse
|
|
1003
|
+
const dd = typeof day === 'string' ? parseInt(day, 10) : day;
|
|
1004
|
+
if (isNaN(dd)) {
|
|
1005
|
+
throw new TypeError(`HDate called with bad day: ${day}`);
|
|
1006
|
+
}
|
|
1007
|
+
setDate(this, dd);
|
|
1008
|
+
}
|
|
1009
|
+
else {
|
|
1010
|
+
// 0 arguments
|
|
1011
|
+
if (typeof day === 'undefined' || day === null) {
|
|
1012
|
+
day = new Date();
|
|
1013
|
+
}
|
|
1014
|
+
// 1 argument
|
|
1015
|
+
const abs0 = typeof day === 'number' && !isNaN(day)
|
|
1016
|
+
? day
|
|
1017
|
+
: isDate(day)
|
|
1018
|
+
? greg2abs(day)
|
|
1019
|
+
: isSimpleHebrewDate(day)
|
|
1020
|
+
? day
|
|
1021
|
+
: null;
|
|
1022
|
+
if (abs0 === null) {
|
|
1023
|
+
throw new TypeError(`HDate called with bad arg: ${day}`);
|
|
1024
|
+
}
|
|
1025
|
+
const isNumber = typeof abs0 === 'number';
|
|
1026
|
+
const d = isNumber ? abs2hebrew(abs0) : abs0;
|
|
1027
|
+
this.yy = d.yy;
|
|
1028
|
+
this.mm = d.mm;
|
|
1029
|
+
this.dd = d.dd;
|
|
1030
|
+
if (isNumber) {
|
|
1031
|
+
this.rd = abs0;
|
|
1032
|
+
}
|
|
1033
|
+
}
|
|
1034
|
+
}
|
|
1035
|
+
/**
|
|
1036
|
+
* Returns the Hebrew year of this Hebrew date
|
|
1037
|
+
* @returns an integer >= 1
|
|
1038
|
+
* @example
|
|
1039
|
+
* const hd = new HDate(new Date(2008, 10, 13)); // 15 Cheshvan 5769
|
|
1040
|
+
* hd.getFullYear(); // 5769
|
|
1041
|
+
*/
|
|
1042
|
+
getFullYear() {
|
|
1043
|
+
return this.yy;
|
|
1044
|
+
}
|
|
1045
|
+
/**
|
|
1046
|
+
* Returns `true` if this Hebrew date occurs during a Hebrew leap year
|
|
1047
|
+
* @example
|
|
1048
|
+
* const hd = new HDate(new Date(2008, 10, 13)); // 15 Cheshvan 5769
|
|
1049
|
+
* hd.isLeapYear(); // false
|
|
1050
|
+
*/
|
|
1051
|
+
isLeapYear() {
|
|
1052
|
+
return isLeapYear(this.yy);
|
|
1053
|
+
}
|
|
1054
|
+
/**
|
|
1055
|
+
* Returns the Hebrew month (1=NISAN, 7=TISHREI) of this Hebrew date
|
|
1056
|
+
* @returns an integer 1-13
|
|
1057
|
+
* @example
|
|
1058
|
+
* const hd = new HDate(new Date(2008, 10, 13)); // 15 Cheshvan 5769
|
|
1059
|
+
* hd.getMonth(); // 8
|
|
1060
|
+
*/
|
|
1061
|
+
getMonth() {
|
|
1062
|
+
return this.mm;
|
|
1063
|
+
}
|
|
1064
|
+
/**
|
|
1065
|
+
* The Tishrei-based month of this Hebrew date. 1 is Tishrei, 7 is Nisan, 13 is Elul in a leap year
|
|
1066
|
+
* @returns an integer 1-13
|
|
1067
|
+
* @example
|
|
1068
|
+
* const hd = new HDate(new Date(2008, 10, 13)); // 15 Cheshvan 5769
|
|
1069
|
+
* hd.getTishreiMonth(); // 2
|
|
1070
|
+
*/
|
|
1071
|
+
getTishreiMonth() {
|
|
1072
|
+
const nummonths = monthsInYear(this.getFullYear());
|
|
1073
|
+
return (this.getMonth() + nummonths - 6) % nummonths || nummonths;
|
|
1074
|
+
}
|
|
1075
|
+
/**
|
|
1076
|
+
* Number of days in the month of this Hebrew date (29 or 30)
|
|
1077
|
+
* @returns an integer 29-30
|
|
1078
|
+
* @example
|
|
1079
|
+
* const hd = new HDate(new Date(2008, 10, 13)); // 15 Cheshvan 5769
|
|
1080
|
+
* hd.daysInMonth(); // 29
|
|
1081
|
+
*/
|
|
1082
|
+
daysInMonth() {
|
|
1083
|
+
return daysInMonth(this.getMonth(), this.getFullYear());
|
|
1084
|
+
}
|
|
1085
|
+
/**
|
|
1086
|
+
* Gets the day within the month (1-30)
|
|
1087
|
+
* @returns an integer 1-30
|
|
1088
|
+
* @example
|
|
1089
|
+
* const hd = new HDate(new Date(2008, 10, 13)); // 15 Cheshvan 5769
|
|
1090
|
+
* hd.getDate(); // 15
|
|
1091
|
+
*/
|
|
1092
|
+
getDate() {
|
|
1093
|
+
return this.dd;
|
|
1094
|
+
}
|
|
1095
|
+
/**
|
|
1096
|
+
* Returns the day of the week for this Hebrew date,
|
|
1097
|
+
* where 0 represents Sunday, 1 represents Monday, 6 represents Saturday.
|
|
1098
|
+
*
|
|
1099
|
+
* For the day of the month, see `getDate()`
|
|
1100
|
+
* @returns an integer 0-6
|
|
1101
|
+
* @example
|
|
1102
|
+
* const hd = new HDate(new Date(2008, 10, 13)); // 15 Cheshvan 5769
|
|
1103
|
+
* hd.getDate(); // 4
|
|
1104
|
+
*/
|
|
1105
|
+
getDay() {
|
|
1106
|
+
return mod(this.abs(), 7);
|
|
1107
|
+
}
|
|
1108
|
+
/**
|
|
1109
|
+
* Converts this Hebrew date to the corresponding Gregorian date.
|
|
1110
|
+
*
|
|
1111
|
+
* The returned `Date` object will be in the local (i.e. host system) time zone.
|
|
1112
|
+
* Hours, minutes, seconds and milliseconds will all be zero.
|
|
1113
|
+
*
|
|
1114
|
+
* Note that this function returns the daytime portion of the date.
|
|
1115
|
+
* For example, the 15th of Cheshvan 5769 began at sundown on
|
|
1116
|
+
* 12 November 2008 and continues through 13 November 2008. This
|
|
1117
|
+
* function would return only the date 13 November 2008.
|
|
1118
|
+
* @example
|
|
1119
|
+
* const hd = new HDate(15, 'Cheshvan', 5769);
|
|
1120
|
+
* const date = hd.greg(); // 13 November 2008
|
|
1121
|
+
* const year = date.getFullYear(); // 2008
|
|
1122
|
+
* const monthNum = date.getMonth() + 1; // 11
|
|
1123
|
+
* const day = date.getDate(); // 13
|
|
1124
|
+
*/
|
|
1125
|
+
greg() {
|
|
1126
|
+
return abs2greg(this.abs());
|
|
1127
|
+
}
|
|
1128
|
+
/**
|
|
1129
|
+
* Converts from Hebrew date representation to R.D. (Rata Die) fixed days.
|
|
1130
|
+
* R.D. 1 is the imaginary date Monday, January 1, 1 (Gregorian).
|
|
1131
|
+
* Note also that R.D. = Julian Date − 1,721,424.5
|
|
1132
|
+
* @see {@link https://en.wikipedia.org/wiki/Rata_Die | Rata Die}
|
|
1133
|
+
* @example
|
|
1134
|
+
* const hd = new HDate(15, 'Cheshvan', 5769);
|
|
1135
|
+
* hd.abs(); // 733359
|
|
1136
|
+
*/
|
|
1137
|
+
abs() {
|
|
1138
|
+
if (typeof this.rd !== 'number') {
|
|
1139
|
+
this.rd = hebrew2abs(this.yy, this.mm, this.dd);
|
|
1140
|
+
}
|
|
1141
|
+
return this.rd;
|
|
1142
|
+
}
|
|
1143
|
+
/**
|
|
1144
|
+
* Converts Hebrew date to R.D. (Rata Die) fixed days.
|
|
1145
|
+
* R.D. 1 is the imaginary date Monday, January 1, 1 on the Gregorian
|
|
1146
|
+
* Calendar.
|
|
1147
|
+
* @param year Hebrew year
|
|
1148
|
+
* @param month Hebrew month (1=NISAN, 7=TISHREI)
|
|
1149
|
+
* @param day Hebrew date (1-30)
|
|
1150
|
+
* @example
|
|
1151
|
+
* import {HDate, months} from '@hebcal/hdate';
|
|
1152
|
+
* HDate.hebrew2abs(5769, months.CHESHVAN, 15); // 733359
|
|
1153
|
+
*/
|
|
1154
|
+
static hebrew2abs(year, month, day) {
|
|
1155
|
+
return hebrew2abs(year, month, day);
|
|
1156
|
+
}
|
|
1157
|
+
/**
|
|
1158
|
+
* Returns a transliterated Hebrew month name, e.g. `'Elul'` or `'Cheshvan'`.
|
|
1159
|
+
* @example
|
|
1160
|
+
* const hd = new HDate(new Date(2008, 10, 13)); // 15 Cheshvan 5769
|
|
1161
|
+
* hd.getMonthName(); // 'Cheshvan'
|
|
1162
|
+
*/
|
|
1163
|
+
getMonthName() {
|
|
1164
|
+
return getMonthName(this.getMonth(), this.getFullYear());
|
|
1165
|
+
}
|
|
1166
|
+
/**
|
|
1167
|
+
* Renders this Hebrew date as a translated or transliterated string,
|
|
1168
|
+
* including ordinal e.g. `'15th of Cheshvan, 5769'`.
|
|
1169
|
+
* @example
|
|
1170
|
+
* import {HDate, months} from '@hebcal/hdate';
|
|
1171
|
+
*
|
|
1172
|
+
* const hd = new HDate(15, months.CHESHVAN, 5769);
|
|
1173
|
+
* console.log(hd.render('en')); // '15th of Cheshvan, 5769'
|
|
1174
|
+
* console.log(hd.render('he')); // '15 חֶשְׁוָן, 5769'
|
|
1175
|
+
* console.log(hd.render('en', false)); // '15th of Cheshvan'
|
|
1176
|
+
* console.log(hd.render('he', false)); // '15 חֶשְׁוָן'
|
|
1177
|
+
* @param [locale] Optional locale name (defaults to active locale).
|
|
1178
|
+
* @param [showYear=true] Display year (defaults to true).
|
|
1179
|
+
* @see {@link Locale}
|
|
1180
|
+
*/
|
|
1181
|
+
render(locale, showYear = true) {
|
|
1182
|
+
const locale0 = locale || 'en';
|
|
1183
|
+
const day = this.getDate();
|
|
1184
|
+
const monthName0 = Locale.gettext(this.getMonthName(), locale0);
|
|
1185
|
+
const monthName = monthName0.replace(/'/g, '’');
|
|
1186
|
+
const nth = Locale.ordinal(day, locale0);
|
|
1187
|
+
const dayOf = getDayOfTranslation(locale0);
|
|
1188
|
+
const dateStr = `${nth}${dayOf} ${monthName}`;
|
|
1189
|
+
if (showYear) {
|
|
1190
|
+
const fullYear = this.getFullYear();
|
|
1191
|
+
return `${dateStr}, ${fullYear}`;
|
|
1192
|
+
}
|
|
1193
|
+
else {
|
|
1194
|
+
return dateStr;
|
|
1195
|
+
}
|
|
1196
|
+
}
|
|
1197
|
+
/**
|
|
1198
|
+
* Renders this Hebrew date in Hebrew gematriya, regardless of locale.
|
|
1199
|
+
* @param suppressNikud - suppress nekudot (default false)
|
|
1200
|
+
* @param suppressYear - suppress Hebrew year (default false)
|
|
1201
|
+
* @example
|
|
1202
|
+
* import {HDate, months} from '@hebcal/hdate';
|
|
1203
|
+
* const hd = new HDate(15, months.CHESHVAN, 5769);
|
|
1204
|
+
* hd.renderGematriya(); // 'ט״ו חֶשְׁוָן תשס״ט'
|
|
1205
|
+
* hd.renderGematriya(true); // 'ט״ו חשון תשס״ט'
|
|
1206
|
+
* hd.renderGematriya(false, true); // 'ט״ו חֶשְׁוָן'
|
|
1207
|
+
*/
|
|
1208
|
+
renderGematriya(suppressNikud = false, suppressYear = false) {
|
|
1209
|
+
const d = this.getDate();
|
|
1210
|
+
const locale = suppressNikud ? 'he-x-NoNikud' : 'he';
|
|
1211
|
+
const m = Locale.gettext(this.getMonthName(), locale);
|
|
1212
|
+
const prefix = gematriya(d) + ' ' + m;
|
|
1213
|
+
if (suppressYear) {
|
|
1214
|
+
return prefix;
|
|
1215
|
+
}
|
|
1216
|
+
const y = this.getFullYear();
|
|
1217
|
+
return prefix + ' ' + gematriya(y);
|
|
1218
|
+
}
|
|
1219
|
+
/**
|
|
1220
|
+
* Returns an `HDate` corresponding to the specified day of week
|
|
1221
|
+
* **before** this Hebrew date
|
|
1222
|
+
* @example
|
|
1223
|
+
* new HDate(new Date('Wednesday February 19, 2014')).before(6).greg() // Sat Feb 15 2014
|
|
1224
|
+
* @param dayOfWeek day of week: Sunday=0, Saturday=6
|
|
1225
|
+
*/
|
|
1226
|
+
before(dayOfWeek) {
|
|
1227
|
+
return onOrBefore(dayOfWeek, this, -1);
|
|
1228
|
+
}
|
|
1229
|
+
/**
|
|
1230
|
+
* Returns an `HDate` corresponding to the specified day of week
|
|
1231
|
+
* **on or before** this Hebrew date
|
|
1232
|
+
* @example
|
|
1233
|
+
* new HDate(new Date('Wednesday February 19, 2014')).onOrBefore(6).greg() // Sat Feb 15 2014
|
|
1234
|
+
* new HDate(new Date('Saturday February 22, 2014')).onOrBefore(6).greg() // Sat Feb 22 2014
|
|
1235
|
+
* new HDate(new Date('Sunday February 23, 2014')).onOrBefore(6).greg() // Sat Feb 22 2014
|
|
1236
|
+
* @param dayOfWeek day of week: Sunday=0, Saturday=6
|
|
1237
|
+
*/
|
|
1238
|
+
onOrBefore(dayOfWeek) {
|
|
1239
|
+
return onOrBefore(dayOfWeek, this, 0);
|
|
1240
|
+
}
|
|
1241
|
+
/**
|
|
1242
|
+
* Returns an `HDate` corresponding to the specified day of week
|
|
1243
|
+
* **nearest** to this Hebrew date
|
|
1244
|
+
* @example
|
|
1245
|
+
* new HDate(new Date('Wednesday February 19, 2014')).nearest(6).greg() // Sat Feb 22 2014
|
|
1246
|
+
* new HDate(new Date('Tuesday February 18, 2014')).nearest(6).greg() // Sat Feb 15 2014
|
|
1247
|
+
* @param dayOfWeek day of week: Sunday=0, Saturday=6
|
|
1248
|
+
*/
|
|
1249
|
+
nearest(dayOfWeek) {
|
|
1250
|
+
return onOrBefore(dayOfWeek, this, 3);
|
|
1251
|
+
}
|
|
1252
|
+
/**
|
|
1253
|
+
* Returns an `HDate` corresponding to the specified day of week
|
|
1254
|
+
* **on or after** this Hebrew date
|
|
1255
|
+
* @example
|
|
1256
|
+
* new HDate(new Date('Wednesday February 19, 2014')).onOrAfter(6).greg() // Sat Feb 22 2014
|
|
1257
|
+
* new HDate(new Date('Saturday February 22, 2014')).onOrAfter(6).greg() // Sat Feb 22 2014
|
|
1258
|
+
* new HDate(new Date('Sunday February 23, 2014')).onOrAfter(6).greg() // Sat Mar 01 2014
|
|
1259
|
+
* @param dayOfWeek day of week: Sunday=0, Saturday=6
|
|
1260
|
+
*/
|
|
1261
|
+
onOrAfter(dayOfWeek) {
|
|
1262
|
+
return onOrBefore(dayOfWeek, this, 6);
|
|
1263
|
+
}
|
|
1264
|
+
/**
|
|
1265
|
+
* Returns an `HDate` corresponding to the specified day of week
|
|
1266
|
+
* **after** this Hebrew date
|
|
1267
|
+
* @example
|
|
1268
|
+
* new HDate(new Date('Wednesday February 19, 2014')).after(6).greg() // Sat Feb 22 2014
|
|
1269
|
+
* new HDate(new Date('Saturday February 22, 2014')).after(6).greg() // Sat Mar 01 2014
|
|
1270
|
+
* new HDate(new Date('Sunday February 23, 2014')).after(6).greg() // Sat Mar 01 2014
|
|
1271
|
+
* @param dayOfWeek day of week: Sunday=0, Saturday=6
|
|
1272
|
+
*/
|
|
1273
|
+
after(dayOfWeek) {
|
|
1274
|
+
return onOrBefore(dayOfWeek, this, 7);
|
|
1275
|
+
}
|
|
1276
|
+
/**
|
|
1277
|
+
* Returns the next Hebrew date
|
|
1278
|
+
* @example
|
|
1279
|
+
* const hd = new HDate(new Date(2008, 10, 13)); // 15 Cheshvan 5769
|
|
1280
|
+
* hd.next(); // '16 Cheshvan 5769'
|
|
1281
|
+
*/
|
|
1282
|
+
next() {
|
|
1283
|
+
return new HDate(this.abs() + 1);
|
|
1284
|
+
}
|
|
1285
|
+
/**
|
|
1286
|
+
* Returns the previous Hebrew date
|
|
1287
|
+
* @example
|
|
1288
|
+
* const hd = new HDate(new Date(2008, 10, 13)); // 15 Cheshvan 5769
|
|
1289
|
+
* hd.prev(); // '14 Cheshvan 5769'
|
|
1290
|
+
*/
|
|
1291
|
+
prev() {
|
|
1292
|
+
return new HDate(this.abs() - 1);
|
|
1293
|
+
}
|
|
1294
|
+
/**
|
|
1295
|
+
* Returns a cloned `HDate` object with a specified amount of time added
|
|
1296
|
+
*
|
|
1297
|
+
* Units are case insensitive, and support plural and short forms.
|
|
1298
|
+
* Note, short forms are case sensitive.
|
|
1299
|
+
*
|
|
1300
|
+
* | Unit | Shorthand | Description
|
|
1301
|
+
* | --- | --- | --- |
|
|
1302
|
+
* | `day` | `d` | days |
|
|
1303
|
+
* | `week` | `w` | weeks |
|
|
1304
|
+
* | `month` | `M` | months |
|
|
1305
|
+
* | `year` | `y` | years |
|
|
1306
|
+
*/
|
|
1307
|
+
add(amount, units = 'd') {
|
|
1308
|
+
amount =
|
|
1309
|
+
typeof amount === 'string' ? parseInt(amount, 10) : amount;
|
|
1310
|
+
if (!amount) {
|
|
1311
|
+
return new HDate(this);
|
|
1312
|
+
}
|
|
1313
|
+
units = standardizeUnits(units);
|
|
1314
|
+
if (units === UNITS_DAY) {
|
|
1315
|
+
return new HDate(this.abs() + amount);
|
|
1316
|
+
}
|
|
1317
|
+
else if (units === UNITS_WEEK) {
|
|
1318
|
+
return new HDate(this.abs() + 7 * amount);
|
|
1319
|
+
}
|
|
1320
|
+
else if (units === UNITS_YEAR) {
|
|
1321
|
+
return new HDate(this.getDate(), this.getMonth(), this.getFullYear() + amount);
|
|
1322
|
+
}
|
|
1323
|
+
else {
|
|
1324
|
+
// units === UNITS_MONTH
|
|
1325
|
+
let hd = new HDate(this);
|
|
1326
|
+
const sign = amount > 0 ? 1 : -1;
|
|
1327
|
+
amount = Math.abs(amount);
|
|
1328
|
+
for (let i = 0; i < amount; i++) {
|
|
1329
|
+
hd = new HDate(hd.abs() + sign * hd.daysInMonth());
|
|
1330
|
+
}
|
|
1331
|
+
return hd;
|
|
1332
|
+
}
|
|
1333
|
+
}
|
|
1334
|
+
/**
|
|
1335
|
+
* Returns a cloned `HDate` object with a specified amount of time subracted
|
|
1336
|
+
*
|
|
1337
|
+
* Units are case insensitive, and support plural and short forms.
|
|
1338
|
+
* Note, short forms are case sensitive.
|
|
1339
|
+
*
|
|
1340
|
+
* | Unit | Shorthand | Description
|
|
1341
|
+
* | --- | --- | --- |
|
|
1342
|
+
* | `day` | `d` | days |
|
|
1343
|
+
* | `week` | `w` | weeks |
|
|
1344
|
+
* | `month` | `M` | months |
|
|
1345
|
+
* | `year` | `y` | years |
|
|
1346
|
+
* @example
|
|
1347
|
+
* import {HDate, months} from '@hebcal/hdate';
|
|
1348
|
+
*
|
|
1349
|
+
* const hd1 = new HDate(15, months.CHESHVAN, 5769);
|
|
1350
|
+
* const hd2 = hd1.add(1, 'weeks'); // 7 Kislev 5769
|
|
1351
|
+
* const hd3 = hd1.add(-3, 'M'); // 30 Av 5768
|
|
1352
|
+
*/
|
|
1353
|
+
subtract(amount, units = 'd') {
|
|
1354
|
+
return this.add(amount * -1, units);
|
|
1355
|
+
}
|
|
1356
|
+
/**
|
|
1357
|
+
* Returns the difference in days between the two given HDates.
|
|
1358
|
+
*
|
|
1359
|
+
* The result is positive if `this` date is comes chronologically
|
|
1360
|
+
* after the `other` date, and negative
|
|
1361
|
+
* if the order of the two dates is reversed.
|
|
1362
|
+
*
|
|
1363
|
+
* The result is zero if the two dates are identical.
|
|
1364
|
+
* @example
|
|
1365
|
+
* import {HDate, months} from '@hebcal/hdate';
|
|
1366
|
+
*
|
|
1367
|
+
* const hd1 = new HDate(25, months.KISLEV, 5770);
|
|
1368
|
+
* const hd2 = new HDate(15, months.CHESHVAN, 5769);
|
|
1369
|
+
* const days = hd1.deltaDays(hd2); // 394
|
|
1370
|
+
* @param other Hebrew date to compare
|
|
1371
|
+
*/
|
|
1372
|
+
deltaDays(other) {
|
|
1373
|
+
return this.abs() - other.abs();
|
|
1374
|
+
}
|
|
1375
|
+
/**
|
|
1376
|
+
* Compares this Hebrew date to another date, returning `true` if the dates match.
|
|
1377
|
+
* @param other Hebrew date to compare
|
|
1378
|
+
* @example
|
|
1379
|
+
* const hd1 = new HDate(new Date(2008, 10, 13));
|
|
1380
|
+
* const hd2 = new HDate(15, 'Cheshvan', 5769);
|
|
1381
|
+
* hd1.isSameDate(hd2); // true
|
|
1382
|
+
*/
|
|
1383
|
+
isSameDate(other) {
|
|
1384
|
+
return this.yy === other.yy && this.mm === other.mm && this.dd === other.dd;
|
|
1385
|
+
}
|
|
1386
|
+
/**
|
|
1387
|
+
* Returns a string representation of this Hebrew date using English transliterations
|
|
1388
|
+
* @example
|
|
1389
|
+
* const hd = new HDate(new Date(2008, 10, 13)); // 15 Cheshvan 5769
|
|
1390
|
+
* hd.toString(); // '15 Cheshvan 5769'
|
|
1391
|
+
*/
|
|
1392
|
+
toString() {
|
|
1393
|
+
const day = this.getDate();
|
|
1394
|
+
const fullYear = this.getFullYear();
|
|
1395
|
+
const monthName = this.getMonthName();
|
|
1396
|
+
return `${day} ${monthName} ${fullYear}`;
|
|
1397
|
+
}
|
|
1398
|
+
/**
|
|
1399
|
+
* Returns true if Hebrew year is a leap year
|
|
1400
|
+
* @param year Hebrew year
|
|
1401
|
+
* @example
|
|
1402
|
+
* HDate.isLeapYear(5783); // false
|
|
1403
|
+
* HDate.isLeapYear(5784); // true
|
|
1404
|
+
*/
|
|
1405
|
+
static isLeapYear(year) {
|
|
1406
|
+
return isLeapYear(year);
|
|
1407
|
+
}
|
|
1408
|
+
/**
|
|
1409
|
+
* Number of months in this Hebrew year (either 12 or 13 depending on leap year)
|
|
1410
|
+
* @param year Hebrew year
|
|
1411
|
+
* @example
|
|
1412
|
+
* HDate.monthsInYear(5783); // 12
|
|
1413
|
+
* HDate.monthsInYear(5784); // 13
|
|
1414
|
+
*/
|
|
1415
|
+
static monthsInYear(year) {
|
|
1416
|
+
return monthsInYear(year);
|
|
1417
|
+
}
|
|
1418
|
+
/**
|
|
1419
|
+
* Number of days in Hebrew month in a given year (29 or 30)
|
|
1420
|
+
* @param month Hebrew month (e.g. months.TISHREI)
|
|
1421
|
+
* @param year Hebrew year
|
|
1422
|
+
* @example
|
|
1423
|
+
* import {HDate, months} from '@hebcal/hdate';
|
|
1424
|
+
* HDate.daysInMonth(months.CHESHVAN, 5769); // 29
|
|
1425
|
+
*/
|
|
1426
|
+
static daysInMonth(month, year) {
|
|
1427
|
+
return daysInMonth(month, year);
|
|
1428
|
+
}
|
|
1429
|
+
/**
|
|
1430
|
+
* Returns a transliterated string name of Hebrew month in year,
|
|
1431
|
+
* for example 'Elul' or 'Cheshvan'.
|
|
1432
|
+
* @param month Hebrew month (e.g. months.TISHREI)
|
|
1433
|
+
* @param year Hebrew year
|
|
1434
|
+
* @example
|
|
1435
|
+
* import {HDate, months} from '@hebcal/hdate';
|
|
1436
|
+
* HDate.getMonthName(months.CHESHVAN, 5769); // 'Cheshvan'
|
|
1437
|
+
*/
|
|
1438
|
+
static getMonthName(month, year) {
|
|
1439
|
+
return getMonthName(month, year);
|
|
1440
|
+
}
|
|
1441
|
+
/**
|
|
1442
|
+
* Returns the Hebrew month number (NISAN=1, TISHREI=7)
|
|
1443
|
+
* @param month A number, or Hebrew month name string
|
|
1444
|
+
* @example
|
|
1445
|
+
* import {HDate, months} from '@hebcal/hdate';
|
|
1446
|
+
* HDate.monthNum(months.CHESHVAN); // 8
|
|
1447
|
+
* HDate.monthNum('Cheshvan'); // 8
|
|
1448
|
+
* HDate.monthNum('חשון'); // 8
|
|
1449
|
+
*/
|
|
1450
|
+
static monthNum(month) {
|
|
1451
|
+
if (typeof month === 'number') {
|
|
1452
|
+
if (isNaN(month) || month > 14) {
|
|
1453
|
+
throw new RangeError(`bad monthNum: ${month}`);
|
|
1454
|
+
}
|
|
1455
|
+
return month;
|
|
1456
|
+
}
|
|
1457
|
+
return month.charCodeAt(0) >= 48 && month.charCodeAt(0) <= 57 /* number */
|
|
1458
|
+
? parseInt(month, 10)
|
|
1459
|
+
: monthFromName(month);
|
|
1460
|
+
}
|
|
1461
|
+
/**
|
|
1462
|
+
* Number of days in the Hebrew year.
|
|
1463
|
+
* Regular years can have 353, 354, or 355 days.
|
|
1464
|
+
* Leap years can have 383, 384, or 385 days.
|
|
1465
|
+
* @param year Hebrew year
|
|
1466
|
+
* @example
|
|
1467
|
+
* HDate.daysInYear(5783); // 355
|
|
1468
|
+
* HDate.daysInYear(5784); // 383
|
|
1469
|
+
*/
|
|
1470
|
+
static daysInYear(year) {
|
|
1471
|
+
return daysInYear(year);
|
|
1472
|
+
}
|
|
1473
|
+
/**
|
|
1474
|
+
* true if Cheshvan is long in Hebrew year
|
|
1475
|
+
* @param year Hebrew year
|
|
1476
|
+
* @example
|
|
1477
|
+
* HDate.longCheshvan(5783); // true
|
|
1478
|
+
* HDate.longCheshvan(5784); // false
|
|
1479
|
+
*/
|
|
1480
|
+
static longCheshvan(year) {
|
|
1481
|
+
return longCheshvan(year);
|
|
1482
|
+
}
|
|
1483
|
+
/**
|
|
1484
|
+
* true if Kislev is short in Hebrew year
|
|
1485
|
+
* @param year Hebrew year
|
|
1486
|
+
* @example
|
|
1487
|
+
* HDate.shortKislev(5783); // false
|
|
1488
|
+
* HDate.shortKislev(5784); // true
|
|
1489
|
+
*/
|
|
1490
|
+
static shortKislev(year) {
|
|
1491
|
+
return shortKislev(year);
|
|
1492
|
+
}
|
|
1493
|
+
/**
|
|
1494
|
+
* Converts Hebrew month string name to numeric
|
|
1495
|
+
* @example
|
|
1496
|
+
* import {HDate, months} from '@hebcal/hdate';
|
|
1497
|
+
* HDate.monthFromName(months.CHESHVAN); // 8
|
|
1498
|
+
* HDate.monthFromName('Cheshvan'); // 8
|
|
1499
|
+
* HDate.monthFromName('חשון'); // 8
|
|
1500
|
+
*/
|
|
1501
|
+
static monthFromName(monthName) {
|
|
1502
|
+
return monthFromName(monthName);
|
|
1503
|
+
}
|
|
1504
|
+
/**
|
|
1505
|
+
* Convenience function for determining the R.D. date
|
|
1506
|
+
* near a specified R.D. date, corresponding to the specified day of week.
|
|
1507
|
+
*
|
|
1508
|
+
* Note: Applying this function to d+6 gives us the `dayOfWeek` on or after an
|
|
1509
|
+
* absolute day d. Similarly, applying it to d+3 gives the `dayOfWeek` nearest to
|
|
1510
|
+
* absolute date d, applying it to d-1 gives the `dayOfWeek` previous to absolute
|
|
1511
|
+
* date d, and applying it to d+7 gives the `dayOfWeek` following absolute date d.
|
|
1512
|
+
* @param dayOfWeek day of week: Sunday=0, Saturday=6
|
|
1513
|
+
*/
|
|
1514
|
+
static dayOnOrBefore(dayOfWeek, absdate) {
|
|
1515
|
+
return absdate - ((absdate - dayOfWeek) % 7);
|
|
1516
|
+
}
|
|
1517
|
+
/**
|
|
1518
|
+
* Tests if the object is an instance of `HDate`
|
|
1519
|
+
* @example
|
|
1520
|
+
* HDate.isHDate(new HDate()); // true
|
|
1521
|
+
* HDate.isHDate(new Date()); // false
|
|
1522
|
+
* HDate.isHDate(null); // false
|
|
1523
|
+
* HDate.isHDate(12345); // false
|
|
1524
|
+
* HDate.isHDate('15 Cheshvan 5769'); // false
|
|
1525
|
+
*/
|
|
1526
|
+
static isHDate(obj) {
|
|
1527
|
+
return (obj !== null &&
|
|
1528
|
+
typeof obj === 'object' &&
|
|
1529
|
+
typeof obj.yy === 'number' &&
|
|
1530
|
+
typeof obj.mm === 'number' &&
|
|
1531
|
+
typeof obj.dd === 'number' &&
|
|
1532
|
+
typeof obj.greg === 'function' &&
|
|
1533
|
+
typeof obj.abs === 'function');
|
|
1534
|
+
}
|
|
1535
|
+
/**
|
|
1536
|
+
* Construct a new instance of `HDate` from a Gematriya-formatted string
|
|
1537
|
+
* @example
|
|
1538
|
+
* HDate.fromGematriyaString('כ״ז בְּתַמּוּז תשפ״ג') // 27 Tamuz 5783
|
|
1539
|
+
* HDate.fromGematriyaString('כ׳ סיון תש״ד') // 20 Sivan 5704
|
|
1540
|
+
* HDate.fromGematriyaString('ה׳ אִיָיר תש״ח') // 5 Iyyar 5708
|
|
1541
|
+
*/
|
|
1542
|
+
static fromGematriyaString(str, currentThousands = 5000) {
|
|
1543
|
+
const parts = str.split(' ').filter(x => x.length !== 0);
|
|
1544
|
+
const numParts = parts.length;
|
|
1545
|
+
if (numParts !== 3 && numParts !== 4) {
|
|
1546
|
+
throw new RangeError(`cannot parse gematriya str: "${str}"`);
|
|
1547
|
+
}
|
|
1548
|
+
const day = gematriyaStrToNum(parts[0]);
|
|
1549
|
+
const monthStr = numParts === 3 ? parts[1] : parts[1] + ' ' + parts[2];
|
|
1550
|
+
const month = monthFromName(monthStr);
|
|
1551
|
+
const yearStr = numParts === 3 ? parts[2] : parts[3];
|
|
1552
|
+
let year = gematriyaStrToNum(yearStr);
|
|
1553
|
+
if (year < 1000) {
|
|
1554
|
+
year += currentThousands;
|
|
1555
|
+
}
|
|
1556
|
+
return new HDate(day, month, year);
|
|
1557
|
+
}
|
|
1558
|
+
}
|
|
1559
|
+
function standardizeUnits(units) {
|
|
1560
|
+
switch (units) {
|
|
1561
|
+
case 'd':
|
|
1562
|
+
return UNITS_DAY;
|
|
1563
|
+
case 'w':
|
|
1564
|
+
return UNITS_WEEK;
|
|
1565
|
+
case 'M':
|
|
1566
|
+
return UNITS_MONTH;
|
|
1567
|
+
case 'y':
|
|
1568
|
+
return UNITS_YEAR;
|
|
1569
|
+
}
|
|
1570
|
+
const str = String(units || '')
|
|
1571
|
+
.toLowerCase()
|
|
1572
|
+
.replace(/s$/, '');
|
|
1573
|
+
switch (str) {
|
|
1574
|
+
case UNITS_DAY:
|
|
1575
|
+
case UNITS_WEEK:
|
|
1576
|
+
case UNITS_MONTH:
|
|
1577
|
+
case UNITS_YEAR:
|
|
1578
|
+
return str;
|
|
1579
|
+
}
|
|
1580
|
+
throw new TypeError(`Invalid units '${units}'`);
|
|
1581
|
+
}
|
|
1582
|
+
function getDayOfTranslation(locale) {
|
|
1583
|
+
switch (locale) {
|
|
1584
|
+
case 'en':
|
|
1585
|
+
case 's':
|
|
1586
|
+
case 'a':
|
|
1587
|
+
case 'ashkenazi':
|
|
1588
|
+
return ' of';
|
|
1589
|
+
}
|
|
1590
|
+
const ofStr = Locale.lookupTranslation('of', locale);
|
|
1591
|
+
if (ofStr) {
|
|
1592
|
+
return ' ' + ofStr;
|
|
1593
|
+
}
|
|
1594
|
+
if (locale.startsWith('ashkenazi')) {
|
|
1595
|
+
return ' of';
|
|
1596
|
+
}
|
|
1597
|
+
return '';
|
|
1598
|
+
}
|
|
1599
|
+
/**
|
|
1600
|
+
* Sets the day of the month of the date. Returns the object it was called upon
|
|
1601
|
+
* @private
|
|
1602
|
+
* @param month A number, or Hebrew month name string
|
|
1603
|
+
*/
|
|
1604
|
+
function setMonth(hd, month) {
|
|
1605
|
+
hd.mm = HDate.monthNum(month);
|
|
1606
|
+
fix(hd);
|
|
1607
|
+
return hd;
|
|
1608
|
+
}
|
|
1609
|
+
function setDate(hd, date) {
|
|
1610
|
+
hd.dd = date;
|
|
1611
|
+
fix(hd);
|
|
1612
|
+
return hd;
|
|
1613
|
+
}
|
|
1614
|
+
function fix(hd) {
|
|
1615
|
+
fixMonth(hd);
|
|
1616
|
+
fixDate(hd);
|
|
1617
|
+
}
|
|
1618
|
+
function fixDate(hd) {
|
|
1619
|
+
if (hd.dd < 1) {
|
|
1620
|
+
if (hd.mm === months.TISHREI) {
|
|
1621
|
+
hd.yy -= 1;
|
|
1622
|
+
}
|
|
1623
|
+
hd.dd += daysInMonth(hd.mm, hd.yy);
|
|
1624
|
+
hd.mm -= 1;
|
|
1625
|
+
fix(hd);
|
|
1626
|
+
}
|
|
1627
|
+
if (hd.dd > daysInMonth(hd.mm, hd.yy)) {
|
|
1628
|
+
if (hd.mm === months.ELUL) {
|
|
1629
|
+
hd.yy += 1;
|
|
1630
|
+
}
|
|
1631
|
+
hd.dd -= daysInMonth(hd.mm, hd.yy);
|
|
1632
|
+
if (hd.mm === monthsInYear(hd.yy)) {
|
|
1633
|
+
hd.mm = 1; // rollover to NISAN
|
|
1634
|
+
}
|
|
1635
|
+
else {
|
|
1636
|
+
hd.mm += 1;
|
|
1637
|
+
}
|
|
1638
|
+
fix(hd);
|
|
1639
|
+
}
|
|
1640
|
+
fixMonth(hd);
|
|
1641
|
+
}
|
|
1642
|
+
function fixMonth(hd) {
|
|
1643
|
+
if (hd.mm === months.ADAR_II && !hd.isLeapYear()) {
|
|
1644
|
+
hd.mm -= 1; // to Adar I
|
|
1645
|
+
fix(hd);
|
|
1646
|
+
}
|
|
1647
|
+
else if (hd.mm < 1) {
|
|
1648
|
+
hd.mm += monthsInYear(hd.yy);
|
|
1649
|
+
hd.yy -= 1;
|
|
1650
|
+
fix(hd);
|
|
1651
|
+
}
|
|
1652
|
+
else if (hd.mm > monthsInYear(hd.yy)) {
|
|
1653
|
+
hd.mm -= monthsInYear(hd.yy);
|
|
1654
|
+
hd.yy += 1;
|
|
1655
|
+
fix(hd);
|
|
1656
|
+
}
|
|
1657
|
+
delete hd.rd;
|
|
1658
|
+
}
|
|
1659
|
+
function onOrBefore(day, t, offset) {
|
|
1660
|
+
return new HDate(HDate.dayOnOrBefore(day, t.abs() + offset));
|
|
1661
|
+
}
|
|
1662
|
+
class QuickLRU extends Map {
|
|
1663
|
+
constructor(options = {}) {
|
|
1664
|
+
super();
|
|
1665
|
+
_QuickLRU_instances.add(this);
|
|
1666
|
+
_QuickLRU_size.set(this, 0);
|
|
1667
|
+
_QuickLRU_cache.set(this, new Map());
|
|
1668
|
+
_QuickLRU_oldCache.set(this, new Map());
|
|
1669
|
+
_QuickLRU_maxSize.set(this, void 0);
|
|
1670
|
+
_QuickLRU_maxAge.set(this, void 0);
|
|
1671
|
+
_QuickLRU_onEviction.set(this, void 0);
|
|
1672
|
+
if (!(options.maxSize && options.maxSize > 0)) {
|
|
1673
|
+
throw new TypeError('`maxSize` must be a number greater than 0');
|
|
1674
|
+
}
|
|
1675
|
+
if (typeof options.maxAge === 'number' && options.maxAge === 0) {
|
|
1676
|
+
throw new TypeError('`maxAge` must be a number greater than 0');
|
|
1677
|
+
}
|
|
1678
|
+
__classPrivateFieldSet(this, _QuickLRU_maxSize, options.maxSize, "f");
|
|
1679
|
+
__classPrivateFieldSet(this, _QuickLRU_maxAge, options.maxAge || Number.POSITIVE_INFINITY, "f");
|
|
1680
|
+
__classPrivateFieldSet(this, _QuickLRU_onEviction, options.onEviction, "f");
|
|
1681
|
+
}
|
|
1682
|
+
// For tests.
|
|
1683
|
+
get __oldCache() {
|
|
1684
|
+
return __classPrivateFieldGet(this, _QuickLRU_oldCache, "f");
|
|
1685
|
+
}
|
|
1686
|
+
get(key) {
|
|
1687
|
+
if (__classPrivateFieldGet(this, _QuickLRU_cache, "f").has(key)) {
|
|
1688
|
+
const item = __classPrivateFieldGet(this, _QuickLRU_cache, "f").get(key);
|
|
1689
|
+
return __classPrivateFieldGet(this, _QuickLRU_instances, "m", _QuickLRU_getItemValue).call(this, key, item);
|
|
1690
|
+
}
|
|
1691
|
+
if (__classPrivateFieldGet(this, _QuickLRU_oldCache, "f").has(key)) {
|
|
1692
|
+
const item = __classPrivateFieldGet(this, _QuickLRU_oldCache, "f").get(key);
|
|
1693
|
+
if (__classPrivateFieldGet(this, _QuickLRU_instances, "m", _QuickLRU_deleteIfExpired).call(this, key, item) === false) {
|
|
1694
|
+
__classPrivateFieldGet(this, _QuickLRU_instances, "m", _QuickLRU_moveToRecent).call(this, key, item);
|
|
1695
|
+
return item.value;
|
|
1696
|
+
}
|
|
1697
|
+
}
|
|
1698
|
+
}
|
|
1699
|
+
set(key, value, { maxAge = __classPrivateFieldGet(this, _QuickLRU_maxAge, "f") } = {}) {
|
|
1700
|
+
const expiry = typeof maxAge === 'number' && maxAge !== Number.POSITIVE_INFINITY
|
|
1701
|
+
? (Date.now() + maxAge)
|
|
1702
|
+
: undefined;
|
|
1703
|
+
if (__classPrivateFieldGet(this, _QuickLRU_cache, "f").has(key)) {
|
|
1704
|
+
__classPrivateFieldGet(this, _QuickLRU_cache, "f").set(key, {
|
|
1705
|
+
value,
|
|
1706
|
+
expiry,
|
|
1707
|
+
});
|
|
1708
|
+
}
|
|
1709
|
+
else {
|
|
1710
|
+
__classPrivateFieldGet(this, _QuickLRU_instances, "m", _QuickLRU_set).call(this, key, { value, expiry });
|
|
1711
|
+
}
|
|
1712
|
+
return this;
|
|
1713
|
+
}
|
|
1714
|
+
has(key) {
|
|
1715
|
+
if (__classPrivateFieldGet(this, _QuickLRU_cache, "f").has(key)) {
|
|
1716
|
+
return !__classPrivateFieldGet(this, _QuickLRU_instances, "m", _QuickLRU_deleteIfExpired).call(this, key, __classPrivateFieldGet(this, _QuickLRU_cache, "f").get(key));
|
|
1717
|
+
}
|
|
1718
|
+
if (__classPrivateFieldGet(this, _QuickLRU_oldCache, "f").has(key)) {
|
|
1719
|
+
return !__classPrivateFieldGet(this, _QuickLRU_instances, "m", _QuickLRU_deleteIfExpired).call(this, key, __classPrivateFieldGet(this, _QuickLRU_oldCache, "f").get(key));
|
|
1720
|
+
}
|
|
1721
|
+
return false;
|
|
1722
|
+
}
|
|
1723
|
+
peek(key) {
|
|
1724
|
+
if (__classPrivateFieldGet(this, _QuickLRU_cache, "f").has(key)) {
|
|
1725
|
+
return __classPrivateFieldGet(this, _QuickLRU_instances, "m", _QuickLRU_peek).call(this, key, __classPrivateFieldGet(this, _QuickLRU_cache, "f"));
|
|
1726
|
+
}
|
|
1727
|
+
if (__classPrivateFieldGet(this, _QuickLRU_oldCache, "f").has(key)) {
|
|
1728
|
+
return __classPrivateFieldGet(this, _QuickLRU_instances, "m", _QuickLRU_peek).call(this, key, __classPrivateFieldGet(this, _QuickLRU_oldCache, "f"));
|
|
1729
|
+
}
|
|
1730
|
+
}
|
|
1731
|
+
expiresIn(key) {
|
|
1732
|
+
var _a;
|
|
1733
|
+
const item = (_a = __classPrivateFieldGet(this, _QuickLRU_cache, "f").get(key)) !== null && _a !== void 0 ? _a : __classPrivateFieldGet(this, _QuickLRU_oldCache, "f").get(key);
|
|
1734
|
+
if (item) {
|
|
1735
|
+
return item.expiry ? item.expiry - Date.now() : Number.POSITIVE_INFINITY;
|
|
1736
|
+
}
|
|
1737
|
+
}
|
|
1738
|
+
delete(key) {
|
|
1739
|
+
var _a;
|
|
1740
|
+
const deleted = __classPrivateFieldGet(this, _QuickLRU_cache, "f").delete(key);
|
|
1741
|
+
if (deleted) {
|
|
1742
|
+
__classPrivateFieldSet(this, _QuickLRU_size, (_a = __classPrivateFieldGet(this, _QuickLRU_size, "f"), _a--, _a), "f");
|
|
1743
|
+
}
|
|
1744
|
+
return __classPrivateFieldGet(this, _QuickLRU_oldCache, "f").delete(key) || deleted;
|
|
1745
|
+
}
|
|
1746
|
+
clear() {
|
|
1747
|
+
__classPrivateFieldGet(this, _QuickLRU_cache, "f").clear();
|
|
1748
|
+
__classPrivateFieldGet(this, _QuickLRU_oldCache, "f").clear();
|
|
1749
|
+
__classPrivateFieldSet(this, _QuickLRU_size, 0, "f");
|
|
1750
|
+
}
|
|
1751
|
+
resize(newSize) {
|
|
1752
|
+
if (!(newSize && newSize > 0)) {
|
|
1753
|
+
throw new TypeError('`maxSize` must be a number greater than 0');
|
|
1754
|
+
}
|
|
1755
|
+
const items = [...__classPrivateFieldGet(this, _QuickLRU_instances, "m", _QuickLRU_entriesAscending).call(this)];
|
|
1756
|
+
const removeCount = items.length - newSize;
|
|
1757
|
+
if (removeCount < 0) {
|
|
1758
|
+
__classPrivateFieldSet(this, _QuickLRU_cache, new Map(items), "f");
|
|
1759
|
+
__classPrivateFieldSet(this, _QuickLRU_oldCache, new Map(), "f");
|
|
1760
|
+
__classPrivateFieldSet(this, _QuickLRU_size, items.length, "f");
|
|
1761
|
+
}
|
|
1762
|
+
else {
|
|
1763
|
+
if (removeCount > 0) {
|
|
1764
|
+
__classPrivateFieldGet(this, _QuickLRU_instances, "m", _QuickLRU_emitEvictions).call(this, items.slice(0, removeCount));
|
|
1765
|
+
}
|
|
1766
|
+
__classPrivateFieldSet(this, _QuickLRU_oldCache, new Map(items.slice(removeCount)), "f");
|
|
1767
|
+
__classPrivateFieldSet(this, _QuickLRU_cache, new Map(), "f");
|
|
1768
|
+
__classPrivateFieldSet(this, _QuickLRU_size, 0, "f");
|
|
1769
|
+
}
|
|
1770
|
+
__classPrivateFieldSet(this, _QuickLRU_maxSize, newSize, "f");
|
|
1771
|
+
}
|
|
1772
|
+
evict(count = 1) {
|
|
1773
|
+
const requested = Number(count);
|
|
1774
|
+
if (!requested || requested <= 0) {
|
|
1775
|
+
return;
|
|
1776
|
+
}
|
|
1777
|
+
const items = [...__classPrivateFieldGet(this, _QuickLRU_instances, "m", _QuickLRU_entriesAscending).call(this)];
|
|
1778
|
+
const evictCount = Math.trunc(Math.min(requested, Math.max(items.length - 1, 0)));
|
|
1779
|
+
if (evictCount <= 0) {
|
|
1780
|
+
return;
|
|
1781
|
+
}
|
|
1782
|
+
__classPrivateFieldGet(this, _QuickLRU_instances, "m", _QuickLRU_emitEvictions).call(this, items.slice(0, evictCount));
|
|
1783
|
+
__classPrivateFieldSet(this, _QuickLRU_oldCache, new Map(items.slice(evictCount)), "f");
|
|
1784
|
+
__classPrivateFieldSet(this, _QuickLRU_cache, new Map(), "f");
|
|
1785
|
+
__classPrivateFieldSet(this, _QuickLRU_size, 0, "f");
|
|
1786
|
+
}
|
|
1787
|
+
*keys() {
|
|
1788
|
+
for (const [key] of this) {
|
|
1789
|
+
yield key;
|
|
1790
|
+
}
|
|
1791
|
+
}
|
|
1792
|
+
*values() {
|
|
1793
|
+
for (const [, value] of this) {
|
|
1794
|
+
yield value;
|
|
1795
|
+
}
|
|
1796
|
+
}
|
|
1797
|
+
*[(_QuickLRU_size = new WeakMap(), _QuickLRU_cache = new WeakMap(), _QuickLRU_oldCache = new WeakMap(), _QuickLRU_maxSize = new WeakMap(), _QuickLRU_maxAge = new WeakMap(), _QuickLRU_onEviction = new WeakMap(), _QuickLRU_instances = new WeakSet(), _QuickLRU_emitEvictions = function _QuickLRU_emitEvictions(cache) {
|
|
1798
|
+
if (typeof __classPrivateFieldGet(this, _QuickLRU_onEviction, "f") !== 'function') {
|
|
1799
|
+
return;
|
|
1800
|
+
}
|
|
1801
|
+
for (const [key, item] of cache) {
|
|
1802
|
+
__classPrivateFieldGet(this, _QuickLRU_onEviction, "f").call(this, key, item.value);
|
|
1803
|
+
}
|
|
1804
|
+
}, _QuickLRU_deleteIfExpired = function _QuickLRU_deleteIfExpired(key, item) {
|
|
1805
|
+
if (typeof item.expiry === 'number' && item.expiry <= Date.now()) {
|
|
1806
|
+
if (typeof __classPrivateFieldGet(this, _QuickLRU_onEviction, "f") === 'function') {
|
|
1807
|
+
__classPrivateFieldGet(this, _QuickLRU_onEviction, "f").call(this, key, item.value);
|
|
1808
|
+
}
|
|
1809
|
+
return this.delete(key);
|
|
1810
|
+
}
|
|
1811
|
+
return false;
|
|
1812
|
+
}, _QuickLRU_getOrDeleteIfExpired = function _QuickLRU_getOrDeleteIfExpired(key, item) {
|
|
1813
|
+
const deleted = __classPrivateFieldGet(this, _QuickLRU_instances, "m", _QuickLRU_deleteIfExpired).call(this, key, item);
|
|
1814
|
+
if (deleted === false) {
|
|
1815
|
+
return item.value;
|
|
1816
|
+
}
|
|
1817
|
+
}, _QuickLRU_getItemValue = function _QuickLRU_getItemValue(key, item) {
|
|
1818
|
+
return item.expiry ? __classPrivateFieldGet(this, _QuickLRU_instances, "m", _QuickLRU_getOrDeleteIfExpired).call(this, key, item) : item.value;
|
|
1819
|
+
}, _QuickLRU_peek = function _QuickLRU_peek(key, cache) {
|
|
1820
|
+
const item = cache.get(key);
|
|
1821
|
+
return __classPrivateFieldGet(this, _QuickLRU_instances, "m", _QuickLRU_getItemValue).call(this, key, item);
|
|
1822
|
+
}, _QuickLRU_set = function _QuickLRU_set(key, value) {
|
|
1823
|
+
var _a;
|
|
1824
|
+
__classPrivateFieldGet(this, _QuickLRU_cache, "f").set(key, value);
|
|
1825
|
+
__classPrivateFieldSet(this, _QuickLRU_size, (_a = __classPrivateFieldGet(this, _QuickLRU_size, "f"), _a++, _a), "f");
|
|
1826
|
+
if (__classPrivateFieldGet(this, _QuickLRU_size, "f") >= __classPrivateFieldGet(this, _QuickLRU_maxSize, "f")) {
|
|
1827
|
+
__classPrivateFieldSet(this, _QuickLRU_size, 0, "f");
|
|
1828
|
+
__classPrivateFieldGet(this, _QuickLRU_instances, "m", _QuickLRU_emitEvictions).call(this, __classPrivateFieldGet(this, _QuickLRU_oldCache, "f"));
|
|
1829
|
+
__classPrivateFieldSet(this, _QuickLRU_oldCache, __classPrivateFieldGet(this, _QuickLRU_cache, "f"), "f");
|
|
1830
|
+
__classPrivateFieldSet(this, _QuickLRU_cache, new Map(), "f");
|
|
1831
|
+
}
|
|
1832
|
+
}, _QuickLRU_moveToRecent = function _QuickLRU_moveToRecent(key, item) {
|
|
1833
|
+
__classPrivateFieldGet(this, _QuickLRU_oldCache, "f").delete(key);
|
|
1834
|
+
__classPrivateFieldGet(this, _QuickLRU_instances, "m", _QuickLRU_set).call(this, key, item);
|
|
1835
|
+
}, _QuickLRU_entriesAscending = function* _QuickLRU_entriesAscending() {
|
|
1836
|
+
for (const item of __classPrivateFieldGet(this, _QuickLRU_oldCache, "f")) {
|
|
1837
|
+
const [key, value] = item;
|
|
1838
|
+
if (!__classPrivateFieldGet(this, _QuickLRU_cache, "f").has(key)) {
|
|
1839
|
+
const deleted = __classPrivateFieldGet(this, _QuickLRU_instances, "m", _QuickLRU_deleteIfExpired).call(this, key, value);
|
|
1840
|
+
if (deleted === false) {
|
|
1841
|
+
yield item;
|
|
1842
|
+
}
|
|
1843
|
+
}
|
|
1844
|
+
}
|
|
1845
|
+
for (const item of __classPrivateFieldGet(this, _QuickLRU_cache, "f")) {
|
|
1846
|
+
const [key, value] = item;
|
|
1847
|
+
const deleted = __classPrivateFieldGet(this, _QuickLRU_instances, "m", _QuickLRU_deleteIfExpired).call(this, key, value);
|
|
1848
|
+
if (deleted === false) {
|
|
1849
|
+
yield item;
|
|
1850
|
+
}
|
|
1851
|
+
}
|
|
1852
|
+
}, Symbol.iterator)]() {
|
|
1853
|
+
for (const item of __classPrivateFieldGet(this, _QuickLRU_cache, "f")) {
|
|
1854
|
+
const [key, value] = item;
|
|
1855
|
+
const deleted = __classPrivateFieldGet(this, _QuickLRU_instances, "m", _QuickLRU_deleteIfExpired).call(this, key, value);
|
|
1856
|
+
if (deleted === false) {
|
|
1857
|
+
yield [key, value.value];
|
|
1858
|
+
}
|
|
1859
|
+
}
|
|
1860
|
+
for (const item of __classPrivateFieldGet(this, _QuickLRU_oldCache, "f")) {
|
|
1861
|
+
const [key, value] = item;
|
|
1862
|
+
if (!__classPrivateFieldGet(this, _QuickLRU_cache, "f").has(key)) {
|
|
1863
|
+
const deleted = __classPrivateFieldGet(this, _QuickLRU_instances, "m", _QuickLRU_deleteIfExpired).call(this, key, value);
|
|
1864
|
+
if (deleted === false) {
|
|
1865
|
+
yield [key, value.value];
|
|
1866
|
+
}
|
|
1867
|
+
}
|
|
1868
|
+
}
|
|
1869
|
+
}
|
|
1870
|
+
*entriesDescending() {
|
|
1871
|
+
let items = [...__classPrivateFieldGet(this, _QuickLRU_cache, "f")];
|
|
1872
|
+
for (let i = items.length - 1; i >= 0; --i) {
|
|
1873
|
+
const item = items[i];
|
|
1874
|
+
const [key, value] = item;
|
|
1875
|
+
const deleted = __classPrivateFieldGet(this, _QuickLRU_instances, "m", _QuickLRU_deleteIfExpired).call(this, key, value);
|
|
1876
|
+
if (deleted === false) {
|
|
1877
|
+
yield [key, value.value];
|
|
1878
|
+
}
|
|
1879
|
+
}
|
|
1880
|
+
items = [...__classPrivateFieldGet(this, _QuickLRU_oldCache, "f")];
|
|
1881
|
+
for (let i = items.length - 1; i >= 0; --i) {
|
|
1882
|
+
const item = items[i];
|
|
1883
|
+
const [key, value] = item;
|
|
1884
|
+
if (!__classPrivateFieldGet(this, _QuickLRU_cache, "f").has(key)) {
|
|
1885
|
+
const deleted = __classPrivateFieldGet(this, _QuickLRU_instances, "m", _QuickLRU_deleteIfExpired).call(this, key, value);
|
|
1886
|
+
if (deleted === false) {
|
|
1887
|
+
yield [key, value.value];
|
|
1888
|
+
}
|
|
1889
|
+
}
|
|
1890
|
+
}
|
|
1891
|
+
}
|
|
1892
|
+
*entriesAscending() {
|
|
1893
|
+
for (const [key, value] of __classPrivateFieldGet(this, _QuickLRU_instances, "m", _QuickLRU_entriesAscending).call(this)) {
|
|
1894
|
+
yield [key, value.value];
|
|
1895
|
+
}
|
|
1896
|
+
}
|
|
1897
|
+
get size() {
|
|
1898
|
+
if (!__classPrivateFieldGet(this, _QuickLRU_size, "f")) {
|
|
1899
|
+
return __classPrivateFieldGet(this, _QuickLRU_oldCache, "f").size;
|
|
1900
|
+
}
|
|
1901
|
+
let oldCacheSize = 0;
|
|
1902
|
+
for (const key of __classPrivateFieldGet(this, _QuickLRU_oldCache, "f").keys()) {
|
|
1903
|
+
if (!__classPrivateFieldGet(this, _QuickLRU_cache, "f").has(key)) {
|
|
1904
|
+
oldCacheSize++;
|
|
1905
|
+
}
|
|
1906
|
+
}
|
|
1907
|
+
return Math.min(__classPrivateFieldGet(this, _QuickLRU_size, "f") + oldCacheSize, __classPrivateFieldGet(this, _QuickLRU_maxSize, "f"));
|
|
1908
|
+
}
|
|
1909
|
+
get maxSize() {
|
|
1910
|
+
return __classPrivateFieldGet(this, _QuickLRU_maxSize, "f");
|
|
1911
|
+
}
|
|
1912
|
+
get maxAge() {
|
|
1913
|
+
return __classPrivateFieldGet(this, _QuickLRU_maxAge, "f");
|
|
1914
|
+
}
|
|
1915
|
+
entries() {
|
|
1916
|
+
return this.entriesAscending();
|
|
1917
|
+
}
|
|
1918
|
+
forEach(callbackFunction, thisArgument = this) {
|
|
1919
|
+
for (const [key, value] of this.entriesAscending()) {
|
|
1920
|
+
callbackFunction.call(thisArgument, value, key, this);
|
|
1921
|
+
}
|
|
1922
|
+
}
|
|
1923
|
+
get [Symbol.toStringTag]() {
|
|
1924
|
+
return 'QuickLRU';
|
|
1925
|
+
}
|
|
1926
|
+
toString() {
|
|
1927
|
+
return `QuickLRU(${this.size}/${this.maxSize})`;
|
|
1928
|
+
}
|
|
1929
|
+
[Symbol.for('nodejs.util.inspect.custom')]() {
|
|
1930
|
+
return this.toString();
|
|
1931
|
+
}
|
|
1932
|
+
}
|
|
1933
|
+
/*! @hebcal/core v6.0.7, distributed under GPLv2 https://www.gnu.org/licenses/gpl-2.0.txt */
|
|
1934
|
+
var poAshkenazi = { "headers": { "plural-forms": "nplurals=2; plural=(n > 1);", "language": "en_CA@ashkenazi" }, "contexts": { "": { "Shabbat": ["Shabbos"], "Achrei Mot": ["Achrei Mos"], "Bechukotai": ["Bechukosai"], "Beha'alotcha": ["Beha’aloscha"], "Bereshit": ["Bereshis"], "Chukat": ["Chukas"], "Erev Shavuot": ["Erev Shavuos"], "Erev Sukkot": ["Erev Sukkos"], "Ki Tavo": ["Ki Savo"], "Ki Teitzei": ["Ki Seitzei"], "Ki Tisa": ["Ki Sisa"], "Matot": ["Matos"], "Pesach Shabbat Chol ha-Moed": ["Pesach Shabbos Chol ha-Moed"], "Purim Katan": ["Purim Koton"], "Shabbat Chazon": ["Shabbos Chazon"], "Shabbat HaChodesh": ["Shabbos HaChodesh"], "Shabbat HaGadol": ["Shabbos HaGadol"], "Shabbat Nachamu": ["Shabbos Nachamu"], "Shabbat Parah": ["Shabbos Parah"], "Shabbat Shekalim": ["Shabbos Shekalim"], "Shabbat Shuva": ["Shabbos Shuvah"], "Shabbat Zachor": ["Shabbos Zachor"], "Shavuot": ["Shavuos"], "Shavuot I": ["Shavuos I"], "Shavuot II": ["Shavuos II"], "Shemot": ["Shemos"], "Shmini Atzeret": ["Shmini Atzeres"], "Simchat Torah": ["Simchas Torah"], "Sukkot": ["Sukkos"], "Sukkot I": ["Sukkos I"], "Sukkot II": ["Sukkos II"], "Sukkot II (CH''M)": ["Sukkos II (CH’’M)"], "Sukkot III (CH''M)": ["Sukkos III (CH’’M)"], "Sukkot IV (CH''M)": ["Sukkos IV (CH’’M)"], "Sukkot V (CH''M)": ["Sukkos V (CH’’M)"], "Sukkot VI (CH''M)": ["Sukkos VI (CH’’M)"], "Sukkot VII (Hoshana Raba)": ["Sukkos VII (Hoshana Raba)"], "Sukkot Shabbat Chol ha-Moed": ["Sukkos Shabbos Chol ha-Moed"], "Ta'anit Bechorot": ["Ta’anis Bechoros"], "Ta'anit Esther": ["Ta’anis Esther"], "Toldot": ["Toldos"], "Vaetchanan": ["Vaeschanan"], "Yitro": ["Yisro"], "Vezot Haberakhah": ["Vezos Haberakhah"], "Parashat": ["Parshas"], "Leil Selichot": ["Leil Selichos"], "Shabbat Mevarchim Chodesh": ["Shabbos Mevorchim Chodesh"], "Shabbat Shirah": ["Shabbos Shirah"], "Asara B'Tevet": ["Asara B’Teves"], "Alot HaShachar": ["Alos HaShachar"], "Kriat Shema, sof zeman": ["Krias Shema, sof zman"], "Tefilah, sof zeman": ["Tefilah, sof zman"], "Kriat Shema, sof zeman (MGA)": ["Krias Shema, sof zman (MGA)"], "Tefilah, sof zeman (MGA)": ["Tefilah, sof zman (MGA)"], "Chatzot HaLailah": ["Chatzos HaLailah"], "Chatzot hayom": ["Chatzos"], "Tzeit HaKochavim": ["Tzeis HaKochavim"], "Birkat Hachamah": ["Birkas Hachamah"], "Shushan Purim Katan": ["Shushan Purim Koton"] } } };
|
|
1935
|
+
/*! @hebcal/core v6.0.7, distributed under GPLv2 https://www.gnu.org/licenses/gpl-2.0.txt */
|
|
1936
|
+
var poHe = { "headers": { "plural-forms": "nplurals=2; plural=(n > 1);", "language": "he_IL" }, "contexts": { "": { "Shabbat": ["שַׁבָּת"], "Parashat": ["פָּרָשַׁת"], "Achrei Mot": ["אַחֲרֵי מוֹת"], "Balak": ["בָּלָק"], "Bamidbar": ["בְּמִדְבַּר"], "Bechukotai": ["בְּחֻקֹּתַי"], "Beha'alotcha": ["בְּהַעֲלֹתְךָ"], "Behar": ["בְּהַר"], "Bereshit": ["בְּרֵאשִׁית"], "Beshalach": ["בְּשַׁלַּח"], "Bo": ["בֹּא"], "Chayei Sara": ["חַיֵּי שָֹרָה"], "Chukat": ["חֻקַּת"], "Devarim": ["דְּבָרִים"], "Eikev": ["עֵקֶב"], "Emor": ["אֱמוֹר"], "Ha'azinu": ["הַאֲזִינוּ"], "Kedoshim": ["קְדֹשִׁים"], "Ki Tavo": ["כִּי־תָבוֹא"], "Ki Teitzei": ["כִּי־תֵצֵא"], "Ki Tisa": ["כִּי תִשָּׂא"], "Korach": ["קֹרַח"], "Lech-Lecha": ["לֶךְ־לְךָ"], "Masei": ["מַסְעֵי"], "Matot": ["מַטּוֹת"], "Metzora": ["מְצֹרָע"], "Miketz": ["מִקֵּץ"], "Mishpatim": ["מִשְׁפָּטִים"], "Nasso": ["נָשׂא"], "Nitzavim": ["נִצָּבִים"], "Noach": ["נֹחַ"], "Pekudei": ["פְקוּדֵי"], "Pinchas": ["פִּינְחָס"], "Re'eh": ["רְאֵה"], "Sh'lach": ["שְׁלַח־לְךָ"], "Shemot": ["שְׁמוֹת"], "Shmini": ["שְּׁמִינִי"], "Shoftim": ["שׁוֹפְטִים"], "Tazria": ["תַזְרִיעַ"], "Terumah": ["תְּרוּמָה"], "Tetzaveh": ["תְּצַוֶּה"], "Toldot": ["תּוֹלְדוֹת"], "Tzav": ["צַו"], "Vaera": ["וָאֵרָא"], "Vaetchanan": ["וָאֶתְחַנַּן"], "Vayakhel": ["וַיַּקְהֵל"], "Vayechi": ["וַיְחִי"], "Vayeilech": ["וַיֵּלֶךְ"], "Vayera": ["וַיֵּרָא"], "Vayeshev": ["וַיֵּשֶׁב"], "Vayetzei": ["וַיֵּצֵא"], "Vayigash": ["וַיִּגַּשׁ"], "Vayikra": ["וַיִּקְרָא"], "Vayishlach": ["וַיִּשְׁלַח"], "Vezot Haberakhah": ["וְזֹאת הַבְּרָכָה"], "Yitro": ["יִתְרוֹ"], "Asara B'Tevet": ["עֲשָׂרָה בְּטֵבֵת"], "Candle lighting": ["הַדְלָקַת נֵרוֹת"], "Chanukah": ["חֲנוּכָּה"], "Chanukah: 1 Candle": ["חֲנוּכָּה: א׳ נֵר"], "Chanukah: 2 Candles": ["חֲנוּכָּה: ב׳ נֵרוֹת"], "Chanukah: 3 Candles": ["חֲנוּכָּה: ג׳ נֵרוֹת"], "Chanukah: 4 Candles": ["חֲנוּכָּה: ד׳ נֵרוֹת"], "Chanukah: 5 Candles": ["חֲנוּכָּה: ה׳ נֵרוֹת"], "Chanukah: 6 Candles": ["חֲנוּכָּה: ו׳ נֵרוֹת"], "Chanukah: 7 Candles": ["חֲנוּכָּה: ז׳ נֵרוֹת"], "Chanukah: 8 Candles": ["חֲנוּכָּה: ח׳ נֵרוֹת"], "Chanukah: 8th Day": ["חֲנוּכָּה: יוֹם ח׳"], "Days of the Omer": ["סְפִירַת הָעוֹמֶר"], "Omer": ["עוֹמֶר"], "day of the Omer": ["בָּעוֹמֶר"], "Erev Pesach": ["עֶרֶב פֶּסַח"], "Erev Purim": ["עֶרֶב פּוּרִים"], "Erev Rosh Hashana": ["עֶרֶב רֹאשׁ הַשָּׁנָה"], "Erev Shavuot": ["עֶרֶב שָׁבוּעוֹת"], "Erev Simchat Torah": ["עֶרֶב שִׂמְחַת תּוֹרָה"], "Erev Sukkot": ["עֶרֶב סוּכּוֹת"], "Erev Tish'a B'Av": ["עֶרֶב תִּשְׁעָה בְּאָב"], "Erev Yom Kippur": ["עֶרֶב יוֹם כִּפּוּר"], "Havdalah": ["הַבְדָּלָה"], "Lag BaOmer": ["ל״ג בָּעוֹמֶר"], "Leil Selichot": ["סְלִיחוֹת"], "Pesach": ["פֶּסַח"], "Pesach I": ["פֶּסַח א׳"], "Pesach II": ["פֶּסַח ב׳"], "Pesach II (CH''M)": ["פֶּסַח ב׳ (חוה״מ)"], "Pesach III (CH''M)": ["פֶּסַח ג׳ (חוה״מ)"], "Pesach IV (CH''M)": ["פֶּסַח ד׳ (חוה״מ)"], "Pesach Sheni": ["פֶּסַח שֵׁנִי"], "Pesach V (CH''M)": ["פֶּסַח ה׳ (חוה״מ)"], "Pesach VI (CH''M)": ["פֶּסַח ו׳ (חוה״מ)"], "Pesach VII": ["פֶּסַח ז׳"], "Pesach VIII": ["פֶּסַח ח׳"], "Pesach Shabbat Chol ha-Moed": ["פֶּסַח שַׁבָּת חוֹל הַמּוֹעֵד"], "Purim": ["פּוּרִים"], "Purim Katan": ["פּוּרִים קָטָן"], "Rosh Chodesh %s": ["רֹאשׁ חוֹדֶשׁ %s"], "Rosh Chodesh": ["רֹאשׁ חוֹדֶשׁ"], "Rosh Hashana": ["רֹאשׁ הַשָּׁנָה"], "Rosh Hashana I": ["רֹאשׁ הַשָּׁנָה א׳"], "Rosh Hashana II": ["רֹאשׁ הַשָּׁנָה ב׳"], "Shabbat Chazon": ["שַׁבַּת חֲזוֹן"], "Shabbat HaChodesh": ["שַׁבַּת הַחֹדֶשׁ"], "Shabbat HaGadol": ["שַׁבַּת הַגָּדוֹל"], "Shabbat Nachamu": ["שַׁבַּת נַחֲמוּ"], "Shabbat Parah": ["שַׁבַּת פָּרָה"], "Shabbat Shekalim": ["שַׁבַּת שְׁקָלִים"], "Shabbat Shuva": ["שַׁבַּת שׁוּבָה"], "Shabbat Zachor": ["שַׁבַּת זָכוֹר"], "Shavuot": ["שָׁבוּעוֹת"], "Shavuot I": ["שָׁבוּעוֹת א׳"], "Shavuot II": ["שָׁבוּעוֹת ב׳"], "Shmini Atzeret": ["שְׁמִינִי עֲצֶרֶת"], "Shushan Purim": ["שׁוּשָׁן פּוּרִים"], "Sigd": ["חַג הַסִּיגְד"], "Simchat Torah": ["שִׂמְחַת תּוֹרָה"], "Sukkot": ["סוּכּוֹת"], "Sukkot I": ["סוּכּוֹת א׳"], "Sukkot II": ["סוּכּוֹת ב׳"], "Sukkot II (CH''M)": ["סוּכּוֹת ב׳ (חוה״מ)"], "Sukkot III (CH''M)": ["סוּכּוֹת ג׳ (חוה״מ)"], "Sukkot IV (CH''M)": ["סוּכּוֹת ד׳ (חוה״מ)"], "Sukkot V (CH''M)": ["סוּכּוֹת ה׳ (חוה״מ)"], "Sukkot VI (CH''M)": ["סוּכּוֹת ו׳ (חוה״מ)"], "Sukkot VII (Hoshana Raba)": ["סוּכּוֹת ז׳ (הוֹשַׁעְנָא רַבָּה)"], "Sukkot Shabbat Chol ha-Moed": ["סוּכּוֹת שַׁבָּת חוֹל הַמּוֹעֵד"], "Ta'anit Bechorot": ["תַּעֲנִית בְּכוֹרוֹת"], "Ta'anit Esther": ["תַּעֲנִית אֶסְתֵּר"], "Tish'a B'Av": ["תִּשְׁעָה בְּאָב"], "Tu B'Av": ["ט״וּ בְּאָב"], "Tu BiShvat": ["ט״וּ בִּשְׁבָט"], "Tu B'Shvat": ["ט״וּ בִּשְׁבָט"], "Tzom Gedaliah": ["צוֹם גְּדַלְיָה"], "Tzom Tammuz": ["צוֹם י״ז בְּתַמּוּז"], "Yom HaAtzma'ut": ["יוֹם הָעַצְמָאוּת"], "Yom HaShoah": ["יוֹם הַשּׁוֹאָה"], "Yom HaZikaron": ["יוֹם הַזִּכָּרוֹן"], "Yom Kippur": ["יוֹם כִּפּוּר"], "Yom Yerushalayim": ["יוֹם יְרוּשָׁלַיִם"], "Yom HaAliyah": ["יוֹם הַעֲלִיָּה"], "Yom HaAliyah School Observance": ["שְׁמִירָת בֵּית הַסֵפֶר לְיוֹם הַעֲלִיָּה"], "Rosh Chodesh Adar": ["רֹאשׁ חוֹדֶשׁ אֲדָר"], "Rosh Chodesh Adar I": ["רֹאשׁ חוֹדֶשׁ אֲדָר א׳"], "Rosh Chodesh Adar II": ["רֹאשׁ חוֹדֶשׁ אֲדָר ב׳"], "Rosh Chodesh Av": ["רֹאשׁ חוֹדֶשׁ אָב"], "Rosh Chodesh Cheshvan": ["רֹאשׁ חוֹדֶשׁ חֶשְׁוָן"], "Rosh Chodesh Elul": ["רֹאשׁ חוֹדֶשׁ אֱלוּל"], "Rosh Chodesh Iyyar": ["רֹאשׁ חוֹדֶשׁ אִיָּיר"], "Rosh Chodesh Kislev": ["רֹאשׁ חוֹדֶשׁ כִּסְלֵו"], "Rosh Chodesh Nisan": ["רֹאשׁ חוֹדֶשׁ נִיסָן"], "Rosh Chodesh Sh'vat": ["רֹאשׁ חוֹדֶשׁ שְׁבָט"], "Rosh Chodesh Sivan": ["רֹאשׁ חוֹדֶשׁ סִיוָן"], "Rosh Chodesh Tamuz": ["רֹאשׁ חוֹדֶשׁ תַּמּוּז"], "Rosh Chodesh Tammuz": ["רֹאשׁ חוֹדֶשׁ תַּמּוּז"], "Rosh Chodesh Tevet": ["רֹאשׁ חוֹדֶשׁ טֵבֵת"], "min": ["דַּקּוֹת"], "Fast begins": ["תְּחִילַּת הַצוֹם"], "Fast ends": ["סִיּוּם הַצוֹם"], "Rosh Hashana LaBehemot": ["רֹאשׁ הַשָּׁנָה לְמַעְשַׂר בְּהֵמָה"], "Tish'a B'Av (observed)": ["(תִּשְׁעָה בְּאָב (נִדְחָה"], "Shabbat Mevarchim Chodesh": ["שַׁבַּת מְבָרְכִים חוֹדֶשׁ"], "Shabbat Shirah": ["שַׁבַּת שִׁירָה"], "Lovingkindness": ["חֶסֶד"], "Might": ["גְּבוּרָה"], "Beauty": ["תִּפְאֶרֶת"], "Eternity": ["נֶּצַח"], "Splendor": ["הוֹד"], "Foundation": ["יְּסוֹד"], "Majesty": ["מַּלְכוּת"], "day": ["יוֹם"], "Yom Kippur Katan": ["יוֹם כִּפּוּר קָטָן"], "Yizkor": ["יִזְכּוֹר"], "Family Day": ["יוֹם הַמִּשׁפָּחָה"], "Yitzhak Rabin Memorial Day": ["יוֹם הַזִּכָּרוֹן לְיִצְחָק רַבִּין"], "Jabotinsky Day": ["יוֹם זַ׳בּוֹטִינְסְקִי"], "Herzl Day": ["יוֹם הֵרְצְל"], "Ben-Gurion Day": ["יוֹם בן־גוריון"], "Hebrew Language Day": ["יוֹם הַשָׂפָה הַעִברִית"], "Birkat Hachamah": ["בִּרְכַּת הַחַמָּה"], "Shushan Purim Katan": ["שׁוּשָׁן פּוּרִים קָטָן"], "Purim Meshulash": ["פּוּרִים מְשׁוּלָּשׁ"], "Chag HaBanot": ["חַג הַבָּנוֹת"], "Molad": ["מוֹלָד הָלְּבָנָה"], "chalakim": ["חֲלָקִים"] } } };
|
|
1937
|
+
/*! @hebcal/core v6.0.7, distributed under GPLv2 https://www.gnu.org/licenses/gpl-2.0.txt */
|
|
1938
|
+
var noNikudOverride = { "headers": { "plural-forms": "nplurals=2; plural=(n != 1);", "language": "he-x-NoNikud" }, "contexts": { "": { "Korach": ["קורח"], "Chukat": ["חוקת"], "Yom Kippur": ["יום כיפור"], "Yom Kippur Katan": ["יום כיפור קטן"] } } };
|
|
1939
|
+
/*! @hebcal/core v6.0.7, distributed under GPLv2 https://www.gnu.org/licenses/gpl-2.0.txt */
|
|
1940
|
+
Locale.addTranslations('he', poHe);
|
|
1941
|
+
Locale.addTranslations('ashkenazi', poAshkenazi);
|
|
1942
|
+
/* Hebrew without nikkud */
|
|
1943
|
+
const poHeNoNikud = Locale.copyLocaleNoNikud(poHe);
|
|
1944
|
+
Locale.addTranslations('he-x-NoNikud', poHeNoNikud);
|
|
1945
|
+
Locale.addTranslations('he-x-NoNikud', noNikudOverride);
|
|
1946
|
+
/*! @hebcal/core v6.0.7, distributed under GPLv2 https://www.gnu.org/licenses/gpl-2.0.txt */
|
|
1947
|
+
/**
|
|
1948
|
+
* Holiday flags for Event. These flags are typically
|
|
1949
|
+
* combined using bitwise arithmetic to form a mask.
|
|
1950
|
+
* @readonly
|
|
1951
|
+
* @enum {number}
|
|
1952
|
+
*/
|
|
1953
|
+
const flags = {
|
|
1954
|
+
/** Chag, yontiff, yom tov */
|
|
1955
|
+
CHAG: 0x000001,
|
|
1956
|
+
/** Light candles 18 minutes before sundown */
|
|
1957
|
+
LIGHT_CANDLES: 0x000002,
|
|
1958
|
+
/** End of holiday (end of Yom Tov) */
|
|
1959
|
+
YOM_TOV_ENDS: 0x000004,
|
|
1960
|
+
/** Observed only in the Diaspora (chutz l'aretz) */
|
|
1961
|
+
CHUL_ONLY: 0x000008,
|
|
1962
|
+
/** Observed only in Israel */
|
|
1963
|
+
IL_ONLY: 0x000010,
|
|
1964
|
+
/** Light candles in the evening at Tzeit time (3 small stars) */
|
|
1965
|
+
LIGHT_CANDLES_TZEIS: 0x000020,
|
|
1966
|
+
/** Candle-lighting for Chanukah */
|
|
1967
|
+
CHANUKAH_CANDLES: 0x000040,
|
|
1968
|
+
/** Rosh Chodesh, beginning of a new Hebrew month */
|
|
1969
|
+
ROSH_CHODESH: 0x000080,
|
|
1970
|
+
/** Minor fasts like Tzom Tammuz, Ta'anit Esther, ... */
|
|
1971
|
+
MINOR_FAST: 0x000100,
|
|
1972
|
+
/** Shabbat Shekalim, Zachor, ... */
|
|
1973
|
+
SPECIAL_SHABBAT: 0x000200,
|
|
1974
|
+
/** Weekly sedrot on Saturdays */
|
|
1975
|
+
PARSHA_HASHAVUA: 0x000400,
|
|
1976
|
+
/** Days of the Omer */
|
|
1977
|
+
OMER_COUNT: 0x001000,
|
|
1978
|
+
/** Yom HaShoah, Yom HaAtzma'ut, ... */
|
|
1979
|
+
MODERN_HOLIDAY: 0x002000,
|
|
1980
|
+
/** Yom Kippur and Tish'a B'Av */
|
|
1981
|
+
MAJOR_FAST: 0x004000,
|
|
1982
|
+
/** On the Saturday before Rosh Chodesh */
|
|
1983
|
+
SHABBAT_MEVARCHIM: 0x008000,
|
|
1984
|
+
/** Molad */
|
|
1985
|
+
MOLAD: 0x010000,
|
|
1986
|
+
/** Yahrzeit or Hebrew Anniversary */
|
|
1987
|
+
USER_EVENT: 0x020000,
|
|
1988
|
+
/** Daily Hebrew date ("11th of Sivan, 5780") */
|
|
1989
|
+
HEBREW_DATE: 0x040000,
|
|
1990
|
+
/** A holiday that's not major, modern, rosh chodesh, or a fast day */
|
|
1991
|
+
MINOR_HOLIDAY: 0x080000,
|
|
1992
|
+
/** Evening before a major or minor holiday */
|
|
1993
|
+
EREV: 0x100000,
|
|
1994
|
+
/** Chol haMoed, intermediate days of Pesach or Sukkot */
|
|
1995
|
+
CHOL_HAMOED: 0x200000,
|
|
1996
|
+
/** Yom Kippur Katan, minor day of atonement on the day preceeding each Rosh Chodesh */
|
|
1997
|
+
YOM_KIPPUR_KATAN: 0x800000,
|
|
1998
|
+
/** Yizkor */
|
|
1999
|
+
YIZKOR: 0x8000000,
|
|
2000
|
+
};
|
|
2001
|
+
const flagToCategory = [
|
|
2002
|
+
[flags.MAJOR_FAST, 'holiday', 'major', 'fast'],
|
|
2003
|
+
[flags.CHANUKAH_CANDLES, 'holiday', 'major'],
|
|
2004
|
+
[flags.HEBREW_DATE, 'hebdate'],
|
|
2005
|
+
[flags.MINOR_FAST, 'holiday', 'fast'],
|
|
2006
|
+
[flags.MINOR_HOLIDAY, 'holiday', 'minor'],
|
|
2007
|
+
[flags.MODERN_HOLIDAY, 'holiday', 'modern'],
|
|
2008
|
+
[flags.MOLAD, 'molad'],
|
|
2009
|
+
[flags.OMER_COUNT, 'omer'],
|
|
2010
|
+
[flags.PARSHA_HASHAVUA, 'parashat'], // backwards-compat
|
|
2011
|
+
[flags.ROSH_CHODESH, 'roshchodesh'],
|
|
2012
|
+
[flags.SHABBAT_MEVARCHIM, 'mevarchim'],
|
|
2013
|
+
[flags.SPECIAL_SHABBAT, 'holiday', 'shabbat'],
|
|
2014
|
+
[flags.USER_EVENT, 'user'],
|
|
2015
|
+
[flags.YIZKOR, 'yizkor'],
|
|
2016
|
+
];
|
|
2017
|
+
/**
|
|
2018
|
+
* Represents an Event with a title, date, and flags.
|
|
2019
|
+
*
|
|
2020
|
+
* Events are used to represent holidays, candle-lighting times,
|
|
2021
|
+
* Torah readings, and more.
|
|
2022
|
+
*
|
|
2023
|
+
* To get the title of the event a language other than English
|
|
2024
|
+
* with Sephardic transliterations, use the `render()` method.
|
|
2025
|
+
*/
|
|
2026
|
+
class Event {
|
|
2027
|
+
/**
|
|
2028
|
+
* Constructs Event
|
|
2029
|
+
* @param date Hebrew date event occurs
|
|
2030
|
+
* @param desc Description (not translated)
|
|
2031
|
+
* @param [mask=0] optional bitmask of holiday flags (see {@link flags})
|
|
2032
|
+
* @param [attrs={}] optional additional attributes (e.g. `eventTimeStr`, `cholHaMoedDay`)
|
|
2033
|
+
*/
|
|
2034
|
+
constructor(date, desc, mask = 0, attrs) {
|
|
2035
|
+
if (!HDate.isHDate(date)) {
|
|
2036
|
+
throw new TypeError(`Invalid Event date: ${date}`);
|
|
2037
|
+
}
|
|
2038
|
+
else if (typeof desc !== 'string') {
|
|
2039
|
+
throw new TypeError(`Invalid Event description: ${desc}`);
|
|
2040
|
+
}
|
|
2041
|
+
this.date = date;
|
|
2042
|
+
this.desc = desc;
|
|
2043
|
+
this.mask = +mask;
|
|
2044
|
+
if (typeof attrs === 'object' && attrs !== null) {
|
|
2045
|
+
Object.assign(this, attrs);
|
|
2046
|
+
}
|
|
2047
|
+
}
|
|
2048
|
+
/**
|
|
2049
|
+
* Hebrew date of this event
|
|
2050
|
+
*/
|
|
2051
|
+
getDate() {
|
|
2052
|
+
return this.date;
|
|
2053
|
+
}
|
|
2054
|
+
/**
|
|
2055
|
+
* Gregorian date of this event
|
|
2056
|
+
*/
|
|
2057
|
+
greg() {
|
|
2058
|
+
return this.date.greg();
|
|
2059
|
+
}
|
|
2060
|
+
/**
|
|
2061
|
+
* Untranslated title of this event. Note that these description
|
|
2062
|
+
* strings are always in English and will remain stable across releases.
|
|
2063
|
+
* To get the title of the event in another language, use the
|
|
2064
|
+
* `render()` method.
|
|
2065
|
+
*/
|
|
2066
|
+
getDesc() {
|
|
2067
|
+
return this.desc;
|
|
2068
|
+
}
|
|
2069
|
+
/**
|
|
2070
|
+
* Bitmask of optional event flags. See {@link flags}
|
|
2071
|
+
*/
|
|
2072
|
+
getFlags() {
|
|
2073
|
+
return this.mask;
|
|
2074
|
+
}
|
|
2075
|
+
/**
|
|
2076
|
+
* Returns (translated) description of this event
|
|
2077
|
+
* @example
|
|
2078
|
+
* const ev = new Event(new HDate(6, 'Sivan', 5749), 'Shavuot', flags.CHAG);
|
|
2079
|
+
* ev.render('en'); // 'Shavuot'
|
|
2080
|
+
* ev.render('he'); // 'שָׁבוּעוֹת'
|
|
2081
|
+
* ev.render('ashkenazi'); // 'Shavuos'
|
|
2082
|
+
* @param [locale] Optional locale name (defaults to empty locale)
|
|
2083
|
+
*/
|
|
2084
|
+
render(locale) {
|
|
2085
|
+
return Locale.gettext(this.desc, locale);
|
|
2086
|
+
}
|
|
2087
|
+
/**
|
|
2088
|
+
* Returns a brief (translated) description of this event.
|
|
2089
|
+
* For most events, this is the same as render(). For some events, it procudes
|
|
2090
|
+
* a shorter text (e.g. without a time or added description).
|
|
2091
|
+
* @param [locale] Optional locale name (defaults to empty locale)
|
|
2092
|
+
*/
|
|
2093
|
+
renderBrief(locale) {
|
|
2094
|
+
return this.render(locale);
|
|
2095
|
+
}
|
|
2096
|
+
/**
|
|
2097
|
+
* Optional holiday-specific Emoji or `null`.
|
|
2098
|
+
*/
|
|
2099
|
+
getEmoji() {
|
|
2100
|
+
return this.emoji || null;
|
|
2101
|
+
}
|
|
2102
|
+
/**
|
|
2103
|
+
* Returns a simplified (untranslated) description for this event. For example,
|
|
2104
|
+
* the `HolidayEvent` class supports
|
|
2105
|
+
* "Erev Pesach" => "Pesach", and "Sukkot III (CH''M)" => "Sukkot".
|
|
2106
|
+
* For many holidays the basename and the event description are the same.
|
|
2107
|
+
*/
|
|
2108
|
+
basename() {
|
|
2109
|
+
return this.getDesc();
|
|
2110
|
+
}
|
|
2111
|
+
/**
|
|
2112
|
+
* Returns a URL to hebcal.com or sefaria.org for more detail on the event.
|
|
2113
|
+
* Returns `undefined` for events with no detail page.
|
|
2114
|
+
*/
|
|
2115
|
+
url() {
|
|
2116
|
+
return undefined;
|
|
2117
|
+
}
|
|
2118
|
+
/**
|
|
2119
|
+
* Is this event observed in Israel?
|
|
2120
|
+
* @example
|
|
2121
|
+
* const ev1 = new Event(new HDate(7, 'Sivan', 5749), 'Shavuot II', flags.CHAG | flags.CHUL_ONLY);
|
|
2122
|
+
* ev1.observedInIsrael(); // false
|
|
2123
|
+
* const ev2 = new Event(new HDate(26, 'Kislev', 5749), 'Chanukah: 3 Candles', 0);
|
|
2124
|
+
* ev2.observedInIsrael(); // true
|
|
2125
|
+
*/
|
|
2126
|
+
observedInIsrael() {
|
|
2127
|
+
return !(this.mask & flags.CHUL_ONLY);
|
|
2128
|
+
}
|
|
2129
|
+
/**
|
|
2130
|
+
* Is this event observed in the Diaspora?
|
|
2131
|
+
* @example
|
|
2132
|
+
* const ev1 = new Event(new HDate(7, 'Sivan', 5749), 'Shavuot II', flags.CHAG | flags.CHUL_ONLY);
|
|
2133
|
+
* ev1.observedInDiaspora(); // true
|
|
2134
|
+
* const ev2 = new Event(new HDate(26, 'Kislev', 5749), 'Chanukah: 3 Candles', 0);
|
|
2135
|
+
* ev2.observedInDiaspora(); // true
|
|
2136
|
+
*/
|
|
2137
|
+
observedInDiaspora() {
|
|
2138
|
+
return !(this.mask & flags.IL_ONLY);
|
|
2139
|
+
}
|
|
2140
|
+
/**
|
|
2141
|
+
* Is this event observed in Israel/Diaspora?
|
|
2142
|
+
* @example
|
|
2143
|
+
* const ev1 = new Event(new HDate(7, 'Sivan', 5749), 'Shavuot II', flags.CHAG | flags.CHUL_ONLY);
|
|
2144
|
+
* ev1.observedIn(false); // true
|
|
2145
|
+
* ev1.observedIn(true); // false
|
|
2146
|
+
* const ev2 = new Event(new HDate(26, 'Kislev', 5749), 'Chanukah: 3 Candles', 0);
|
|
2147
|
+
* ev2.observedIn(false); // true
|
|
2148
|
+
* ev2.observedIn(true); // true
|
|
2149
|
+
* @param il
|
|
2150
|
+
*/
|
|
2151
|
+
observedIn(il) {
|
|
2152
|
+
return il ? this.observedInIsrael() : this.observedInDiaspora();
|
|
2153
|
+
}
|
|
2154
|
+
/**
|
|
2155
|
+
* Returns a list of event categories
|
|
2156
|
+
*/
|
|
2157
|
+
getCategories() {
|
|
2158
|
+
const mask = this.getFlags();
|
|
2159
|
+
for (const attrs of flagToCategory) {
|
|
2160
|
+
const attr0 = attrs[0];
|
|
2161
|
+
if (mask & attr0) {
|
|
2162
|
+
return attrs.slice(1);
|
|
2163
|
+
}
|
|
2164
|
+
}
|
|
2165
|
+
return ['unknown'];
|
|
2166
|
+
}
|
|
2167
|
+
}
|
|
2168
|
+
/*! @hebcal/core v6.0.7, distributed under GPLv2 https://www.gnu.org/licenses/gpl-2.0.txt */
|
|
2169
|
+
const SUN$1 = 0;
|
|
2170
|
+
const TUE$1 = 2;
|
|
2171
|
+
const FRI$1 = 5;
|
|
2172
|
+
const SAT$1 = 6;
|
|
2173
|
+
const NISAN$1 = months.NISAN;
|
|
2174
|
+
const IYYAR = months.IYYAR;
|
|
2175
|
+
/**
|
|
2176
|
+
* Yom HaShoah first observed in 1951.
|
|
2177
|
+
* When the actual date of Yom Hashoah falls on a Friday, the
|
|
2178
|
+
* state of Israel observes Yom Hashoah on the preceding
|
|
2179
|
+
* Thursday. When it falls on a Sunday, Yom Hashoah is observed
|
|
2180
|
+
* on the following Monday.
|
|
2181
|
+
* http://www.ushmm.org/remembrance/dor/calendar/
|
|
2182
|
+
* @private
|
|
2183
|
+
* @param year
|
|
2184
|
+
*/
|
|
2185
|
+
function dateYomHaShoah(year) {
|
|
2186
|
+
if (year < 5711) {
|
|
2187
|
+
return null;
|
|
2188
|
+
}
|
|
2189
|
+
let nisan27dt = new HDate(27, NISAN$1, year);
|
|
2190
|
+
if (nisan27dt.getDay() === FRI$1) {
|
|
2191
|
+
nisan27dt = new HDate(26, NISAN$1, year);
|
|
2192
|
+
}
|
|
2193
|
+
else if (nisan27dt.getDay() === SUN$1) {
|
|
2194
|
+
nisan27dt = new HDate(28, NISAN$1, year);
|
|
2195
|
+
}
|
|
2196
|
+
return nisan27dt;
|
|
2197
|
+
}
|
|
2198
|
+
/**
|
|
2199
|
+
* Yom HaAtzma'ut only celebrated after 1948
|
|
2200
|
+
* @private
|
|
2201
|
+
* @param year
|
|
2202
|
+
*/
|
|
2203
|
+
function dateYomHaZikaron(year) {
|
|
2204
|
+
if (year < 5708) {
|
|
2205
|
+
return null;
|
|
2206
|
+
}
|
|
2207
|
+
let day;
|
|
2208
|
+
const pesach = new HDate(15, NISAN$1, year);
|
|
2209
|
+
const pdow = pesach.getDay();
|
|
2210
|
+
if (pdow === SUN$1) {
|
|
2211
|
+
day = 2;
|
|
2212
|
+
}
|
|
2213
|
+
else if (pdow === SAT$1) {
|
|
2214
|
+
day = 3;
|
|
2215
|
+
}
|
|
2216
|
+
else if (year < 5764) {
|
|
2217
|
+
day = 4;
|
|
2218
|
+
}
|
|
2219
|
+
else if (pdow === TUE$1) {
|
|
2220
|
+
day = 5;
|
|
2221
|
+
}
|
|
2222
|
+
else {
|
|
2223
|
+
day = 4;
|
|
2224
|
+
}
|
|
2225
|
+
return new HDate(day, IYYAR, year);
|
|
2226
|
+
}
|
|
2227
|
+
/*! @hebcal/core v6.0.7, distributed under GPLv2 https://www.gnu.org/licenses/gpl-2.0.txt */
|
|
2228
|
+
/*
|
|
2229
|
+
Hebcal - A Jewish Calendar Generator
|
|
2230
|
+
Copyright (c) 1994-2020 Danny Sadinoff
|
|
2231
|
+
Portions copyright Eyal Schachter and Michael J. Radwin
|
|
2232
|
+
|
|
2233
|
+
https://github.com/hebcal/hebcal-es6
|
|
2234
|
+
|
|
2235
|
+
This program is free software; you can redistribute it and/or
|
|
2236
|
+
modify it under the terms of the GNU General Public License
|
|
2237
|
+
as published by the Free Software Foundation; either version 2
|
|
2238
|
+
of the License, or (at your option) any later version.
|
|
2239
|
+
|
|
2240
|
+
This program is distributed in the hope that it will be useful,
|
|
2241
|
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
2242
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
2243
|
+
GNU General Public License for more details.
|
|
2244
|
+
|
|
2245
|
+
You should have received a copy of the GNU General Public License
|
|
2246
|
+
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
2247
|
+
*/
|
|
2248
|
+
/*
|
|
2249
|
+
* Many of the following algorithms were taken from hebrew calendar
|
|
2250
|
+
* routines by Maimonedes, from his Mishneh Torah, and implemented by
|
|
2251
|
+
* Nachum Dershowitz Department of Computer Science
|
|
2252
|
+
* (217) 333-4219 University of Illinois at Urbana-Champaign
|
|
2253
|
+
* nachum@cs.uiuedu 1304 West Springfield Avenue
|
|
2254
|
+
* Urbana, Illinois 61801
|
|
2255
|
+
*
|
|
2256
|
+
* The routines were included in the emacs 19 distribution.
|
|
2257
|
+
*
|
|
2258
|
+
*/
|
|
2259
|
+
const INCOMPLETE = 0;
|
|
2260
|
+
const REGULAR = 1;
|
|
2261
|
+
const COMPLETE = 2;
|
|
2262
|
+
function yearType(hyear) {
|
|
2263
|
+
const longC = HDate.longCheshvan(hyear);
|
|
2264
|
+
const shortK = HDate.shortKislev(hyear);
|
|
2265
|
+
if (longC && !shortK) {
|
|
2266
|
+
return COMPLETE;
|
|
2267
|
+
}
|
|
2268
|
+
else if (!longC && shortK) {
|
|
2269
|
+
return INCOMPLETE;
|
|
2270
|
+
}
|
|
2271
|
+
else {
|
|
2272
|
+
return REGULAR;
|
|
2273
|
+
}
|
|
2274
|
+
}
|
|
2275
|
+
/**
|
|
2276
|
+
* Represents Parashah HaShavua for an entire Hebrew year
|
|
2277
|
+
*/
|
|
2278
|
+
class Sedra {
|
|
2279
|
+
/**
|
|
2280
|
+
* Caculates the Parashah HaShavua for an entire Hebrew year
|
|
2281
|
+
* @param hyear - Hebrew year (e.g. 5749)
|
|
2282
|
+
* @param il - Use Israel sedra schedule (false for Diaspora)
|
|
2283
|
+
*/
|
|
2284
|
+
constructor(hyear, il) {
|
|
2285
|
+
hyear = +hyear;
|
|
2286
|
+
this.year = hyear;
|
|
2287
|
+
const rh0 = new HDate(1, months.TISHREI, hyear);
|
|
2288
|
+
const rh = (this.rh = rh0.abs());
|
|
2289
|
+
const rhDay = rh0.getDay() + 1;
|
|
2290
|
+
// find the first Saturday on or after Rosh Hashana
|
|
2291
|
+
this.firstSaturday = HDate.dayOnOrBefore(6, rh + 6);
|
|
2292
|
+
const leap = +HDate.isLeapYear(hyear);
|
|
2293
|
+
this.il = Boolean(il);
|
|
2294
|
+
const type = yearType(hyear);
|
|
2295
|
+
let key = `${leap}${rhDay}${type}`;
|
|
2296
|
+
if (types[key]) {
|
|
2297
|
+
this.theSedraArray = types[key];
|
|
2298
|
+
this.yearKey = key;
|
|
2299
|
+
}
|
|
2300
|
+
else {
|
|
2301
|
+
key = key + +this.il; // cast to num, then concat
|
|
2302
|
+
this.theSedraArray = types[key];
|
|
2303
|
+
this.yearKey = key;
|
|
2304
|
+
}
|
|
2305
|
+
if (!this.theSedraArray) {
|
|
2306
|
+
throw new Error(`improper sedra year type ${key} calculated for ${hyear}`);
|
|
2307
|
+
}
|
|
2308
|
+
}
|
|
2309
|
+
/**
|
|
2310
|
+
* Returns the date that a parsha occurs
|
|
2311
|
+
* or `null` if the parsha doesn't occur this year
|
|
2312
|
+
* @param parsha if a `string`, specified with Sephardic transliterations
|
|
2313
|
+
* like `'Noach'` or `'Matot-Masei'`. If an array, must be a 1- or 2-element
|
|
2314
|
+
* array such as `['Noach']` or `['Matot', 'Masei']`. If a `number`, should
|
|
2315
|
+
* be a 0-based parsha index (`0` for Bereshit, `1` for Noach) or a negative
|
|
2316
|
+
* number for a doubled parsha (e.g. `-21` for Vayakhel-Pekudei)
|
|
2317
|
+
*/
|
|
2318
|
+
find(parsha) {
|
|
2319
|
+
if (typeof parsha === 'number') {
|
|
2320
|
+
if (parsha >= parshiot.length || (parsha < 0 && !isValidDouble(parsha))) {
|
|
2321
|
+
throw new RangeError(`Invalid parsha number: ${parsha}`);
|
|
2322
|
+
}
|
|
2323
|
+
return this.findInternal(parsha);
|
|
2324
|
+
}
|
|
2325
|
+
else if (typeof parsha === 'string') {
|
|
2326
|
+
const num = parsha2id.get(parsha);
|
|
2327
|
+
if (typeof num === 'number') {
|
|
2328
|
+
return this.find(num);
|
|
2329
|
+
}
|
|
2330
|
+
else if (parsha.indexOf('-') !== -1) {
|
|
2331
|
+
if (parsha === CHMPESACH || parsha === CHMSUKOT) {
|
|
2332
|
+
return this.findInternal(parsha);
|
|
2333
|
+
}
|
|
2334
|
+
return this.find(parsha.split('-'));
|
|
2335
|
+
}
|
|
2336
|
+
else {
|
|
2337
|
+
// try to find Saturday holiday like 'Yom Kippur'
|
|
2338
|
+
return this.findInternal(parsha);
|
|
2339
|
+
}
|
|
2340
|
+
}
|
|
2341
|
+
else if (Array.isArray(parsha)) {
|
|
2342
|
+
const plen = parsha.length;
|
|
2343
|
+
if ((plen !== 1 && plen !== 2) || typeof parsha[0] !== 'string') {
|
|
2344
|
+
throw new TypeError(`Invalid parsha argument: ${JSON.stringify(parsha)}`);
|
|
2345
|
+
}
|
|
2346
|
+
if (plen === 1) {
|
|
2347
|
+
return this.find(parsha[0]);
|
|
2348
|
+
}
|
|
2349
|
+
const p1 = parsha[0];
|
|
2350
|
+
const p2 = parsha[1];
|
|
2351
|
+
const num1 = parsha2id.get(p1);
|
|
2352
|
+
const num2 = parsha2id.get(p2);
|
|
2353
|
+
if (typeof num1 !== 'number' ||
|
|
2354
|
+
typeof num2 !== 'number' ||
|
|
2355
|
+
num2 !== num1 + 1 ||
|
|
2356
|
+
!isValidDouble(-num1)) {
|
|
2357
|
+
throw new RangeError(`Unrecognized parsha name: ${p1}-${p2}`);
|
|
2358
|
+
}
|
|
2359
|
+
return this.find(-num1);
|
|
2360
|
+
}
|
|
2361
|
+
return null; /* NOTREACHED */
|
|
2362
|
+
}
|
|
2363
|
+
findInternal(parsha) {
|
|
2364
|
+
const idx = this.theSedraArray.indexOf(parsha);
|
|
2365
|
+
if (idx === -1) {
|
|
2366
|
+
return null; // doesn't occur this year
|
|
2367
|
+
}
|
|
2368
|
+
return new HDate(this.firstSaturday + idx * 7);
|
|
2369
|
+
}
|
|
2370
|
+
/**
|
|
2371
|
+
* Returns the date that a parsha (or its doubled or undoubled counterpart)
|
|
2372
|
+
* occurs, or `null` if the parsha doesn't occur this year
|
|
2373
|
+
*/
|
|
2374
|
+
findContaining(parsha) {
|
|
2375
|
+
const hdate = this.find(parsha);
|
|
2376
|
+
if (hdate) {
|
|
2377
|
+
return hdate;
|
|
2378
|
+
}
|
|
2379
|
+
if (typeof parsha === 'number') {
|
|
2380
|
+
// a valid negative number (double parsha in a year where they are
|
|
2381
|
+
// combined) would've been found above, and a invalid negative number
|
|
2382
|
+
// would've thrown an error, so this parsha must be a positive number
|
|
2383
|
+
// representing either p1 or p2
|
|
2384
|
+
const p1 = -parsha;
|
|
2385
|
+
if (isValidDouble(p1)) {
|
|
2386
|
+
return this.find(p1);
|
|
2387
|
+
}
|
|
2388
|
+
else {
|
|
2389
|
+
// this must be the second individual parsha of a doubled pair
|
|
2390
|
+
// for example 29 for Kedoshim, so check for -28 for Achrei Mot-Kedoshim
|
|
2391
|
+
return this.find(p1 + 1);
|
|
2392
|
+
}
|
|
2393
|
+
}
|
|
2394
|
+
else {
|
|
2395
|
+
const num = parsha2id.get(parsha);
|
|
2396
|
+
if (num) {
|
|
2397
|
+
// parsha is either the first or second individual parsha of
|
|
2398
|
+
// a pair that is doubled this year
|
|
2399
|
+
const p1 = -num;
|
|
2400
|
+
if (isValidDouble(p1)) {
|
|
2401
|
+
return this.find(p1);
|
|
2402
|
+
}
|
|
2403
|
+
else {
|
|
2404
|
+
return this.find(p1 + 1);
|
|
2405
|
+
}
|
|
2406
|
+
}
|
|
2407
|
+
else {
|
|
2408
|
+
// this was indeed a doubled parsha, so return date of the first half
|
|
2409
|
+
const [p1] = parsha.split('-');
|
|
2410
|
+
return this.find(p1);
|
|
2411
|
+
}
|
|
2412
|
+
}
|
|
2413
|
+
}
|
|
2414
|
+
/**
|
|
2415
|
+
* Returns the underlying annual sedra schedule.
|
|
2416
|
+
* Used by `@hebcal/triennial`
|
|
2417
|
+
*/
|
|
2418
|
+
getSedraArray() {
|
|
2419
|
+
return this.theSedraArray;
|
|
2420
|
+
}
|
|
2421
|
+
/**
|
|
2422
|
+
* R.D. date of the first Saturday on or after Rosh Hashana
|
|
2423
|
+
*/
|
|
2424
|
+
getFirstSaturday() {
|
|
2425
|
+
return this.firstSaturday;
|
|
2426
|
+
}
|
|
2427
|
+
getYear() {
|
|
2428
|
+
return this.year;
|
|
2429
|
+
}
|
|
2430
|
+
/**
|
|
2431
|
+
* Returns an object describing the parsha on the first Saturday on or after `hd`
|
|
2432
|
+
* @param hd Hebrew date or R.D. days
|
|
2433
|
+
*/
|
|
2434
|
+
lookup(hd) {
|
|
2435
|
+
const abs = typeof hd === 'number' ? hd : HDate.isHDate(hd) ? hd.abs() : NaN;
|
|
2436
|
+
if (isNaN(abs)) {
|
|
2437
|
+
throw new TypeError(`Bad date argument: ${hd}`);
|
|
2438
|
+
}
|
|
2439
|
+
else if (abs < this.rh) {
|
|
2440
|
+
throw new RangeError(`Date ${hd} before start of Hebrew year ${this.year}`);
|
|
2441
|
+
}
|
|
2442
|
+
// find the first saturday on or after today's date
|
|
2443
|
+
const saturday = HDate.dayOnOrBefore(6, abs + 6);
|
|
2444
|
+
const weekNum = (saturday - this.firstSaturday) / 7;
|
|
2445
|
+
const index = this.theSedraArray[weekNum];
|
|
2446
|
+
if (typeof index === 'undefined') {
|
|
2447
|
+
const sedra = getSedra(this.year + 1, this.il);
|
|
2448
|
+
return sedra.lookup(saturday); // must be next year
|
|
2449
|
+
}
|
|
2450
|
+
const hdate = new HDate(saturday);
|
|
2451
|
+
if (typeof index === 'string') {
|
|
2452
|
+
// Shabbat has a chag. Return a description
|
|
2453
|
+
return { parsha: [index], chag: true, hdate, il: this.il, num: 0 };
|
|
2454
|
+
}
|
|
2455
|
+
if (index >= 0) {
|
|
2456
|
+
return {
|
|
2457
|
+
parsha: [parshiot[index]],
|
|
2458
|
+
chag: false,
|
|
2459
|
+
num: index + 1,
|
|
2460
|
+
hdate,
|
|
2461
|
+
il: this.il,
|
|
2462
|
+
};
|
|
2463
|
+
}
|
|
2464
|
+
const p1 = D(index); // undouble the parsha
|
|
2465
|
+
return {
|
|
2466
|
+
parsha: [parshiot[p1], parshiot[p1 + 1]],
|
|
2467
|
+
chag: false,
|
|
2468
|
+
num: [p1 + 1, p1 + 2],
|
|
2469
|
+
hdate,
|
|
2470
|
+
il: this.il,
|
|
2471
|
+
};
|
|
2472
|
+
}
|
|
2473
|
+
}
|
|
2474
|
+
/**
|
|
2475
|
+
* The 54 parshiyot of the Torah as transilterated strings.
|
|
2476
|
+
* * parshiot[0] == `Bereshit`
|
|
2477
|
+
* * parshiot[1] == `Noach`
|
|
2478
|
+
* * parshiot[52] == `Ha'azinu`
|
|
2479
|
+
* * parshiot[53] == `Vezot Haberakhah`
|
|
2480
|
+
* @readonly
|
|
2481
|
+
* @type {string[]}
|
|
2482
|
+
*/
|
|
2483
|
+
const parshiot = [
|
|
2484
|
+
'Bereshit',
|
|
2485
|
+
'Noach',
|
|
2486
|
+
'Lech-Lecha',
|
|
2487
|
+
'Vayera',
|
|
2488
|
+
'Chayei Sara',
|
|
2489
|
+
'Toldot',
|
|
2490
|
+
'Vayetzei',
|
|
2491
|
+
'Vayishlach',
|
|
2492
|
+
'Vayeshev',
|
|
2493
|
+
'Miketz',
|
|
2494
|
+
'Vayigash',
|
|
2495
|
+
'Vayechi',
|
|
2496
|
+
'Shemot',
|
|
2497
|
+
'Vaera',
|
|
2498
|
+
'Bo',
|
|
2499
|
+
'Beshalach',
|
|
2500
|
+
'Yitro',
|
|
2501
|
+
'Mishpatim',
|
|
2502
|
+
'Terumah',
|
|
2503
|
+
'Tetzaveh',
|
|
2504
|
+
'Ki Tisa',
|
|
2505
|
+
'Vayakhel',
|
|
2506
|
+
'Pekudei',
|
|
2507
|
+
'Vayikra',
|
|
2508
|
+
'Tzav',
|
|
2509
|
+
'Shmini',
|
|
2510
|
+
'Tazria',
|
|
2511
|
+
'Metzora',
|
|
2512
|
+
'Achrei Mot',
|
|
2513
|
+
'Kedoshim',
|
|
2514
|
+
'Emor',
|
|
2515
|
+
'Behar',
|
|
2516
|
+
'Bechukotai',
|
|
2517
|
+
'Bamidbar',
|
|
2518
|
+
'Nasso',
|
|
2519
|
+
"Beha'alotcha",
|
|
2520
|
+
"Sh'lach",
|
|
2521
|
+
'Korach',
|
|
2522
|
+
'Chukat',
|
|
2523
|
+
'Balak',
|
|
2524
|
+
'Pinchas',
|
|
2525
|
+
'Matot',
|
|
2526
|
+
'Masei',
|
|
2527
|
+
'Devarim',
|
|
2528
|
+
'Vaetchanan',
|
|
2529
|
+
'Eikev',
|
|
2530
|
+
"Re'eh",
|
|
2531
|
+
'Shoftim',
|
|
2532
|
+
'Ki Teitzei',
|
|
2533
|
+
'Ki Tavo',
|
|
2534
|
+
'Nitzavim',
|
|
2535
|
+
'Vayeilech',
|
|
2536
|
+
"Ha'azinu",
|
|
2537
|
+
'Vezot Haberakhah',
|
|
2538
|
+
];
|
|
2539
|
+
// 0-based parsha IDs
|
|
2540
|
+
const parsha2id = new Map();
|
|
2541
|
+
for (let id = 0; id < parshiot.length; id++) {
|
|
2542
|
+
const name = parshiot[id];
|
|
2543
|
+
parsha2id.set(name, id);
|
|
2544
|
+
}
|
|
2545
|
+
// 0-based parsha IDs
|
|
2546
|
+
const doubles = [
|
|
2547
|
+
21, // Vayakhel-Pekudei
|
|
2548
|
+
26, // Tazria-Metzora
|
|
2549
|
+
28, // Achrei Mot-Kedoshim
|
|
2550
|
+
31, // Behar-Bechukotai
|
|
2551
|
+
38, // Chukat-Balak
|
|
2552
|
+
41, // Matot-Masei
|
|
2553
|
+
50, // Nitzavim-Vayeilech
|
|
2554
|
+
];
|
|
2555
|
+
/**
|
|
2556
|
+
* @private
|
|
2557
|
+
* @param id a negative number
|
|
2558
|
+
*/
|
|
2559
|
+
function isValidDouble(id) {
|
|
2560
|
+
return doubles.includes(-id);
|
|
2561
|
+
}
|
|
2562
|
+
/**
|
|
2563
|
+
* parsha doubler/undoubler
|
|
2564
|
+
* @private
|
|
2565
|
+
* @param p
|
|
2566
|
+
*/
|
|
2567
|
+
function D(p) {
|
|
2568
|
+
return -p;
|
|
2569
|
+
}
|
|
2570
|
+
const RH = 'Rosh Hashana'; // 0
|
|
2571
|
+
const YK = 'Yom Kippur'; // 1
|
|
2572
|
+
const SUKKOT = 'Sukkot'; // 0
|
|
2573
|
+
const CHMSUKOT = 'Sukkot Shabbat Chol ha-Moed'; // 0
|
|
2574
|
+
const SHMINI = 'Shmini Atzeret'; // 0
|
|
2575
|
+
const PESACH = 'Pesach'; // 25
|
|
2576
|
+
const PESACH1 = 'Pesach I';
|
|
2577
|
+
const CHMPESACH = 'Pesach Shabbat Chol ha-Moed'; // 25
|
|
2578
|
+
const PESACH7 = 'Pesach VII'; // 25
|
|
2579
|
+
const PESACH8 = 'Pesach VIII';
|
|
2580
|
+
const SHAVUOT$1 = 'Shavuot'; // 33
|
|
2581
|
+
/**
|
|
2582
|
+
* Returns an array from start to end
|
|
2583
|
+
* @private
|
|
2584
|
+
* @param start beginning number, inclusive
|
|
2585
|
+
* @param stop ending number, inclusive
|
|
2586
|
+
*/
|
|
2587
|
+
function range(start, stop) {
|
|
2588
|
+
return Array.from({ length: stop - start + 1 }, (v, k) => k + start);
|
|
2589
|
+
}
|
|
2590
|
+
const yearStartVayeilech = [51, 52, CHMSUKOT];
|
|
2591
|
+
const yearStartHaazinu = [52, YK, CHMSUKOT];
|
|
2592
|
+
const yearStartRH = [RH, 52, SUKKOT, SHMINI];
|
|
2593
|
+
const r020 = range(0, 20);
|
|
2594
|
+
const r027 = range(0, 27);
|
|
2595
|
+
const r3340 = range(33, 40);
|
|
2596
|
+
const r4349 = range(43, 49);
|
|
2597
|
+
const r4350 = range(43, 50);
|
|
2598
|
+
/**
|
|
2599
|
+
* The ordinary year types (keviot)
|
|
2600
|
+
* names are leap/nonleap - day - incomplete/regular/complete - diaspora/Israel
|
|
2601
|
+
* @private
|
|
2602
|
+
* @readonly
|
|
2603
|
+
*/
|
|
2604
|
+
const types = {
|
|
2605
|
+
/* Hebrew year that starts on Monday, is `incomplete' (Heshvan and
|
|
2606
|
+
* Kislev each have 29 days), and has Passover start on Tuesday. */
|
|
2607
|
+
// e.g. 5753
|
|
2608
|
+
'020': yearStartVayeilech.concat(r020, D(21), 23, 24, CHMPESACH, 25, D(26), D(28), 30, D(31), r3340, D(41), r4349, D(50)),
|
|
2609
|
+
/* Hebrew year that starts on Monday, is `complete' (Heshvan and
|
|
2610
|
+
* Kislev each have 30 days), and has Passover start on Thursday. */
|
|
2611
|
+
// e.g. 5756
|
|
2612
|
+
'0220': yearStartVayeilech.concat(r020, D(21), 23, 24, CHMPESACH, 25, D(26), D(28), 30, D(31), 33, SHAVUOT$1, range(34, 37), D(38), 40, D(41), r4349, D(50)),
|
|
2613
|
+
/* Hebrew year that starts on Thursday, is `regular' (Heshvan has 29
|
|
2614
|
+
* days and Kislev has 30 days), and has Passover start on Saturday. */
|
|
2615
|
+
// e.g. 5701
|
|
2616
|
+
'0510': yearStartHaazinu.concat(r020, D(21), 23, 24, PESACH1, PESACH8, 25, D(26), D(28), 30, D(31), r3340, D(41), r4350),
|
|
2617
|
+
/* Hebrew year that starts on Thursday, is `regular' (Heshvan has 29
|
|
2618
|
+
* days and Kislev has 30 days), and has Passover start on Saturday. */
|
|
2619
|
+
// e.g. 5745
|
|
2620
|
+
'0511': yearStartHaazinu.concat(r020, D(21), 23, 24, PESACH, 25, D(26), D(28), range(30, 40), D(41), r4350),
|
|
2621
|
+
/* Hebrew year that starts on Thursday, is `complete' (Heshvan and
|
|
2622
|
+
* Kislev each have 30 days), and has Passover start on Sunday. */
|
|
2623
|
+
// e.g. 5754
|
|
2624
|
+
'052': yearStartHaazinu.concat(range(0, 24), PESACH7, 25, D(26), D(28), 30, D(31), r3340, D(41), r4350),
|
|
2625
|
+
/* Hebrew year that starts on Saturday, is `incomplete' (Heshvan and Kislev
|
|
2626
|
+
* each have 29 days), and has Passover start on Sunday. */
|
|
2627
|
+
// e.g. 5761
|
|
2628
|
+
'070': yearStartRH.concat(r020, D(21), 23, 24, PESACH7, 25, D(26), D(28), 30, D(31), r3340, D(41), r4350),
|
|
2629
|
+
/* Hebrew year that starts on Saturday, is `complete' (Heshvan and
|
|
2630
|
+
* Kislev each have 30 days), and has Passover start on Tuesday. */
|
|
2631
|
+
// e.g. 5716
|
|
2632
|
+
'072': yearStartRH.concat(r020, D(21), 23, 24, CHMPESACH, 25, D(26), D(28), 30, D(31), r3340, D(41), r4349, D(50)),
|
|
2633
|
+
/* -- The leap year types (keviot) -- */
|
|
2634
|
+
/* Hebrew year that starts on Monday, is `incomplete' (Heshvan and
|
|
2635
|
+
* Kislev each have 29 days), and has Passover start on Thursday. */
|
|
2636
|
+
// e.g. 5746
|
|
2637
|
+
'1200': yearStartVayeilech.concat(r027, CHMPESACH, range(28, 33), SHAVUOT$1, range(34, 37), D(38), 40, D(41), r4349, D(50)),
|
|
2638
|
+
/* Hebrew year that starts on Monday, is `incomplete' (Heshvan and
|
|
2639
|
+
* Kislev each have 29 days), and has Passover start on Thursday. */
|
|
2640
|
+
// e.g. 5746
|
|
2641
|
+
'1201': yearStartVayeilech.concat(r027, CHMPESACH, range(28, 40), D(41), r4349, D(50)),
|
|
2642
|
+
/* Hebrew year that starts on Monday, is `complete' (Heshvan and
|
|
2643
|
+
* Kislev each have 30 days), and has Passover start on Saturday. */
|
|
2644
|
+
// e.g.5752
|
|
2645
|
+
'1220': yearStartVayeilech.concat(r027, PESACH1, PESACH8, range(28, 40), D(41), r4350),
|
|
2646
|
+
/* Hebrew year that starts on Monday, is `complete' (Heshvan and
|
|
2647
|
+
* Kislev each have 30 days), and has Passover start on Saturday. */
|
|
2648
|
+
// e.g.5752
|
|
2649
|
+
'1221': yearStartVayeilech.concat(r027, PESACH, range(28, 50)),
|
|
2650
|
+
/* Hebrew year that starts on Thursday, is `incomplete' (Heshvan and
|
|
2651
|
+
* Kislev both have 29 days), and has Passover start on Sunday. */
|
|
2652
|
+
// e.g. 5768
|
|
2653
|
+
'150': yearStartHaazinu.concat(range(0, 28), PESACH7, range(29, 50)),
|
|
2654
|
+
/* Hebrew year that starts on Thursday, is `complete' (Heshvan and
|
|
2655
|
+
* Kislev both have 30 days), and has Passover start on Tuesday. */
|
|
2656
|
+
// eg. 5771
|
|
2657
|
+
'152': yearStartHaazinu.concat(range(0, 28), CHMPESACH, range(29, 49), D(50)),
|
|
2658
|
+
/* Hebrew year that starts on Saturday, is `incomplete' (Heshvan and
|
|
2659
|
+
* Kislev each have 29 days), and has Passover start on Tuesday. */
|
|
2660
|
+
// e.g.5757
|
|
2661
|
+
'170': yearStartRH.concat(r027, CHMPESACH, range(28, 40), D(41), r4349, D(50)),
|
|
2662
|
+
/* Hebrew year that starts on Saturday, is `complete' (Heshvan and
|
|
2663
|
+
* Kislev each have 30 days), and has Passover start on Thursday. */
|
|
2664
|
+
'1720': yearStartRH.concat(r027, CHMPESACH, range(28, 33), SHAVUOT$1, range(34, 37), D(38), 40, D(41), r4349, D(50)),
|
|
2665
|
+
};
|
|
2666
|
+
/* Hebrew year that starts on Monday, is `complete' (Heshvan and
|
|
2667
|
+
* Kislev each have 30 days), and has Passover start on Thursday. */
|
|
2668
|
+
types['0221'] = types['020'];
|
|
2669
|
+
/* Hebrew year that starts on Tuesday, is `regular' (Heshvan has 29
|
|
2670
|
+
* days and Kislev has 30 days), and has Passover start on Thursday. */
|
|
2671
|
+
// e.g. 5715
|
|
2672
|
+
types['0310'] = types['0220'];
|
|
2673
|
+
/* Hebrew year that starts on Tuesday, is `regular' (Heshvan has 29
|
|
2674
|
+
* days and Kislev has 30 days), and has Passover start on Thursday. */
|
|
2675
|
+
types['0311'] = types['020'];
|
|
2676
|
+
/* Hebrew year that starts on Tuesday, is `regular' (Heshvan has 29
|
|
2677
|
+
* days and Kislev has 30 days), and has Passover start on Saturday. */
|
|
2678
|
+
// e.g. 5715
|
|
2679
|
+
types['1310'] = types['1220'];
|
|
2680
|
+
/* Hebrew year that starts on Tuesday, is `regular' (Heshvan has 29
|
|
2681
|
+
* days and Kislev has 30 days), and has Passover start on Saturday. */
|
|
2682
|
+
types['1311'] = types['1221'];
|
|
2683
|
+
/* Hebrew year that starts on Saturday, is `complete' (Heshvan and
|
|
2684
|
+
* Kislev each have 30 days), and has Passover start on Thursday. */
|
|
2685
|
+
types['1721'] = types['170'];
|
|
2686
|
+
const sedraCache = new QuickLRU({ maxSize: 400 });
|
|
2687
|
+
/**
|
|
2688
|
+
* Convenience function to create an instance of `Sedra` or reuse a previously
|
|
2689
|
+
* created and cached instance.
|
|
2690
|
+
* @param hyear
|
|
2691
|
+
* @param il
|
|
2692
|
+
*/
|
|
2693
|
+
function getSedra(hyear, il) {
|
|
2694
|
+
const cacheKey = `${hyear}-${il ? 1 : 0}`;
|
|
2695
|
+
let sedra = sedraCache.get(cacheKey);
|
|
2696
|
+
if (!sedra) {
|
|
2697
|
+
sedra = new Sedra(hyear, il);
|
|
2698
|
+
sedraCache.set(cacheKey, sedra);
|
|
2699
|
+
}
|
|
2700
|
+
return sedra;
|
|
2701
|
+
}
|
|
2702
|
+
/*! @hebcal/core v6.0.7, distributed under GPLv2 https://www.gnu.org/licenses/gpl-2.0.txt */
|
|
2703
|
+
const Nisan = months.NISAN;
|
|
2704
|
+
const Iyyar = months.IYYAR;
|
|
2705
|
+
const Sivan = months.SIVAN;
|
|
2706
|
+
const Tamuz = months.TAMUZ;
|
|
2707
|
+
const Av = months.AV;
|
|
2708
|
+
const Elul = months.ELUL;
|
|
2709
|
+
const Tishrei = months.TISHREI;
|
|
2710
|
+
const Cheshvan = months.CHESHVAN;
|
|
2711
|
+
const Kislev = months.KISLEV;
|
|
2712
|
+
const Shvat = months.SHVAT;
|
|
2713
|
+
const Adar2 = months.ADAR_II;
|
|
2714
|
+
const CHAG$1 = flags.CHAG;
|
|
2715
|
+
const LIGHT_CANDLES = flags.LIGHT_CANDLES;
|
|
2716
|
+
const YOM_TOV_ENDS = flags.YOM_TOV_ENDS;
|
|
2717
|
+
const CHUL_ONLY = flags.CHUL_ONLY;
|
|
2718
|
+
const IL_ONLY$1 = flags.IL_ONLY;
|
|
2719
|
+
const LIGHT_CANDLES_TZEIS$1 = flags.LIGHT_CANDLES_TZEIS;
|
|
2720
|
+
const MAJOR_FAST$1 = flags.MAJOR_FAST;
|
|
2721
|
+
const MINOR_HOLIDAY$1 = flags.MINOR_HOLIDAY;
|
|
2722
|
+
const EREV$1 = flags.EREV;
|
|
2723
|
+
const CHOL_HAMOED = flags.CHOL_HAMOED;
|
|
2724
|
+
const emojiPesach = '🫓';
|
|
2725
|
+
const emojiSukkot = '🌿🍋';
|
|
2726
|
+
const ROSH_HASHANA_II = 'Rosh Hashana II';
|
|
2727
|
+
const EREV_YOM_KIPPUR = 'Erev Yom Kippur';
|
|
2728
|
+
const YOM_KIPPUR = 'Yom Kippur';
|
|
2729
|
+
const EREV_SUKKOT = 'Erev Sukkot';
|
|
2730
|
+
const SUKKOT_I = 'Sukkot I';
|
|
2731
|
+
const SUKKOT_II = 'Sukkot II';
|
|
2732
|
+
const SUKKOT_III_CHM = "Sukkot III (CH''M)";
|
|
2733
|
+
const SUKKOT_IV_CHM = "Sukkot IV (CH''M)";
|
|
2734
|
+
const SUKKOT_V_CHM = "Sukkot V (CH''M)";
|
|
2735
|
+
const SUKKOT_VI_CHM = "Sukkot VI (CH''M)";
|
|
2736
|
+
const SHMINI_ATZERET = 'Shmini Atzeret';
|
|
2737
|
+
const SIMCHAT_TORAH = 'Simchat Torah';
|
|
2738
|
+
const SUKKOT_II_CHM = "Sukkot II (CH''M)";
|
|
2739
|
+
const SUKKOT_VII_HOSHANA_RABA = 'Sukkot VII (Hoshana Raba)';
|
|
2740
|
+
const CHANUKAH_1_CANDLE = 'Chanukah: 1 Candle';
|
|
2741
|
+
const TU_BISHVAT = 'Tu BiShvat';
|
|
2742
|
+
const EREV_PURIM = 'Erev Purim';
|
|
2743
|
+
const PURIM = 'Purim';
|
|
2744
|
+
const SHUSHAN_PURIM = 'Shushan Purim';
|
|
2745
|
+
const EREV_PESACH = 'Erev Pesach';
|
|
2746
|
+
const PESACH_I = 'Pesach I';
|
|
2747
|
+
const PESACH_II = 'Pesach II';
|
|
2748
|
+
const PESACH_II_CHM = "Pesach II (CH''M)";
|
|
2749
|
+
const PESACH_III_CHM = "Pesach III (CH''M)";
|
|
2750
|
+
const PESACH_IV_CHM = "Pesach IV (CH''M)";
|
|
2751
|
+
const PESACH_V_CHM = "Pesach V (CH''M)";
|
|
2752
|
+
const PESACH_VI_CHM = "Pesach VI (CH''M)";
|
|
2753
|
+
const PESACH_VII = 'Pesach VII';
|
|
2754
|
+
const PESACH_VIII = 'Pesach VIII';
|
|
2755
|
+
const PESACH_SHENI = 'Pesach Sheni';
|
|
2756
|
+
const LAG_BAOMER = 'Lag BaOmer';
|
|
2757
|
+
const EREV_SHAVUOT = 'Erev Shavuot';
|
|
2758
|
+
const SHAVUOT = 'Shavuot';
|
|
2759
|
+
const SHAVUOT_I = 'Shavuot I';
|
|
2760
|
+
const SHAVUOT_II = 'Shavuot II';
|
|
2761
|
+
const TU_BAV = "Tu B'Av";
|
|
2762
|
+
const ROSH_HASHANA_LABEHEMOT = 'Rosh Hashana LaBehemot';
|
|
2763
|
+
const EREV_ROSH_HASHANA = 'Erev Rosh Hashana';
|
|
2764
|
+
const YOM_YERUSHALAYIM = 'Yom Yerushalayim';
|
|
2765
|
+
const BEN_GURION_DAY = 'Ben-Gurion Day';
|
|
2766
|
+
const FAMILY_DAY = 'Family Day';
|
|
2767
|
+
const YITZHAK_RABIN_MEMORIAL_DAY = 'Yitzhak Rabin Memorial Day';
|
|
2768
|
+
const HERZL_DAY = 'Herzl Day';
|
|
2769
|
+
const JABOTINSKY_DAY = 'Jabotinsky Day';
|
|
2770
|
+
const SIGD = 'Sigd';
|
|
2771
|
+
const YOM_HAALIYAH = 'Yom HaAliyah';
|
|
2772
|
+
const YOM_HAALIYAH_SCHOOL_OBSERVANCE = 'Yom HaAliyah School Observance';
|
|
2773
|
+
const HEBREW_LANGUAGE_DAY = 'Hebrew Language Day';
|
|
2774
|
+
/**
|
|
2775
|
+
* Transliterated names of holidays, used by `Event.getDesc()`
|
|
2776
|
+
* @readonly
|
|
2777
|
+
* @enum {string}
|
|
2778
|
+
*/
|
|
2779
|
+
const holidayDesc = {
|
|
2780
|
+
/** Asara B'Tevet */
|
|
2781
|
+
ASARA_BTEVET: "Asara B'Tevet",
|
|
2782
|
+
/** Birkat Hachamah */
|
|
2783
|
+
BIRKAT_HACHAMAH: 'Birkat Hachamah',
|
|
2784
|
+
/** Chag HaBanot */
|
|
2785
|
+
CHAG_HABANOT: 'Chag HaBanot',
|
|
2786
|
+
/** Chanukah: 8th Day */
|
|
2787
|
+
CHANUKAH_8TH_DAY: 'Chanukah: 8th Day',
|
|
2788
|
+
/** Erev Tish'a B'Av */
|
|
2789
|
+
EREV_TISHA_BAV: "Erev Tish'a B'Av",
|
|
2790
|
+
/** Leil Selichot */
|
|
2791
|
+
LEIL_SELICHOT: 'Leil Selichot',
|
|
2792
|
+
/** Purim Katan */
|
|
2793
|
+
PURIM_KATAN: 'Purim Katan',
|
|
2794
|
+
/** Purim Meshulash */
|
|
2795
|
+
PURIM_MESHULASH: 'Purim Meshulash',
|
|
2796
|
+
/** Shabbat Chazon */
|
|
2797
|
+
SHABBAT_CHAZON: 'Shabbat Chazon',
|
|
2798
|
+
/** Shabbat HaChodesh */
|
|
2799
|
+
SHABBAT_HACHODESH: 'Shabbat HaChodesh',
|
|
2800
|
+
/** Shabbat HaGadol */
|
|
2801
|
+
SHABBAT_HAGADOL: 'Shabbat HaGadol',
|
|
2802
|
+
/** Shabbat Nachamu */
|
|
2803
|
+
SHABBAT_NACHAMU: 'Shabbat Nachamu',
|
|
2804
|
+
/** Shabbat Parah */
|
|
2805
|
+
SHABBAT_PARAH: 'Shabbat Parah',
|
|
2806
|
+
/** Shabbat Shekalim */
|
|
2807
|
+
SHABBAT_SHEKALIM: 'Shabbat Shekalim',
|
|
2808
|
+
/** Shabbat Shirah */
|
|
2809
|
+
SHABBAT_SHIRAH: 'Shabbat Shirah',
|
|
2810
|
+
/** Shabbat Shuva */
|
|
2811
|
+
SHABBAT_SHUVA: 'Shabbat Shuva',
|
|
2812
|
+
/** Shabbat Zachor */
|
|
2813
|
+
SHABBAT_ZACHOR: 'Shabbat Zachor',
|
|
2814
|
+
/** Shushan Purim Katan */
|
|
2815
|
+
SHUSHAN_PURIM_KATAN: 'Shushan Purim Katan',
|
|
2816
|
+
/** Ta'anit Bechorot */
|
|
2817
|
+
TAANIT_BECHOROT: "Ta'anit Bechorot",
|
|
2818
|
+
/** Ta'anit Esther */
|
|
2819
|
+
TAANIT_ESTHER: "Ta'anit Esther",
|
|
2820
|
+
/** Tish'a B'Av */
|
|
2821
|
+
TISHA_BAV: "Tish'a B'Av",
|
|
2822
|
+
/** Tzom Gedaliah */
|
|
2823
|
+
TZOM_GEDALIAH: 'Tzom Gedaliah',
|
|
2824
|
+
/** Tzom Tammuz */
|
|
2825
|
+
TZOM_TAMMUZ: 'Tzom Tammuz',
|
|
2826
|
+
/** Yom HaAtzma'ut */
|
|
2827
|
+
YOM_HAATZMA_UT: "Yom HaAtzma'ut",
|
|
2828
|
+
/** Yom HaShoah */
|
|
2829
|
+
YOM_HASHOAH: 'Yom HaShoah',
|
|
2830
|
+
/** Yom HaZikaron */
|
|
2831
|
+
YOM_HAZIKARON: 'Yom HaZikaron',
|
|
2832
|
+
/** Chanukah: 1 Candle */
|
|
2833
|
+
CHANUKAH_1_CANDLE,
|
|
2834
|
+
/** Erev Purim */
|
|
2835
|
+
EREV_PURIM,
|
|
2836
|
+
/** Lag BaOmer */
|
|
2837
|
+
LAG_BAOMER,
|
|
2838
|
+
/** Pesach Sheni */
|
|
2839
|
+
PESACH_SHENI,
|
|
2840
|
+
/** Rosh Hashana LaBehemot */
|
|
2841
|
+
ROSH_HASHANA_LABEHEMOT,
|
|
2842
|
+
/** Shushan Purim */
|
|
2843
|
+
SHUSHAN_PURIM,
|
|
2844
|
+
/** Tu B\'Av */
|
|
2845
|
+
TU_BAV,
|
|
2846
|
+
/** Tu BiShvat */
|
|
2847
|
+
TU_BISHVAT
|
|
2848
|
+
};
|
|
2849
|
+
const staticHolidays = [
|
|
2850
|
+
{
|
|
2851
|
+
mm: Tishrei,
|
|
2852
|
+
dd: 2,
|
|
2853
|
+
desc: ROSH_HASHANA_II,
|
|
2854
|
+
flags: CHAG$1 | YOM_TOV_ENDS,
|
|
2855
|
+
emoji: '🍏🍯',
|
|
2856
|
+
},
|
|
2857
|
+
{ mm: Tishrei, dd: 9, desc: EREV_YOM_KIPPUR, flags: EREV$1 | LIGHT_CANDLES },
|
|
2858
|
+
{
|
|
2859
|
+
mm: Tishrei,
|
|
2860
|
+
dd: 10,
|
|
2861
|
+
desc: YOM_KIPPUR,
|
|
2862
|
+
flags: CHAG$1 | MAJOR_FAST$1 | YOM_TOV_ENDS,
|
|
2863
|
+
},
|
|
2864
|
+
{
|
|
2865
|
+
mm: Tishrei,
|
|
2866
|
+
dd: 14,
|
|
2867
|
+
desc: EREV_SUKKOT,
|
|
2868
|
+
flags: CHUL_ONLY | EREV$1 | LIGHT_CANDLES,
|
|
2869
|
+
emoji: emojiSukkot,
|
|
2870
|
+
},
|
|
2871
|
+
{
|
|
2872
|
+
mm: Tishrei,
|
|
2873
|
+
dd: 15,
|
|
2874
|
+
desc: SUKKOT_I,
|
|
2875
|
+
flags: CHUL_ONLY | CHAG$1 | LIGHT_CANDLES_TZEIS$1,
|
|
2876
|
+
emoji: emojiSukkot,
|
|
2877
|
+
},
|
|
2878
|
+
{
|
|
2879
|
+
mm: Tishrei,
|
|
2880
|
+
dd: 16,
|
|
2881
|
+
desc: SUKKOT_II,
|
|
2882
|
+
flags: CHUL_ONLY | CHAG$1 | YOM_TOV_ENDS,
|
|
2883
|
+
emoji: emojiSukkot,
|
|
2884
|
+
},
|
|
2885
|
+
{
|
|
2886
|
+
mm: Tishrei,
|
|
2887
|
+
dd: 17,
|
|
2888
|
+
desc: SUKKOT_III_CHM,
|
|
2889
|
+
flags: CHUL_ONLY | CHOL_HAMOED,
|
|
2890
|
+
chmDay: 1,
|
|
2891
|
+
emoji: emojiSukkot,
|
|
2892
|
+
},
|
|
2893
|
+
{
|
|
2894
|
+
mm: Tishrei,
|
|
2895
|
+
dd: 18,
|
|
2896
|
+
desc: SUKKOT_IV_CHM,
|
|
2897
|
+
flags: CHUL_ONLY | CHOL_HAMOED,
|
|
2898
|
+
chmDay: 2,
|
|
2899
|
+
emoji: emojiSukkot,
|
|
2900
|
+
},
|
|
2901
|
+
{
|
|
2902
|
+
mm: Tishrei,
|
|
2903
|
+
dd: 19,
|
|
2904
|
+
desc: SUKKOT_V_CHM,
|
|
2905
|
+
flags: CHUL_ONLY | CHOL_HAMOED,
|
|
2906
|
+
chmDay: 3,
|
|
2907
|
+
emoji: emojiSukkot,
|
|
2908
|
+
},
|
|
2909
|
+
{
|
|
2910
|
+
mm: Tishrei,
|
|
2911
|
+
dd: 20,
|
|
2912
|
+
desc: SUKKOT_VI_CHM,
|
|
2913
|
+
flags: CHUL_ONLY | CHOL_HAMOED,
|
|
2914
|
+
chmDay: 4,
|
|
2915
|
+
emoji: emojiSukkot,
|
|
2916
|
+
},
|
|
2917
|
+
{
|
|
2918
|
+
mm: Tishrei,
|
|
2919
|
+
dd: 22,
|
|
2920
|
+
desc: SHMINI_ATZERET,
|
|
2921
|
+
flags: CHUL_ONLY | CHAG$1 | LIGHT_CANDLES_TZEIS$1,
|
|
2922
|
+
},
|
|
2923
|
+
{
|
|
2924
|
+
mm: Tishrei,
|
|
2925
|
+
dd: 23,
|
|
2926
|
+
desc: SIMCHAT_TORAH,
|
|
2927
|
+
flags: CHUL_ONLY | CHAG$1 | YOM_TOV_ENDS,
|
|
2928
|
+
},
|
|
2929
|
+
{
|
|
2930
|
+
mm: Tishrei,
|
|
2931
|
+
dd: 14,
|
|
2932
|
+
desc: EREV_SUKKOT,
|
|
2933
|
+
flags: IL_ONLY$1 | EREV$1 | LIGHT_CANDLES,
|
|
2934
|
+
emoji: emojiSukkot,
|
|
2935
|
+
},
|
|
2936
|
+
{
|
|
2937
|
+
mm: Tishrei,
|
|
2938
|
+
dd: 15,
|
|
2939
|
+
desc: SUKKOT_I,
|
|
2940
|
+
flags: IL_ONLY$1 | CHAG$1 | YOM_TOV_ENDS,
|
|
2941
|
+
emoji: emojiSukkot,
|
|
2942
|
+
},
|
|
2943
|
+
{
|
|
2944
|
+
mm: Tishrei,
|
|
2945
|
+
dd: 16,
|
|
2946
|
+
desc: SUKKOT_II_CHM,
|
|
2947
|
+
flags: IL_ONLY$1 | CHOL_HAMOED,
|
|
2948
|
+
chmDay: 1,
|
|
2949
|
+
emoji: emojiSukkot,
|
|
2950
|
+
},
|
|
2951
|
+
{
|
|
2952
|
+
mm: Tishrei,
|
|
2953
|
+
dd: 17,
|
|
2954
|
+
desc: SUKKOT_III_CHM,
|
|
2955
|
+
flags: IL_ONLY$1 | CHOL_HAMOED,
|
|
2956
|
+
chmDay: 2,
|
|
2957
|
+
emoji: emojiSukkot,
|
|
2958
|
+
},
|
|
2959
|
+
{
|
|
2960
|
+
mm: Tishrei,
|
|
2961
|
+
dd: 18,
|
|
2962
|
+
desc: SUKKOT_IV_CHM,
|
|
2963
|
+
flags: IL_ONLY$1 | CHOL_HAMOED,
|
|
2964
|
+
chmDay: 3,
|
|
2965
|
+
emoji: emojiSukkot,
|
|
2966
|
+
},
|
|
2967
|
+
{
|
|
2968
|
+
mm: Tishrei,
|
|
2969
|
+
dd: 19,
|
|
2970
|
+
desc: SUKKOT_V_CHM,
|
|
2971
|
+
flags: IL_ONLY$1 | CHOL_HAMOED,
|
|
2972
|
+
chmDay: 4,
|
|
2973
|
+
emoji: emojiSukkot,
|
|
2974
|
+
},
|
|
2975
|
+
{
|
|
2976
|
+
mm: Tishrei,
|
|
2977
|
+
dd: 20,
|
|
2978
|
+
desc: SUKKOT_VI_CHM,
|
|
2979
|
+
flags: IL_ONLY$1 | CHOL_HAMOED,
|
|
2980
|
+
chmDay: 5,
|
|
2981
|
+
emoji: emojiSukkot,
|
|
2982
|
+
},
|
|
2983
|
+
{
|
|
2984
|
+
mm: Tishrei,
|
|
2985
|
+
dd: 22,
|
|
2986
|
+
desc: SHMINI_ATZERET,
|
|
2987
|
+
flags: IL_ONLY$1 | CHAG$1 | YOM_TOV_ENDS,
|
|
2988
|
+
},
|
|
2989
|
+
{
|
|
2990
|
+
mm: Tishrei,
|
|
2991
|
+
dd: 21,
|
|
2992
|
+
desc: SUKKOT_VII_HOSHANA_RABA,
|
|
2993
|
+
flags: LIGHT_CANDLES | CHOL_HAMOED,
|
|
2994
|
+
chmDay: -1,
|
|
2995
|
+
emoji: emojiSukkot,
|
|
2996
|
+
},
|
|
2997
|
+
{ mm: Shvat, dd: 15, desc: TU_BISHVAT, flags: MINOR_HOLIDAY$1, emoji: '🌳' },
|
|
2998
|
+
{
|
|
2999
|
+
mm: Adar2,
|
|
3000
|
+
dd: 13,
|
|
3001
|
+
desc: EREV_PURIM,
|
|
3002
|
+
flags: EREV$1 | MINOR_HOLIDAY$1,
|
|
3003
|
+
emoji: '🎭️📜',
|
|
3004
|
+
},
|
|
3005
|
+
{ mm: Adar2, dd: 14, desc: PURIM, flags: MINOR_HOLIDAY$1, emoji: '🎭️📜' },
|
|
3006
|
+
{
|
|
3007
|
+
mm: Adar2,
|
|
3008
|
+
dd: 15,
|
|
3009
|
+
desc: SHUSHAN_PURIM,
|
|
3010
|
+
flags: MINOR_HOLIDAY$1,
|
|
3011
|
+
emoji: '🎭️📜',
|
|
3012
|
+
},
|
|
3013
|
+
// Pesach Israel
|
|
3014
|
+
{
|
|
3015
|
+
mm: Nisan,
|
|
3016
|
+
dd: 14,
|
|
3017
|
+
desc: EREV_PESACH,
|
|
3018
|
+
flags: IL_ONLY$1 | EREV$1 | LIGHT_CANDLES,
|
|
3019
|
+
emoji: '🫓🍷',
|
|
3020
|
+
},
|
|
3021
|
+
{
|
|
3022
|
+
mm: Nisan,
|
|
3023
|
+
dd: 15,
|
|
3024
|
+
desc: PESACH_I,
|
|
3025
|
+
flags: IL_ONLY$1 | CHAG$1 | YOM_TOV_ENDS,
|
|
3026
|
+
emoji: emojiPesach,
|
|
3027
|
+
},
|
|
3028
|
+
{
|
|
3029
|
+
mm: Nisan,
|
|
3030
|
+
dd: 16,
|
|
3031
|
+
desc: PESACH_II_CHM,
|
|
3032
|
+
flags: IL_ONLY$1 | CHOL_HAMOED,
|
|
3033
|
+
chmDay: 1,
|
|
3034
|
+
emoji: emojiPesach,
|
|
3035
|
+
},
|
|
3036
|
+
{
|
|
3037
|
+
mm: Nisan,
|
|
3038
|
+
dd: 17,
|
|
3039
|
+
desc: PESACH_III_CHM,
|
|
3040
|
+
flags: IL_ONLY$1 | CHOL_HAMOED,
|
|
3041
|
+
chmDay: 2,
|
|
3042
|
+
emoji: emojiPesach,
|
|
3043
|
+
},
|
|
3044
|
+
{
|
|
3045
|
+
mm: Nisan,
|
|
3046
|
+
dd: 18,
|
|
3047
|
+
desc: PESACH_IV_CHM,
|
|
3048
|
+
flags: IL_ONLY$1 | CHOL_HAMOED,
|
|
3049
|
+
chmDay: 3,
|
|
3050
|
+
emoji: emojiPesach,
|
|
3051
|
+
},
|
|
3052
|
+
{
|
|
3053
|
+
mm: Nisan,
|
|
3054
|
+
dd: 19,
|
|
3055
|
+
desc: PESACH_V_CHM,
|
|
3056
|
+
flags: IL_ONLY$1 | CHOL_HAMOED,
|
|
3057
|
+
chmDay: 4,
|
|
3058
|
+
emoji: emojiPesach,
|
|
3059
|
+
},
|
|
3060
|
+
{
|
|
3061
|
+
mm: Nisan,
|
|
3062
|
+
dd: 20,
|
|
3063
|
+
desc: PESACH_VI_CHM,
|
|
3064
|
+
flags: IL_ONLY$1 | CHOL_HAMOED | LIGHT_CANDLES,
|
|
3065
|
+
chmDay: 5,
|
|
3066
|
+
emoji: emojiPesach,
|
|
3067
|
+
},
|
|
3068
|
+
{
|
|
3069
|
+
mm: Nisan,
|
|
3070
|
+
dd: 21,
|
|
3071
|
+
desc: PESACH_VII,
|
|
3072
|
+
flags: IL_ONLY$1 | CHAG$1 | YOM_TOV_ENDS,
|
|
3073
|
+
emoji: emojiPesach,
|
|
3074
|
+
},
|
|
3075
|
+
// Pesach chutz l'aretz
|
|
3076
|
+
{
|
|
3077
|
+
mm: Nisan,
|
|
3078
|
+
dd: 14,
|
|
3079
|
+
desc: EREV_PESACH,
|
|
3080
|
+
flags: CHUL_ONLY | EREV$1 | LIGHT_CANDLES,
|
|
3081
|
+
emoji: '🫓🍷',
|
|
3082
|
+
},
|
|
3083
|
+
{
|
|
3084
|
+
mm: Nisan,
|
|
3085
|
+
dd: 15,
|
|
3086
|
+
desc: PESACH_I,
|
|
3087
|
+
flags: CHUL_ONLY | CHAG$1 | LIGHT_CANDLES_TZEIS$1,
|
|
3088
|
+
emoji: '🫓🍷',
|
|
3089
|
+
},
|
|
3090
|
+
{
|
|
3091
|
+
mm: Nisan,
|
|
3092
|
+
dd: 16,
|
|
3093
|
+
desc: PESACH_II,
|
|
3094
|
+
flags: CHUL_ONLY | CHAG$1 | YOM_TOV_ENDS,
|
|
3095
|
+
emoji: emojiPesach,
|
|
3096
|
+
},
|
|
3097
|
+
{
|
|
3098
|
+
mm: Nisan,
|
|
3099
|
+
dd: 17,
|
|
3100
|
+
desc: PESACH_III_CHM,
|
|
3101
|
+
flags: CHUL_ONLY | CHOL_HAMOED,
|
|
3102
|
+
chmDay: 1,
|
|
3103
|
+
emoji: emojiPesach,
|
|
3104
|
+
},
|
|
3105
|
+
{
|
|
3106
|
+
mm: Nisan,
|
|
3107
|
+
dd: 18,
|
|
3108
|
+
desc: PESACH_IV_CHM,
|
|
3109
|
+
flags: CHUL_ONLY | CHOL_HAMOED,
|
|
3110
|
+
chmDay: 2,
|
|
3111
|
+
emoji: emojiPesach,
|
|
3112
|
+
},
|
|
3113
|
+
{
|
|
3114
|
+
mm: Nisan,
|
|
3115
|
+
dd: 19,
|
|
3116
|
+
desc: PESACH_V_CHM,
|
|
3117
|
+
flags: CHUL_ONLY | CHOL_HAMOED,
|
|
3118
|
+
chmDay: 3,
|
|
3119
|
+
emoji: emojiPesach,
|
|
3120
|
+
},
|
|
3121
|
+
{
|
|
3122
|
+
mm: Nisan,
|
|
3123
|
+
dd: 20,
|
|
3124
|
+
desc: PESACH_VI_CHM,
|
|
3125
|
+
flags: CHUL_ONLY | CHOL_HAMOED | LIGHT_CANDLES,
|
|
3126
|
+
chmDay: 4,
|
|
3127
|
+
emoji: emojiPesach,
|
|
3128
|
+
},
|
|
3129
|
+
{
|
|
3130
|
+
mm: Nisan,
|
|
3131
|
+
dd: 21,
|
|
3132
|
+
desc: PESACH_VII,
|
|
3133
|
+
flags: CHUL_ONLY | CHAG$1 | LIGHT_CANDLES_TZEIS$1,
|
|
3134
|
+
emoji: emojiPesach,
|
|
3135
|
+
},
|
|
3136
|
+
{
|
|
3137
|
+
mm: Nisan,
|
|
3138
|
+
dd: 22,
|
|
3139
|
+
desc: PESACH_VIII,
|
|
3140
|
+
flags: CHUL_ONLY | CHAG$1 | YOM_TOV_ENDS,
|
|
3141
|
+
emoji: emojiPesach,
|
|
3142
|
+
},
|
|
3143
|
+
{ mm: Iyyar, dd: 14, desc: PESACH_SHENI, flags: MINOR_HOLIDAY$1 },
|
|
3144
|
+
{ mm: Iyyar, dd: 18, desc: LAG_BAOMER, flags: MINOR_HOLIDAY$1, emoji: '🔥' },
|
|
3145
|
+
{
|
|
3146
|
+
mm: Sivan,
|
|
3147
|
+
dd: 5,
|
|
3148
|
+
desc: EREV_SHAVUOT,
|
|
3149
|
+
flags: EREV$1 | LIGHT_CANDLES,
|
|
3150
|
+
emoji: '⛰️🌸',
|
|
3151
|
+
},
|
|
3152
|
+
{
|
|
3153
|
+
mm: Sivan,
|
|
3154
|
+
dd: 6,
|
|
3155
|
+
desc: SHAVUOT,
|
|
3156
|
+
flags: IL_ONLY$1 | CHAG$1 | YOM_TOV_ENDS,
|
|
3157
|
+
emoji: '⛰️🌸',
|
|
3158
|
+
},
|
|
3159
|
+
{
|
|
3160
|
+
mm: Sivan,
|
|
3161
|
+
dd: 6,
|
|
3162
|
+
desc: SHAVUOT_I,
|
|
3163
|
+
flags: CHUL_ONLY | CHAG$1 | LIGHT_CANDLES_TZEIS$1,
|
|
3164
|
+
emoji: '⛰️🌸',
|
|
3165
|
+
},
|
|
3166
|
+
{
|
|
3167
|
+
mm: Sivan,
|
|
3168
|
+
dd: 7,
|
|
3169
|
+
desc: SHAVUOT_II,
|
|
3170
|
+
flags: CHUL_ONLY | CHAG$1 | YOM_TOV_ENDS,
|
|
3171
|
+
emoji: '⛰️🌸',
|
|
3172
|
+
},
|
|
3173
|
+
{ mm: Av, dd: 15, desc: TU_BAV, flags: MINOR_HOLIDAY$1, emoji: '❤️' },
|
|
3174
|
+
{
|
|
3175
|
+
mm: Elul,
|
|
3176
|
+
dd: 1,
|
|
3177
|
+
desc: ROSH_HASHANA_LABEHEMOT,
|
|
3178
|
+
flags: MINOR_HOLIDAY$1,
|
|
3179
|
+
emoji: '🐑',
|
|
3180
|
+
},
|
|
3181
|
+
{
|
|
3182
|
+
mm: Elul,
|
|
3183
|
+
dd: 29,
|
|
3184
|
+
desc: EREV_ROSH_HASHANA,
|
|
3185
|
+
flags: EREV$1 | LIGHT_CANDLES,
|
|
3186
|
+
emoji: '🍏🍯',
|
|
3187
|
+
},
|
|
3188
|
+
];
|
|
3189
|
+
const staticModernHolidays = [
|
|
3190
|
+
{ firstYear: 5727, mm: Iyyar, dd: 28, desc: YOM_YERUSHALAYIM, chul: true },
|
|
3191
|
+
{
|
|
3192
|
+
firstYear: 5737,
|
|
3193
|
+
mm: Kislev,
|
|
3194
|
+
dd: 6,
|
|
3195
|
+
desc: BEN_GURION_DAY,
|
|
3196
|
+
satPostponeToSun: true,
|
|
3197
|
+
friPostponeToSun: true,
|
|
3198
|
+
},
|
|
3199
|
+
{ firstYear: 5750, mm: Shvat, dd: 30, desc: FAMILY_DAY },
|
|
3200
|
+
{
|
|
3201
|
+
firstYear: 5758,
|
|
3202
|
+
mm: Cheshvan,
|
|
3203
|
+
dd: 12,
|
|
3204
|
+
desc: YITZHAK_RABIN_MEMORIAL_DAY,
|
|
3205
|
+
friSatMovetoThu: true,
|
|
3206
|
+
},
|
|
3207
|
+
{ firstYear: 5764, mm: Iyyar, dd: 10, desc: HERZL_DAY, satPostponeToSun: true },
|
|
3208
|
+
{
|
|
3209
|
+
firstYear: 5765,
|
|
3210
|
+
mm: Tamuz,
|
|
3211
|
+
dd: 29,
|
|
3212
|
+
desc: JABOTINSKY_DAY,
|
|
3213
|
+
satPostponeToSun: true,
|
|
3214
|
+
},
|
|
3215
|
+
{
|
|
3216
|
+
firstYear: 5769,
|
|
3217
|
+
mm: Cheshvan,
|
|
3218
|
+
dd: 29,
|
|
3219
|
+
desc: SIGD,
|
|
3220
|
+
chul: true,
|
|
3221
|
+
suppressEmoji: true,
|
|
3222
|
+
friSatMovetoThu: true,
|
|
3223
|
+
},
|
|
3224
|
+
{ firstYear: 5777, mm: Nisan, dd: 10, desc: YOM_HAALIYAH, chul: true },
|
|
3225
|
+
{ firstYear: 5777, mm: Cheshvan, dd: 7, desc: YOM_HAALIYAH_SCHOOL_OBSERVANCE },
|
|
3226
|
+
// https://www.gov.il/he/departments/policies/2012_des5234
|
|
3227
|
+
{
|
|
3228
|
+
firstYear: 5773,
|
|
3229
|
+
mm: months.TEVET,
|
|
3230
|
+
dd: 21,
|
|
3231
|
+
desc: HEBREW_LANGUAGE_DAY,
|
|
3232
|
+
friSatMovetoThu: true,
|
|
3233
|
+
},
|
|
3234
|
+
];
|
|
3235
|
+
/*! @hebcal/core v6.0.7, distributed under GPLv2 https://www.gnu.org/licenses/gpl-2.0.txt */
|
|
3236
|
+
/** Represents a built-in holiday like Pesach, Purim or Tu BiShvat */
|
|
3237
|
+
class HolidayEvent extends Event {
|
|
3238
|
+
basename() {
|
|
3239
|
+
return this.getDesc()
|
|
3240
|
+
.replace(/ \d{4}$/, '')
|
|
3241
|
+
.replace(/ \(CH''M\)$/, '')
|
|
3242
|
+
.replace(/ \(observed\)$/, '')
|
|
3243
|
+
.replace(/ \(Hoshana Raba\)$/, '')
|
|
3244
|
+
.replace(/ [IV]+$/, '')
|
|
3245
|
+
.replace(/: \d Candles?$/, '')
|
|
3246
|
+
.replace(/: 8th Day$/, '')
|
|
3247
|
+
.replace(/^Erev /, '');
|
|
3248
|
+
}
|
|
3249
|
+
url() {
|
|
3250
|
+
const year = this.greg().getFullYear();
|
|
3251
|
+
if (year < 100 || year > 2999) {
|
|
3252
|
+
return undefined;
|
|
3253
|
+
}
|
|
3254
|
+
const url = 'https://www.hebcal.com/holidays/' +
|
|
3255
|
+
this.basename().toLowerCase().replace(/'/g, '').replace(/ /g, '-') +
|
|
3256
|
+
'-' +
|
|
3257
|
+
this.urlDateSuffix();
|
|
3258
|
+
return this.getFlags() & flags.IL_ONLY ? url + '?i=on' : url;
|
|
3259
|
+
}
|
|
3260
|
+
urlDateSuffix() {
|
|
3261
|
+
const year = this.greg().getFullYear();
|
|
3262
|
+
return String(year);
|
|
3263
|
+
}
|
|
3264
|
+
getEmoji() {
|
|
3265
|
+
if (this.emoji) {
|
|
3266
|
+
return this.emoji;
|
|
3267
|
+
}
|
|
3268
|
+
else if (this.getFlags() & flags.SPECIAL_SHABBAT) {
|
|
3269
|
+
return '🕍';
|
|
3270
|
+
}
|
|
3271
|
+
else {
|
|
3272
|
+
return '✡️';
|
|
3273
|
+
}
|
|
3274
|
+
}
|
|
3275
|
+
getCategories() {
|
|
3276
|
+
if (this.cholHaMoedDay) {
|
|
3277
|
+
return ['holiday', 'major', 'cholhamoed'];
|
|
3278
|
+
}
|
|
3279
|
+
const cats = super.getCategories();
|
|
3280
|
+
if (cats[0] !== 'unknown') {
|
|
3281
|
+
return cats;
|
|
3282
|
+
}
|
|
3283
|
+
// Don't depend on flags.MINOR_HOLIDAY always being set. Look for minor holidays.
|
|
3284
|
+
const desc = this.getDesc();
|
|
3285
|
+
switch (desc) {
|
|
3286
|
+
case holidayDesc.LAG_BAOMER:
|
|
3287
|
+
case holidayDesc.LEIL_SELICHOT:
|
|
3288
|
+
case holidayDesc.PESACH_SHENI:
|
|
3289
|
+
case holidayDesc.EREV_PURIM:
|
|
3290
|
+
case holidayDesc.PURIM_KATAN:
|
|
3291
|
+
case holidayDesc.SHUSHAN_PURIM:
|
|
3292
|
+
case holidayDesc.TU_BAV:
|
|
3293
|
+
case holidayDesc.TU_BISHVAT:
|
|
3294
|
+
case holidayDesc.ROSH_HASHANA_LABEHEMOT:
|
|
3295
|
+
return ['holiday', 'minor'];
|
|
3296
|
+
}
|
|
3297
|
+
return ['holiday', 'major'];
|
|
3298
|
+
}
|
|
3299
|
+
/**
|
|
3300
|
+
* Returns (translated) description of this event
|
|
3301
|
+
* @param [locale] Optional locale name (defaults to empty locale)
|
|
3302
|
+
*/
|
|
3303
|
+
render(locale) {
|
|
3304
|
+
const str = super.render(locale);
|
|
3305
|
+
return str.replace(/'/g, '’');
|
|
3306
|
+
}
|
|
3307
|
+
/**
|
|
3308
|
+
* Returns a brief (translated) description of this event.
|
|
3309
|
+
* For most events, this is the same as render(). For some events, it procudes
|
|
3310
|
+
* a shorter text (e.g. without a time or added description).
|
|
3311
|
+
* @param [locale] Optional locale name (defaults to empty locale)
|
|
3312
|
+
*/
|
|
3313
|
+
renderBrief(locale) {
|
|
3314
|
+
const str = super.renderBrief(locale);
|
|
3315
|
+
return str.replace(/'/g, '’');
|
|
3316
|
+
}
|
|
3317
|
+
}
|
|
3318
|
+
/**
|
|
3319
|
+
* Because Asara B'Tevet often occurs twice in the same Gregorian year,
|
|
3320
|
+
* we subclass HolidayEvent to generate the correct URL.
|
|
3321
|
+
*/
|
|
3322
|
+
class AsaraBTevetEvent extends HolidayEvent {
|
|
3323
|
+
urlDateSuffix() {
|
|
3324
|
+
const isoDate = isoDateString(this.greg());
|
|
3325
|
+
return isoDate.replace(/-/g, '');
|
|
3326
|
+
}
|
|
3327
|
+
}
|
|
3328
|
+
const chanukahEmoji = '🕎';
|
|
3329
|
+
const KEYCAP_DIGITS = [
|
|
3330
|
+
'0️⃣',
|
|
3331
|
+
'1️⃣',
|
|
3332
|
+
'2️⃣',
|
|
3333
|
+
'3️⃣',
|
|
3334
|
+
'4️⃣',
|
|
3335
|
+
'5️⃣',
|
|
3336
|
+
'6️⃣',
|
|
3337
|
+
'7️⃣',
|
|
3338
|
+
'8️⃣',
|
|
3339
|
+
'9️⃣',
|
|
3340
|
+
];
|
|
3341
|
+
/**
|
|
3342
|
+
* Because Chanukah sometimes starts in December and ends in January,
|
|
3343
|
+
* we subclass HolidayEvent to generate the correct URL.
|
|
3344
|
+
*/
|
|
3345
|
+
class ChanukahEvent extends HolidayEvent {
|
|
3346
|
+
/**
|
|
3347
|
+
* @param chanukahDay should be undefined for 1st night of Chanukah
|
|
3348
|
+
*/
|
|
3349
|
+
constructor(date, desc, mask, chanukahDay) {
|
|
3350
|
+
super(date, desc, mask);
|
|
3351
|
+
this.chanukahDay = chanukahDay;
|
|
3352
|
+
this.emoji = chanukahEmoji;
|
|
3353
|
+
if (chanukahDay !== 8) {
|
|
3354
|
+
const candles = chanukahDay ? chanukahDay + 1 : 1;
|
|
3355
|
+
this.emoji += KEYCAP_DIGITS[candles];
|
|
3356
|
+
}
|
|
3357
|
+
}
|
|
3358
|
+
urlDateSuffix() {
|
|
3359
|
+
const dt = this.greg();
|
|
3360
|
+
let year = dt.getFullYear();
|
|
3361
|
+
if (dt.getMonth() === 0) {
|
|
3362
|
+
year--;
|
|
3363
|
+
}
|
|
3364
|
+
return String(year);
|
|
3365
|
+
}
|
|
3366
|
+
}
|
|
3367
|
+
/** Represents Rosh Hashana, the Jewish New Year */
|
|
3368
|
+
class RoshHashanaEvent extends HolidayEvent {
|
|
3369
|
+
/**
|
|
3370
|
+
* @private
|
|
3371
|
+
* @param date Hebrew date event occurs
|
|
3372
|
+
* @param hyear Hebrew year
|
|
3373
|
+
* @param mask optional holiday flags
|
|
3374
|
+
*/
|
|
3375
|
+
constructor(date, hyear, mask) {
|
|
3376
|
+
super(date, `Rosh Hashana ${hyear}`, mask);
|
|
3377
|
+
this.hyear = hyear;
|
|
3378
|
+
}
|
|
3379
|
+
/**
|
|
3380
|
+
* Returns (translated) description of this event
|
|
3381
|
+
* @param [locale] Optional locale name (defaults to empty locale)
|
|
3382
|
+
*/
|
|
3383
|
+
render(locale) {
|
|
3384
|
+
return Locale.gettext('Rosh Hashana', locale) + ' ' + this.hyear;
|
|
3385
|
+
}
|
|
3386
|
+
getEmoji() {
|
|
3387
|
+
return '🍏🍯';
|
|
3388
|
+
}
|
|
3389
|
+
}
|
|
3390
|
+
const roshChodeshStr = 'Rosh Chodesh';
|
|
3391
|
+
/** Represents Rosh Chodesh, the beginning of a new month */
|
|
3392
|
+
class RoshChodeshEvent extends HolidayEvent {
|
|
3393
|
+
/**
|
|
3394
|
+
* Constructs Rosh Chodesh event
|
|
3395
|
+
* @param date Hebrew date event occurs
|
|
3396
|
+
* @param monthName Hebrew month name (not translated)
|
|
3397
|
+
*/
|
|
3398
|
+
constructor(date, monthName) {
|
|
3399
|
+
super(date, `${roshChodeshStr} ${monthName}`, flags.ROSH_CHODESH);
|
|
3400
|
+
}
|
|
3401
|
+
/**
|
|
3402
|
+
* Returns (translated) description of this event
|
|
3403
|
+
* @param [locale] Optional locale name (defaults to empty locale)
|
|
3404
|
+
*/
|
|
3405
|
+
render(locale) {
|
|
3406
|
+
const monthName = this.getDesc().substring(roshChodeshStr.length + 1);
|
|
3407
|
+
const monthName0 = Locale.gettext(monthName, locale);
|
|
3408
|
+
const monthName1 = monthName0.replace(/'/g, '’');
|
|
3409
|
+
return Locale.gettext(roshChodeshStr, locale) + ' ' + monthName1;
|
|
3410
|
+
}
|
|
3411
|
+
basename() {
|
|
3412
|
+
return this.getDesc();
|
|
3413
|
+
}
|
|
3414
|
+
getEmoji() {
|
|
3415
|
+
return this.emoji || '🌒';
|
|
3416
|
+
}
|
|
3417
|
+
}
|
|
3418
|
+
/*! @hebcal/core v6.0.7, distributed under GPLv2 https://www.gnu.org/licenses/gpl-2.0.txt */
|
|
3419
|
+
const ykk = 'Yom Kippur Katan';
|
|
3420
|
+
/** YKK is minor day of atonement on the day preceeding each Rosh Chodesh */
|
|
3421
|
+
class YomKippurKatanEvent extends HolidayEvent {
|
|
3422
|
+
/**
|
|
3423
|
+
* @private
|
|
3424
|
+
* @param date Hebrew date event occurs
|
|
3425
|
+
* @param nextMonthName name of the upcoming month
|
|
3426
|
+
*/
|
|
3427
|
+
constructor(date, nextMonthName) {
|
|
3428
|
+
super(date, `${ykk} ${nextMonthName}`, flags.MINOR_FAST | flags.YOM_KIPPUR_KATAN);
|
|
3429
|
+
this.nextMonthName = nextMonthName;
|
|
3430
|
+
this.memo = `Minor Day of Atonement on the day preceeding Rosh Chodesh ${nextMonthName}`;
|
|
3431
|
+
}
|
|
3432
|
+
basename() {
|
|
3433
|
+
return this.getDesc();
|
|
3434
|
+
}
|
|
3435
|
+
/**
|
|
3436
|
+
* @param [locale] Optional locale name (defaults to empty locale)
|
|
3437
|
+
*/
|
|
3438
|
+
render(locale) {
|
|
3439
|
+
const monthName0 = Locale.gettext(this.nextMonthName, locale);
|
|
3440
|
+
const monthName = monthName0.replace(/'/g, '’');
|
|
3441
|
+
return Locale.gettext(ykk, locale) + ' ' + monthName;
|
|
3442
|
+
}
|
|
3443
|
+
/**
|
|
3444
|
+
* @param [locale] Optional locale name (defaults to empty locale)
|
|
3445
|
+
*/
|
|
3446
|
+
renderBrief(locale) {
|
|
3447
|
+
return Locale.gettext(ykk, locale);
|
|
3448
|
+
}
|
|
3449
|
+
url() {
|
|
3450
|
+
return undefined;
|
|
3451
|
+
}
|
|
3452
|
+
}
|
|
3453
|
+
/*! @hebcal/core v6.0.7, distributed under GPLv2 https://www.gnu.org/licenses/gpl-2.0.txt */
|
|
3454
|
+
/*
|
|
3455
|
+
Hebcal - A Jewish Calendar Generator
|
|
3456
|
+
Copyright (c) 1994-2020 Danny Sadinoff
|
|
3457
|
+
Portions copyright Eyal Schachter and Michael J. Radwin
|
|
3458
|
+
|
|
3459
|
+
https://github.com/hebcal/hebcal-es6
|
|
3460
|
+
|
|
3461
|
+
This program is free software; you can redistribute it and/or
|
|
3462
|
+
modify it under the terms of the GNU General Public License
|
|
3463
|
+
as published by the Free Software Foundation; either version 2
|
|
3464
|
+
of the License, or (at your option) any later version.
|
|
3465
|
+
|
|
3466
|
+
This program is distributed in the hope that it will be useful,
|
|
3467
|
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
3468
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
3469
|
+
GNU General Public License for more details.
|
|
3470
|
+
|
|
3471
|
+
You should have received a copy of the GNU General Public License
|
|
3472
|
+
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
3473
|
+
*/
|
|
3474
|
+
/**
|
|
3475
|
+
* Returns an array of Events on this date (or `undefined` if no events)
|
|
3476
|
+
* @param date Hebrew Date, Gregorian date, or absolute R.D. day number
|
|
3477
|
+
* @param [il] use the Israeli schedule for holidays
|
|
3478
|
+
*/
|
|
3479
|
+
function getHolidaysOnDate(date, il) {
|
|
3480
|
+
const hd = HDate.isHDate(date) ? date : new HDate(date);
|
|
3481
|
+
const hdStr = hd.toString();
|
|
3482
|
+
const yearMap = getHolidaysForYear_(hd.getFullYear());
|
|
3483
|
+
const events = yearMap.get(hdStr);
|
|
3484
|
+
// if il isn't a boolean return both diaspora + IL for day
|
|
3485
|
+
{
|
|
3486
|
+
return events;
|
|
3487
|
+
}
|
|
3488
|
+
}
|
|
3489
|
+
const CHAG = flags.CHAG;
|
|
3490
|
+
const IL_ONLY = flags.IL_ONLY;
|
|
3491
|
+
const LIGHT_CANDLES_TZEIS = flags.LIGHT_CANDLES_TZEIS;
|
|
3492
|
+
const CHANUKAH_CANDLES = flags.CHANUKAH_CANDLES;
|
|
3493
|
+
const MINOR_FAST = flags.MINOR_FAST;
|
|
3494
|
+
const SPECIAL_SHABBAT = flags.SPECIAL_SHABBAT;
|
|
3495
|
+
const MODERN_HOLIDAY = flags.MODERN_HOLIDAY;
|
|
3496
|
+
const MAJOR_FAST = flags.MAJOR_FAST;
|
|
3497
|
+
const MINOR_HOLIDAY = flags.MINOR_HOLIDAY;
|
|
3498
|
+
const EREV = flags.EREV;
|
|
3499
|
+
const SUN = 0;
|
|
3500
|
+
const TUE = 2;
|
|
3501
|
+
const THU = 4;
|
|
3502
|
+
const FRI = 5;
|
|
3503
|
+
const SAT = 6;
|
|
3504
|
+
const NISAN = months.NISAN;
|
|
3505
|
+
const TAMUZ = months.TAMUZ;
|
|
3506
|
+
const AV = months.AV;
|
|
3507
|
+
const TISHREI = months.TISHREI;
|
|
3508
|
+
const KISLEV = months.KISLEV;
|
|
3509
|
+
const TEVET = months.TEVET;
|
|
3510
|
+
const ADAR_I = months.ADAR_I;
|
|
3511
|
+
const ADAR_II = months.ADAR_II;
|
|
3512
|
+
const emojiIsraelFlag = { emoji: '🇮🇱' };
|
|
3513
|
+
const yearCache = new QuickLRU({ maxSize: 400 });
|
|
3514
|
+
/**
|
|
3515
|
+
* Lower-level holidays interface, which returns a `Map` of `Event`s indexed by
|
|
3516
|
+
* `HDate.toString()`. These events must filtered especially for `flags.IL_ONLY`
|
|
3517
|
+
* or `flags.CHUL_ONLY` depending on Israel vs. Diaspora holiday scheme.
|
|
3518
|
+
* @private
|
|
3519
|
+
*/
|
|
3520
|
+
function getHolidaysForYear_(year) {
|
|
3521
|
+
if (typeof year !== 'number') {
|
|
3522
|
+
throw new TypeError(`bad Hebrew year: ${year}`);
|
|
3523
|
+
}
|
|
3524
|
+
else if (year < 1 || year > 32658) {
|
|
3525
|
+
throw new RangeError(`Hebrew year ${year} out of range 1-32658`);
|
|
3526
|
+
}
|
|
3527
|
+
const cached = yearCache.get(year);
|
|
3528
|
+
if (cached) {
|
|
3529
|
+
return cached;
|
|
3530
|
+
}
|
|
3531
|
+
const RH = new HDate(1, TISHREI, year);
|
|
3532
|
+
const pesach = new HDate(15, NISAN, year);
|
|
3533
|
+
const map = new Map();
|
|
3534
|
+
function add(...events) {
|
|
3535
|
+
for (const ev of events) {
|
|
3536
|
+
const key = ev.date.toString();
|
|
3537
|
+
const arr = map.get(key);
|
|
3538
|
+
if (typeof arr === 'object') {
|
|
3539
|
+
if (arr[0].getFlags() & EREV) {
|
|
3540
|
+
arr.unshift(ev);
|
|
3541
|
+
}
|
|
3542
|
+
else {
|
|
3543
|
+
arr.push(ev);
|
|
3544
|
+
}
|
|
3545
|
+
}
|
|
3546
|
+
else {
|
|
3547
|
+
map.set(key, [ev]);
|
|
3548
|
+
}
|
|
3549
|
+
}
|
|
3550
|
+
}
|
|
3551
|
+
for (const h of staticHolidays) {
|
|
3552
|
+
const hd = new HDate(h.dd, h.mm, year);
|
|
3553
|
+
const ev = new HolidayEvent(hd, h.desc, h.flags);
|
|
3554
|
+
if (h.emoji)
|
|
3555
|
+
ev.emoji = h.emoji;
|
|
3556
|
+
if (h.chmDay)
|
|
3557
|
+
ev.cholHaMoedDay = h.chmDay;
|
|
3558
|
+
add(ev);
|
|
3559
|
+
}
|
|
3560
|
+
// standard holidays that don't shift based on year
|
|
3561
|
+
add(new RoshHashanaEvent(RH, year, CHAG | LIGHT_CANDLES_TZEIS));
|
|
3562
|
+
// Variable date holidays
|
|
3563
|
+
const tzomGedaliahDay = RH.getDay() === THU ? 4 : 3;
|
|
3564
|
+
add(new HolidayEvent(new HDate(tzomGedaliahDay, TISHREI, year), holidayDesc.TZOM_GEDALIAH, MINOR_FAST));
|
|
3565
|
+
// first SAT after RH
|
|
3566
|
+
add(new HolidayEvent(new HDate(HDate.dayOnOrBefore(SAT, 7 + RH.abs())), holidayDesc.SHABBAT_SHUVA, SPECIAL_SHABBAT));
|
|
3567
|
+
const rchTevet = HDate.shortKislev(year)
|
|
3568
|
+
? new HDate(1, TEVET, year)
|
|
3569
|
+
: new HDate(30, KISLEV, year);
|
|
3570
|
+
add(new HolidayEvent(rchTevet, holidayDesc.CHAG_HABANOT, MINOR_HOLIDAY));
|
|
3571
|
+
add(new ChanukahEvent(new HDate(24, KISLEV, year), holidayDesc.CHANUKAH_1_CANDLE, EREV | MINOR_HOLIDAY | CHANUKAH_CANDLES, undefined));
|
|
3572
|
+
// yes, we know Kislev 30-32 are wrong
|
|
3573
|
+
// HDate() corrects the month automatically
|
|
3574
|
+
for (let candles = 2; candles <= 8; candles++) {
|
|
3575
|
+
const hd = new HDate(23 + candles, KISLEV, year);
|
|
3576
|
+
add(new ChanukahEvent(hd, `Chanukah: ${candles} Candles`, MINOR_HOLIDAY | CHANUKAH_CANDLES, candles - 1));
|
|
3577
|
+
}
|
|
3578
|
+
add(new ChanukahEvent(new HDate(32, KISLEV, year), holidayDesc.CHANUKAH_8TH_DAY, MINOR_HOLIDAY, 8));
|
|
3579
|
+
add(new AsaraBTevetEvent(new HDate(10, TEVET, year), holidayDesc.ASARA_BTEVET, MINOR_FAST));
|
|
3580
|
+
const pesachAbs = pesach.abs();
|
|
3581
|
+
add(new HolidayEvent(new HDate(HDate.dayOnOrBefore(SAT, pesachAbs - 43)), holidayDesc.SHABBAT_SHEKALIM, SPECIAL_SHABBAT), new HolidayEvent(new HDate(HDate.dayOnOrBefore(SAT, pesachAbs - 30)), holidayDesc.SHABBAT_ZACHOR, SPECIAL_SHABBAT), new HolidayEvent(new HDate(pesachAbs - (pesach.getDay() === TUE ? 33 : 31)), holidayDesc.TAANIT_ESTHER, MINOR_FAST));
|
|
3582
|
+
const haChodeshAbs = HDate.dayOnOrBefore(SAT, pesachAbs - 14);
|
|
3583
|
+
add(new HolidayEvent(new HDate(haChodeshAbs - 7), holidayDesc.SHABBAT_PARAH, SPECIAL_SHABBAT), new HolidayEvent(new HDate(haChodeshAbs), holidayDesc.SHABBAT_HACHODESH, SPECIAL_SHABBAT), new HolidayEvent(new HDate(HDate.dayOnOrBefore(SAT, pesachAbs - 1)), holidayDesc.SHABBAT_HAGADOL, SPECIAL_SHABBAT), new HolidayEvent(
|
|
3584
|
+
// if the fast falls on Shabbat, move to Thursday
|
|
3585
|
+
pesach.prev().getDay() === SAT
|
|
3586
|
+
? pesach.onOrBefore(THU)
|
|
3587
|
+
: new HDate(14, NISAN, year), holidayDesc.TAANIT_BECHOROT, MINOR_FAST));
|
|
3588
|
+
add(new HolidayEvent(new HDate(HDate.dayOnOrBefore(SAT, new HDate(1, TISHREI, year + 1).abs() - 4)), holidayDesc.LEIL_SELICHOT, MINOR_HOLIDAY, { emoji: '🕍' }));
|
|
3589
|
+
if (pesach.getDay() === SUN) {
|
|
3590
|
+
add(new HolidayEvent(new HDate(16, ADAR_II, year), holidayDesc.PURIM_MESHULASH, MINOR_HOLIDAY));
|
|
3591
|
+
}
|
|
3592
|
+
if (HDate.isLeapYear(year)) {
|
|
3593
|
+
add(new HolidayEvent(new HDate(14, ADAR_I, year), holidayDesc.PURIM_KATAN, MINOR_HOLIDAY, { emoji: '🎭️' }));
|
|
3594
|
+
add(new HolidayEvent(new HDate(15, ADAR_I, year), holidayDesc.SHUSHAN_PURIM_KATAN, MINOR_HOLIDAY, { emoji: '🎭️' }));
|
|
3595
|
+
}
|
|
3596
|
+
const nisan27dt = dateYomHaShoah(year);
|
|
3597
|
+
if (nisan27dt) {
|
|
3598
|
+
add(new HolidayEvent(nisan27dt, holidayDesc.YOM_HASHOAH, MODERN_HOLIDAY));
|
|
3599
|
+
}
|
|
3600
|
+
const yomHaZikaronDt = dateYomHaZikaron(year);
|
|
3601
|
+
if (yomHaZikaronDt) {
|
|
3602
|
+
add(new HolidayEvent(yomHaZikaronDt, holidayDesc.YOM_HAZIKARON, MODERN_HOLIDAY, emojiIsraelFlag), new HolidayEvent(yomHaZikaronDt.next(), holidayDesc.YOM_HAATZMA_UT, MODERN_HOLIDAY, emojiIsraelFlag));
|
|
3603
|
+
}
|
|
3604
|
+
for (const h of staticModernHolidays) {
|
|
3605
|
+
if (year >= h.firstYear) {
|
|
3606
|
+
let hd = new HDate(h.dd, h.mm, year);
|
|
3607
|
+
const dow = hd.getDay();
|
|
3608
|
+
if (h.friSatMovetoThu && (dow === FRI || dow === SAT)) {
|
|
3609
|
+
hd = hd.onOrBefore(THU);
|
|
3610
|
+
}
|
|
3611
|
+
else if (h.friPostponeToSun && dow === FRI) {
|
|
3612
|
+
hd = new HDate(hd.abs() + 2);
|
|
3613
|
+
}
|
|
3614
|
+
else if (h.satPostponeToSun && dow === SAT) {
|
|
3615
|
+
hd = hd.next();
|
|
3616
|
+
}
|
|
3617
|
+
const mask = h.chul ? MODERN_HOLIDAY : MODERN_HOLIDAY | IL_ONLY;
|
|
3618
|
+
const ev = new HolidayEvent(hd, h.desc, mask);
|
|
3619
|
+
if (!h.suppressEmoji) {
|
|
3620
|
+
ev.emoji = '🇮🇱';
|
|
3621
|
+
}
|
|
3622
|
+
add(ev);
|
|
3623
|
+
}
|
|
3624
|
+
}
|
|
3625
|
+
let tamuz17 = new HDate(17, TAMUZ, year);
|
|
3626
|
+
let tamuz17attrs;
|
|
3627
|
+
if (tamuz17.getDay() === SAT) {
|
|
3628
|
+
tamuz17 = new HDate(18, TAMUZ, year);
|
|
3629
|
+
tamuz17attrs = { observed: true };
|
|
3630
|
+
}
|
|
3631
|
+
add(new HolidayEvent(tamuz17, holidayDesc.TZOM_TAMMUZ, MINOR_FAST, tamuz17attrs));
|
|
3632
|
+
let av9dt = new HDate(9, AV, year);
|
|
3633
|
+
let av9title = holidayDesc.TISHA_BAV;
|
|
3634
|
+
let av9attrs;
|
|
3635
|
+
if (av9dt.getDay() === SAT) {
|
|
3636
|
+
av9dt = av9dt.next();
|
|
3637
|
+
av9attrs = { observed: true };
|
|
3638
|
+
av9title += ' (observed)';
|
|
3639
|
+
}
|
|
3640
|
+
const av9abs = av9dt.abs();
|
|
3641
|
+
add(new HolidayEvent(new HDate(HDate.dayOnOrBefore(SAT, av9abs)), holidayDesc.SHABBAT_CHAZON, SPECIAL_SHABBAT), new HolidayEvent(av9dt.prev(), holidayDesc.EREV_TISHA_BAV, EREV | MAJOR_FAST, av9attrs), new HolidayEvent(av9dt, av9title, MAJOR_FAST, av9attrs), new HolidayEvent(new HDate(HDate.dayOnOrBefore(SAT, av9abs + 7)), holidayDesc.SHABBAT_NACHAMU, SPECIAL_SHABBAT));
|
|
3642
|
+
const monthsInYear = HDate.monthsInYear(year);
|
|
3643
|
+
for (let month = 1; month <= monthsInYear; month++) {
|
|
3644
|
+
const monthName = HDate.getMonthName(month, year);
|
|
3645
|
+
if ((month === NISAN
|
|
3646
|
+
? HDate.daysInMonth(HDate.monthsInYear(year - 1), year - 1)
|
|
3647
|
+
: HDate.daysInMonth(month - 1, year)) === 30) {
|
|
3648
|
+
add(new RoshChodeshEvent(new HDate(1, month, year), monthName));
|
|
3649
|
+
add(new RoshChodeshEvent(new HDate(30, month - 1, year), monthName));
|
|
3650
|
+
}
|
|
3651
|
+
else if (month !== TISHREI) {
|
|
3652
|
+
add(new RoshChodeshEvent(new HDate(1, month, year), monthName));
|
|
3653
|
+
}
|
|
3654
|
+
}
|
|
3655
|
+
// Begin: Yom Kippur Katan
|
|
3656
|
+
// start at Iyyar because one may not fast during Nisan
|
|
3657
|
+
for (let month = months.IYYAR; month <= monthsInYear; month++) {
|
|
3658
|
+
const nextMonth = month + 1;
|
|
3659
|
+
// Yom Kippur Katan is not observed on the day before Rosh Hashanah.
|
|
3660
|
+
// Not observed prior to Rosh Chodesh Cheshvan because Yom Kippur has just passed.
|
|
3661
|
+
// Not observed before Rosh Chodesh Tevet, because that day is Hanukkah.
|
|
3662
|
+
if (nextMonth === TISHREI ||
|
|
3663
|
+
nextMonth === months.CHESHVAN ||
|
|
3664
|
+
nextMonth === TEVET) {
|
|
3665
|
+
continue;
|
|
3666
|
+
}
|
|
3667
|
+
let ykk = new HDate(29, month, year);
|
|
3668
|
+
const dow = ykk.getDay();
|
|
3669
|
+
if (dow === FRI || dow === SAT) {
|
|
3670
|
+
ykk = ykk.onOrBefore(THU);
|
|
3671
|
+
}
|
|
3672
|
+
const nextMonthName = HDate.getMonthName(nextMonth, year);
|
|
3673
|
+
const ev = new YomKippurKatanEvent(ykk, nextMonthName);
|
|
3674
|
+
add(ev);
|
|
3675
|
+
}
|
|
3676
|
+
const sedra = getSedra(year, false);
|
|
3677
|
+
const beshalachHd = sedra.find(15);
|
|
3678
|
+
add(new HolidayEvent(beshalachHd, holidayDesc.SHABBAT_SHIRAH, SPECIAL_SHABBAT));
|
|
3679
|
+
// Birkat Hachamah appears only once every 28 years
|
|
3680
|
+
const birkatHaChama = getBirkatHaChama(year);
|
|
3681
|
+
if (birkatHaChama) {
|
|
3682
|
+
const hd = new HDate(birkatHaChama);
|
|
3683
|
+
add(new HolidayEvent(hd, holidayDesc.BIRKAT_HACHAMAH, MINOR_HOLIDAY, { emoji: '☀️' }));
|
|
3684
|
+
}
|
|
3685
|
+
yearCache.set(year, map);
|
|
3686
|
+
return map;
|
|
3687
|
+
}
|
|
3688
|
+
/**
|
|
3689
|
+
* Birkat Hachamah appears only once every 28 years.
|
|
3690
|
+
* Although almost always in Nisan, it can occur in Adar II.
|
|
3691
|
+
* - 27 Adar II 5461 (Gregorian year 1701)
|
|
3692
|
+
* - 29 Adar II 5993 (Gregorian year 2233)
|
|
3693
|
+
*
|
|
3694
|
+
* Due to drift, this will eventually slip into Iyyar
|
|
3695
|
+
* - 2 Iyyar 7141 (Gregorian year 3381)
|
|
3696
|
+
* @private
|
|
3697
|
+
*/
|
|
3698
|
+
function getBirkatHaChama(year) {
|
|
3699
|
+
const leap = HDate.isLeapYear(year);
|
|
3700
|
+
const startMonth = leap ? ADAR_II : NISAN;
|
|
3701
|
+
const startDay = leap ? 20 : 1;
|
|
3702
|
+
const baseRd = HDate.hebrew2abs(year, startMonth, startDay);
|
|
3703
|
+
for (let day = 0; day <= 40; day++) {
|
|
3704
|
+
const abs = baseRd + day;
|
|
3705
|
+
const elapsed = abs + 1373429;
|
|
3706
|
+
if (elapsed % 10227 === 172) {
|
|
3707
|
+
return abs;
|
|
3708
|
+
}
|
|
3709
|
+
}
|
|
3710
|
+
return 0;
|
|
3711
|
+
}
|
|
3712
|
+
console.log(getHolidaysOnDate(new HDate(1, 1, 5757)));
|