@hebcal/core 6.0.8 → 6.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/DailyLearning.d.ts +1 -1
- package/dist/HolidayEvent.d.ts +1 -0
- package/dist/ashkenazi.po.d.ts +14 -2
- package/dist/bundle.js +2085 -1535
- package/dist/bundle.js.map +1 -1
- package/dist/bundle.min.js +17 -19
- package/dist/bundle.min.js.map +1 -1
- package/dist/coverage/block-navigation.d.ts +1 -0
- package/dist/coverage/block-navigation.js +70 -0
- package/dist/coverage/prettify.d.ts +0 -0
- package/dist/coverage/prettify.js +477 -0
- package/dist/coverage/sorter.d.ts +1 -0
- package/dist/coverage/sorter.js +176 -0
- package/dist/eslint.config.d.mts +83 -0
- package/dist/eslint.config.mjs +28 -0
- package/dist/esm/DailyLearning.d.ts +1 -1
- package/dist/esm/DailyLearning.js +1 -1
- package/dist/esm/DailyLearning.js.map +1 -1
- package/dist/esm/HebrewDateEvent.js +5 -5
- package/dist/esm/HebrewDateEvent.js.map +1 -1
- package/dist/esm/HolidayEvent.d.ts +1 -0
- package/dist/esm/HolidayEvent.js +17 -1
- package/dist/esm/HolidayEvent.js.map +1 -1
- package/dist/esm/MevarchimChodeshEvent.js +2 -1
- package/dist/esm/MevarchimChodeshEvent.js.map +1 -1
- package/dist/esm/ParshaEvent.js +2 -1
- package/dist/esm/ParshaEvent.js.map +1 -1
- package/dist/esm/TimedEvent.js +9 -3
- package/dist/esm/TimedEvent.js.map +1 -1
- package/dist/esm/YomKippurKatanEvent.js +2 -1
- package/dist/esm/YomKippurKatanEvent.js.map +1 -1
- package/dist/esm/ashkenazi.po.d.ts +14 -2
- package/dist/esm/ashkenazi.po.js +2 -2
- package/dist/esm/ashkenazi.po.js.map +1 -1
- package/dist/esm/calendar.js +6 -8
- package/dist/esm/calendar.js.map +1 -1
- package/dist/esm/candles.js +11 -3
- package/dist/esm/candles.js.map +1 -1
- package/dist/esm/event.js +18 -1
- package/dist/esm/event.js.map +1 -1
- package/dist/esm/getStartAndEnd.js +2 -2
- package/dist/esm/getStartAndEnd.js.map +1 -1
- package/dist/esm/hallel.js +1 -1
- package/dist/esm/he-x-NoNikud.po.js +1 -1
- package/dist/esm/he.po.d.ts +20 -0
- package/dist/esm/he.po.js +2 -2
- package/dist/esm/he.po.js.map +1 -1
- package/dist/esm/hebcal.js +3 -3
- package/dist/esm/hebcal.js.map +1 -1
- package/dist/esm/holidays.js +3 -3
- package/dist/esm/holidays.js.map +1 -1
- package/dist/esm/index.d.ts +2 -0
- package/dist/esm/index.js +3 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/isAssurBemlacha.js +1 -1
- package/dist/esm/locale.d.ts +1 -2
- package/dist/esm/locale.js +1 -1
- package/dist/esm/locale.js.map +1 -1
- package/dist/esm/location.js +7 -1
- package/dist/esm/location.js.map +1 -1
- package/dist/esm/modern.js +1 -1
- package/dist/esm/molad.d.ts +71 -1
- package/dist/esm/molad.js +113 -12
- package/dist/esm/molad.js.map +1 -1
- package/dist/esm/moladBase.d.ts +15 -0
- package/dist/esm/moladBase.js +83 -0
- package/dist/esm/moladBase.js.map +1 -0
- package/dist/esm/moladDate.d.ts +12 -0
- package/dist/esm/moladDate.js +63 -0
- package/dist/esm/moladDate.js.map +1 -0
- package/dist/esm/omer.d.ts +0 -1
- package/dist/esm/omer.js +7 -4
- package/dist/esm/omer.js.map +1 -1
- package/dist/esm/parshaName.js +2 -2
- package/dist/esm/parshaName.js.map +1 -1
- package/dist/esm/parshaYear.js +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 +5 -6
- package/dist/esm/reformatTimeStr.js.map +1 -1
- package/dist/esm/sedra.js +13 -7
- package/dist/esm/sedra.js.map +1 -1
- package/dist/esm/staticHolidays.js +1 -1
- package/dist/esm/tachanun.js +4 -4
- package/dist/esm/tachanun.js.map +1 -1
- package/dist/esm/zmanim.d.ts +114 -1
- package/dist/esm/zmanim.js +242 -8
- package/dist/esm/zmanim.js.map +1 -1
- package/dist/he.po.d.ts +20 -0
- package/dist/index.d.ts +2 -0
- package/dist/locale.d.ts +1 -2
- package/dist/molad.d.ts +71 -1
- package/dist/moladBase.d.ts +15 -0
- package/dist/moladDate.d.ts +12 -0
- package/dist/omer.d.ts +0 -1
- package/dist/pkgVersion.d.ts +1 -1
- package/dist/po2json.js +3 -4
- package/dist/src/DailyLearning.d.ts +1 -1
- package/dist/src/HebrewDateEvent.js +4 -4
- package/dist/src/HolidayEvent.d.ts +1 -0
- package/dist/src/HolidayEvent.js +16 -0
- package/dist/src/MevarchimChodeshEvent.js +1 -0
- package/dist/src/ParshaEvent.js +1 -0
- package/dist/src/TimedEvent.js +8 -2
- package/dist/src/YomKippurKatanEvent.js +1 -0
- package/dist/src/ashkenazi.po.d.ts +14 -2
- package/dist/src/ashkenazi.po.js +1 -1
- package/dist/src/calendar.js +5 -7
- package/dist/src/candles.js +10 -2
- package/dist/src/event.js +17 -0
- package/dist/src/getStartAndEnd.js +1 -1
- package/dist/src/he.po.d.ts +20 -0
- package/dist/src/he.po.js +1 -1
- package/dist/src/hebcal.js +2 -2
- package/dist/src/holidays.js +2 -2
- package/dist/src/index.d.ts +2 -0
- package/dist/src/index.js +2 -0
- package/dist/src/locale.d.ts +1 -2
- package/dist/src/locale.js +1 -1
- package/dist/src/location.js +6 -0
- package/dist/src/molad.d.ts +71 -1
- package/dist/src/molad.js +112 -11
- package/dist/src/moladBase.d.ts +15 -0
- package/dist/src/moladBase.js +78 -0
- package/dist/src/moladDate.d.ts +12 -0
- package/dist/src/moladDate.js +58 -0
- package/dist/src/omer.d.ts +0 -1
- package/dist/src/omer.js +6 -3
- package/dist/src/parshaName.js +1 -1
- package/dist/src/pkgVersion.d.ts +1 -1
- package/dist/src/pkgVersion.js +1 -1
- package/dist/src/reformatTimeStr.js +4 -5
- package/dist/src/sedra.js +12 -6
- package/dist/src/tachanun.js +3 -3
- package/dist/src/zmanim.d.ts +114 -1
- package/dist/src/zmanim.js +240 -6
- package/dist/version.js +1 -2
- package/dist/zmanim.d.ts +114 -1
- package/package.json +17 -19
- package/dist/size-demo/dist/getHoliday.d.ts +0 -1944
- package/dist/size-demo/dist/getHoliday.js +0 -3712
- package/dist/size-demo/dist/parshiyot.js +0 -10662
- package/dist/size-demo/dist/sedra.d.ts +0 -1411
- package/dist/size-demo/dist/sedra.js +0 -2359
- package/dist/size-demo/dist/tachanun.d.ts +0 -1015
- package/dist/size-demo/dist/tachanun.js +0 -1755
- package/dist/size-demo/getHoliday.d.ts +0 -1
- package/dist/size-demo/getHoliday.js +0 -3
- package/dist/size-demo/parshiyot.d.ts +0 -1
- package/dist/size-demo/parshiyot.js +0 -11
- package/dist/size-demo/rollup.config.d.ts +0 -3
- package/dist/size-demo/rollup.config.js +0 -47
- package/dist/size-demo/sedra.d.ts +0 -1
- package/dist/size-demo/sedra.js +0 -3
- package/dist/size-demo/tachanun.d.ts +0 -1
- package/dist/size-demo/tachanun.js +0 -3
|
@@ -1,2359 +0,0 @@
|
|
|
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 = 1;
|
|
181
|
-
const IYYAR = 2;
|
|
182
|
-
const SIVAN = 3;
|
|
183
|
-
const TAMUZ = 4;
|
|
184
|
-
const AV = 5;
|
|
185
|
-
const ELUL = 6;
|
|
186
|
-
const TISHREI = 7;
|
|
187
|
-
const CHESHVAN = 8;
|
|
188
|
-
const KISLEV = 9;
|
|
189
|
-
const TEVET = 10;
|
|
190
|
-
const SHVAT = 11;
|
|
191
|
-
const ADAR_I = 12;
|
|
192
|
-
const ADAR_II = 13;
|
|
193
|
-
/**
|
|
194
|
-
* Hebrew months of the year (NISAN=1, TISHREI=7)
|
|
195
|
-
* @readonly
|
|
196
|
-
* @enum {number}
|
|
197
|
-
*/
|
|
198
|
-
const months = {
|
|
199
|
-
/** Elul / אלול */
|
|
200
|
-
ELUL,
|
|
201
|
-
/** Tishrei / תִּשְׁרֵי */
|
|
202
|
-
TISHREI,
|
|
203
|
-
/** Adar Sheini (only on leap years) / אדר ב׳ */
|
|
204
|
-
ADAR_II,
|
|
205
|
-
};
|
|
206
|
-
const NISAN_STR = 'Nisan';
|
|
207
|
-
const monthNames0 = [
|
|
208
|
-
'',
|
|
209
|
-
NISAN_STR,
|
|
210
|
-
'Iyyar',
|
|
211
|
-
'Sivan',
|
|
212
|
-
'Tamuz',
|
|
213
|
-
'Av',
|
|
214
|
-
'Elul',
|
|
215
|
-
'Tishrei',
|
|
216
|
-
'Cheshvan',
|
|
217
|
-
'Kislev',
|
|
218
|
-
'Tevet',
|
|
219
|
-
"Sh'vat",
|
|
220
|
-
];
|
|
221
|
-
/*
|
|
222
|
-
* Transliterations of Hebrew month names.
|
|
223
|
-
* Regular years are index 0 and leap years are index 1.
|
|
224
|
-
* @private
|
|
225
|
-
*/
|
|
226
|
-
const monthNames = [
|
|
227
|
-
[...monthNames0, 'Adar', NISAN_STR],
|
|
228
|
-
[...monthNames0, 'Adar I', 'Adar II', NISAN_STR],
|
|
229
|
-
];
|
|
230
|
-
const edCache = new Map();
|
|
231
|
-
const EPOCH = -1373428;
|
|
232
|
-
// Avg year length in the cycle (19 solar years with 235 lunar months)
|
|
233
|
-
const AVG_HEBYEAR_DAYS = 365.24682220597794;
|
|
234
|
-
/**
|
|
235
|
-
* @private
|
|
236
|
-
*/
|
|
237
|
-
function assertNumber(n, name) {
|
|
238
|
-
if (typeof n !== 'number' || isNaN(n)) {
|
|
239
|
-
throw new TypeError(`param '${name}' not a number: ${n}`);
|
|
240
|
-
}
|
|
241
|
-
}
|
|
242
|
-
/**
|
|
243
|
-
* Converts Hebrew date to R.D. (Rata Die) fixed days.
|
|
244
|
-
* R.D. 1 is the imaginary date Monday, January 1, 1 on the Gregorian
|
|
245
|
-
* Calendar.
|
|
246
|
-
* @param year Hebrew year
|
|
247
|
-
* @param month Hebrew month
|
|
248
|
-
* @param day Hebrew date (1-30)
|
|
249
|
-
* @example
|
|
250
|
-
* const abs = hebrew2abs(5769, months.CHESHVAN, 15);
|
|
251
|
-
*/
|
|
252
|
-
function hebrew2abs(year, month, day) {
|
|
253
|
-
assertNumber(year, 'year');
|
|
254
|
-
assertNumber(month, 'month');
|
|
255
|
-
assertNumber(day, 'day');
|
|
256
|
-
if (year < 1) {
|
|
257
|
-
throw new RangeError(`hebrew2abs: invalid year ${year}`);
|
|
258
|
-
}
|
|
259
|
-
let tempabs = day;
|
|
260
|
-
if (month < TISHREI) {
|
|
261
|
-
for (let m = TISHREI; m <= monthsInYear(year); m++) {
|
|
262
|
-
tempabs += daysInMonth(m, year);
|
|
263
|
-
}
|
|
264
|
-
for (let m = NISAN; m < month; m++) {
|
|
265
|
-
tempabs += daysInMonth(m, year);
|
|
266
|
-
}
|
|
267
|
-
}
|
|
268
|
-
else {
|
|
269
|
-
for (let m = TISHREI; m < month; m++) {
|
|
270
|
-
tempabs += daysInMonth(m, year);
|
|
271
|
-
}
|
|
272
|
-
}
|
|
273
|
-
return EPOCH + elapsedDays(year) + tempabs - 1;
|
|
274
|
-
}
|
|
275
|
-
/**
|
|
276
|
-
* @private
|
|
277
|
-
*/
|
|
278
|
-
function newYear(year) {
|
|
279
|
-
return EPOCH + elapsedDays(year);
|
|
280
|
-
}
|
|
281
|
-
/**
|
|
282
|
-
* Converts absolute R.D. days to Hebrew date
|
|
283
|
-
* @param abs absolute R.D. days
|
|
284
|
-
*/
|
|
285
|
-
function abs2hebrew(abs) {
|
|
286
|
-
assertNumber(abs, 'abs');
|
|
287
|
-
abs = Math.trunc(abs);
|
|
288
|
-
if (abs <= EPOCH) {
|
|
289
|
-
throw new RangeError(`abs2hebrew: ${abs} is before epoch`);
|
|
290
|
-
}
|
|
291
|
-
// first, quickly approximate year
|
|
292
|
-
let year = Math.floor((abs - EPOCH) / AVG_HEBYEAR_DAYS);
|
|
293
|
-
while (newYear(year) <= abs) {
|
|
294
|
-
++year;
|
|
295
|
-
}
|
|
296
|
-
--year;
|
|
297
|
-
let month = abs < hebrew2abs(year, 1, 1) ? 7 : 1;
|
|
298
|
-
while (abs > hebrew2abs(year, month, daysInMonth(month, year))) {
|
|
299
|
-
++month;
|
|
300
|
-
}
|
|
301
|
-
const day = 1 + abs - hebrew2abs(year, month, 1);
|
|
302
|
-
return { yy: year, mm: month, dd: day };
|
|
303
|
-
}
|
|
304
|
-
/**
|
|
305
|
-
* Returns true if Hebrew year is a leap year
|
|
306
|
-
* @param year Hebrew year
|
|
307
|
-
*/
|
|
308
|
-
function isLeapYear(year) {
|
|
309
|
-
return (1 + year * 7) % 19 < 7;
|
|
310
|
-
}
|
|
311
|
-
/**
|
|
312
|
-
* Number of months in this Hebrew year (either 12 or 13 depending on leap year)
|
|
313
|
-
* @param year Hebrew year
|
|
314
|
-
*/
|
|
315
|
-
function monthsInYear(year) {
|
|
316
|
-
return 12 + +isLeapYear(year); // boolean is cast to 1 or 0
|
|
317
|
-
}
|
|
318
|
-
/**
|
|
319
|
-
* Number of days in Hebrew month in a given year (29 or 30)
|
|
320
|
-
* @param month Hebrew month (e.g. months.TISHREI)
|
|
321
|
-
* @param year Hebrew year
|
|
322
|
-
*/
|
|
323
|
-
function daysInMonth(month, year) {
|
|
324
|
-
switch (month) {
|
|
325
|
-
case IYYAR:
|
|
326
|
-
case TAMUZ:
|
|
327
|
-
case ELUL:
|
|
328
|
-
case TEVET:
|
|
329
|
-
case ADAR_II:
|
|
330
|
-
return 29;
|
|
331
|
-
}
|
|
332
|
-
if ((month === ADAR_I && !isLeapYear(year)) ||
|
|
333
|
-
(month === CHESHVAN && !longCheshvan(year)) ||
|
|
334
|
-
(month === KISLEV && shortKislev(year))) {
|
|
335
|
-
return 29;
|
|
336
|
-
}
|
|
337
|
-
else {
|
|
338
|
-
return 30;
|
|
339
|
-
}
|
|
340
|
-
}
|
|
341
|
-
/**
|
|
342
|
-
* Returns a transliterated string name of Hebrew month in year,
|
|
343
|
-
* for example 'Elul' or 'Cheshvan'.
|
|
344
|
-
* @param month Hebrew month (e.g. months.TISHREI)
|
|
345
|
-
* @param year Hebrew year
|
|
346
|
-
*/
|
|
347
|
-
function getMonthName(month, year) {
|
|
348
|
-
assertNumber(month, 'month');
|
|
349
|
-
assertNumber(year, 'year');
|
|
350
|
-
if (month < 1 || month > 14) {
|
|
351
|
-
throw new TypeError(`bad monthNum: ${month}`);
|
|
352
|
-
}
|
|
353
|
-
return monthNames[+isLeapYear(year)][month];
|
|
354
|
-
}
|
|
355
|
-
/**
|
|
356
|
-
* Days from sunday prior to start of Hebrew calendar to mean
|
|
357
|
-
* conjunction of Tishrei in Hebrew YEAR
|
|
358
|
-
* @param year Hebrew year
|
|
359
|
-
*/
|
|
360
|
-
function elapsedDays(year) {
|
|
361
|
-
const n = edCache.get(year);
|
|
362
|
-
if (typeof n === 'number') {
|
|
363
|
-
return n;
|
|
364
|
-
}
|
|
365
|
-
const elapsed = elapsedDays0(year);
|
|
366
|
-
edCache.set(year, elapsed);
|
|
367
|
-
return elapsed;
|
|
368
|
-
}
|
|
369
|
-
/**
|
|
370
|
-
* Days from sunday prior to start of Hebrew calendar to mean
|
|
371
|
-
* conjunction of Tishrei in Hebrew YEAR
|
|
372
|
-
* @private
|
|
373
|
-
* @param year Hebrew year
|
|
374
|
-
*/
|
|
375
|
-
function elapsedDays0(year) {
|
|
376
|
-
const prevYear = year - 1;
|
|
377
|
-
const mElapsed = 235 * Math.floor(prevYear / 19) + // Months in complete 19 year lunar (Metonic) cycles so far
|
|
378
|
-
12 * (prevYear % 19) + // Regular months in this cycle
|
|
379
|
-
Math.floor(((prevYear % 19) * 7 + 1) / 19); // Leap months this cycle
|
|
380
|
-
const pElapsed = 204 + 793 * (mElapsed % 1080);
|
|
381
|
-
const hElapsed = 5 +
|
|
382
|
-
12 * mElapsed +
|
|
383
|
-
793 * Math.floor(mElapsed / 1080) +
|
|
384
|
-
Math.floor(pElapsed / 1080);
|
|
385
|
-
const parts = (pElapsed % 1080) + 1080 * (hElapsed % 24);
|
|
386
|
-
const day = 1 + 29 * mElapsed + Math.floor(hElapsed / 24);
|
|
387
|
-
let altDay = day;
|
|
388
|
-
if (parts >= 19440 ||
|
|
389
|
-
(2 === day % 7 && parts >= 9924 && !isLeapYear(year)) ||
|
|
390
|
-
(1 === day % 7 && parts >= 16789 && isLeapYear(prevYear))) {
|
|
391
|
-
altDay++;
|
|
392
|
-
}
|
|
393
|
-
if (altDay % 7 === 0 || altDay % 7 === 3 || altDay % 7 === 5) {
|
|
394
|
-
return altDay + 1;
|
|
395
|
-
}
|
|
396
|
-
else {
|
|
397
|
-
return altDay;
|
|
398
|
-
}
|
|
399
|
-
}
|
|
400
|
-
/**
|
|
401
|
-
* Number of days in the hebrew YEAR.
|
|
402
|
-
* A common Hebrew calendar year can have a length of 353, 354 or 355 days
|
|
403
|
-
* A leap Hebrew calendar year can have a length of 383, 384 or 385 days
|
|
404
|
-
* @param year Hebrew year
|
|
405
|
-
*/
|
|
406
|
-
function daysInYear(year) {
|
|
407
|
-
return elapsedDays(year + 1) - elapsedDays(year);
|
|
408
|
-
}
|
|
409
|
-
/**
|
|
410
|
-
* true if Cheshvan is long in Hebrew year
|
|
411
|
-
* @param year Hebrew year
|
|
412
|
-
*/
|
|
413
|
-
function longCheshvan(year) {
|
|
414
|
-
return daysInYear(year) % 10 === 5;
|
|
415
|
-
}
|
|
416
|
-
/**
|
|
417
|
-
* true if Kislev is short in Hebrew year
|
|
418
|
-
* @param year Hebrew year
|
|
419
|
-
*/
|
|
420
|
-
function shortKislev(year) {
|
|
421
|
-
return daysInYear(year) % 10 === 3;
|
|
422
|
-
}
|
|
423
|
-
/**
|
|
424
|
-
* Converts Hebrew month string name to numeric
|
|
425
|
-
* @param monthName monthName
|
|
426
|
-
*/
|
|
427
|
-
function monthFromName(monthName) {
|
|
428
|
-
if (typeof monthName === 'number') {
|
|
429
|
-
if (isNaN(monthName) || monthName < 1 || monthName > 14) {
|
|
430
|
-
throw new RangeError(`bad monthName: ${monthName}`);
|
|
431
|
-
}
|
|
432
|
-
return monthName;
|
|
433
|
-
}
|
|
434
|
-
let c = monthName.trim().toLowerCase();
|
|
435
|
-
// remove all niqud and trailing gershayim (for Adar Alef/Bet)
|
|
436
|
-
c = hebrewStripNikkud(c).replace(/׳$/, '');
|
|
437
|
-
// If Hebrew month starts with a bet (for example `בתמוז`) then ignore it
|
|
438
|
-
if (c[0] === 'ב') {
|
|
439
|
-
c = c.substring(1);
|
|
440
|
-
}
|
|
441
|
-
/*
|
|
442
|
-
the Hebrew months are unique to their second letter
|
|
443
|
-
N Nisan (November?)
|
|
444
|
-
I Iyyar
|
|
445
|
-
E Elul
|
|
446
|
-
C Cheshvan
|
|
447
|
-
K Kislev
|
|
448
|
-
1 1Adar
|
|
449
|
-
2 2Adar
|
|
450
|
-
Si Sh Sivan, Shvat
|
|
451
|
-
Ta Ti Te Tamuz, Tishrei, Tevet
|
|
452
|
-
Av Ad Av, Adar
|
|
453
|
-
|
|
454
|
-
אב אד אי אל אב אדר אייר אלול
|
|
455
|
-
ח חשון
|
|
456
|
-
ט טבת
|
|
457
|
-
כ כסלו
|
|
458
|
-
נ ניסן
|
|
459
|
-
ס סיון
|
|
460
|
-
ש שבט
|
|
461
|
-
תמ תש תמוז תשרי
|
|
462
|
-
*/
|
|
463
|
-
switch (c[0]) {
|
|
464
|
-
case 'n':
|
|
465
|
-
case 'נ':
|
|
466
|
-
if (c[1] === 'o') {
|
|
467
|
-
break; /* this catches "november" */
|
|
468
|
-
}
|
|
469
|
-
return NISAN;
|
|
470
|
-
case 'i':
|
|
471
|
-
return IYYAR;
|
|
472
|
-
case 'e':
|
|
473
|
-
return ELUL;
|
|
474
|
-
case 'c':
|
|
475
|
-
case 'ח':
|
|
476
|
-
return CHESHVAN;
|
|
477
|
-
case 'k':
|
|
478
|
-
case 'כ':
|
|
479
|
-
return KISLEV;
|
|
480
|
-
case 's':
|
|
481
|
-
switch (c[1]) {
|
|
482
|
-
case 'i':
|
|
483
|
-
return SIVAN;
|
|
484
|
-
case 'h':
|
|
485
|
-
return SHVAT;
|
|
486
|
-
}
|
|
487
|
-
break;
|
|
488
|
-
case 't':
|
|
489
|
-
switch (c[1]) {
|
|
490
|
-
case 'a':
|
|
491
|
-
return TAMUZ;
|
|
492
|
-
case 'i':
|
|
493
|
-
return TISHREI;
|
|
494
|
-
case 'e':
|
|
495
|
-
return TEVET;
|
|
496
|
-
}
|
|
497
|
-
break;
|
|
498
|
-
case 'a':
|
|
499
|
-
switch (c[1]) {
|
|
500
|
-
case 'v':
|
|
501
|
-
return AV;
|
|
502
|
-
case 'd':
|
|
503
|
-
if (/(1|[^i]i|a|א)$/i.test(c)) {
|
|
504
|
-
return ADAR_I;
|
|
505
|
-
}
|
|
506
|
-
return ADAR_II; // else assume sheini
|
|
507
|
-
}
|
|
508
|
-
break;
|
|
509
|
-
case 'ס':
|
|
510
|
-
return SIVAN;
|
|
511
|
-
case 'ט':
|
|
512
|
-
return TEVET;
|
|
513
|
-
case 'ש':
|
|
514
|
-
return SHVAT;
|
|
515
|
-
case 'א':
|
|
516
|
-
switch (c[1]) {
|
|
517
|
-
case 'ב':
|
|
518
|
-
return AV;
|
|
519
|
-
case 'ד':
|
|
520
|
-
if (/(1|[^i]i|a|א)$/i.test(c)) {
|
|
521
|
-
return ADAR_I;
|
|
522
|
-
}
|
|
523
|
-
return ADAR_II; // else assume sheini
|
|
524
|
-
case 'י':
|
|
525
|
-
return IYYAR;
|
|
526
|
-
case 'ל':
|
|
527
|
-
return ELUL;
|
|
528
|
-
}
|
|
529
|
-
break;
|
|
530
|
-
case 'ת':
|
|
531
|
-
switch (c[1]) {
|
|
532
|
-
case 'מ':
|
|
533
|
-
return TAMUZ;
|
|
534
|
-
case 'ש':
|
|
535
|
-
return TISHREI;
|
|
536
|
-
}
|
|
537
|
-
break;
|
|
538
|
-
}
|
|
539
|
-
throw new RangeError(`bad monthName: ${monthName}`);
|
|
540
|
-
}
|
|
541
|
-
/*! @hebcal/hdate v0.21.1, distributed under GPLv2 https://www.gnu.org/licenses/gpl-2.0.txt */
|
|
542
|
-
const GERESH = '׳';
|
|
543
|
-
const GERSHAYIM = '״';
|
|
544
|
-
const heb2num = {
|
|
545
|
-
א: 1,
|
|
546
|
-
ב: 2,
|
|
547
|
-
ג: 3,
|
|
548
|
-
ד: 4,
|
|
549
|
-
ה: 5,
|
|
550
|
-
ו: 6,
|
|
551
|
-
ז: 7,
|
|
552
|
-
ח: 8,
|
|
553
|
-
ט: 9,
|
|
554
|
-
י: 10,
|
|
555
|
-
כ: 20,
|
|
556
|
-
ל: 30,
|
|
557
|
-
מ: 40,
|
|
558
|
-
נ: 50,
|
|
559
|
-
ס: 60,
|
|
560
|
-
ע: 70,
|
|
561
|
-
פ: 80,
|
|
562
|
-
צ: 90,
|
|
563
|
-
ק: 100,
|
|
564
|
-
ר: 200,
|
|
565
|
-
ש: 300,
|
|
566
|
-
ת: 400,
|
|
567
|
-
};
|
|
568
|
-
const num2heb = {};
|
|
569
|
-
for (const [key, val] of Object.entries(heb2num)) {
|
|
570
|
-
num2heb[val] = key;
|
|
571
|
-
}
|
|
572
|
-
function num2digits(num) {
|
|
573
|
-
const digits = [];
|
|
574
|
-
while (num > 0) {
|
|
575
|
-
if (num === 15 || num === 16) {
|
|
576
|
-
digits.push(9);
|
|
577
|
-
digits.push(num - 9);
|
|
578
|
-
break;
|
|
579
|
-
}
|
|
580
|
-
let incr = 100;
|
|
581
|
-
let i;
|
|
582
|
-
for (i = 400; i > num; i -= incr) {
|
|
583
|
-
if (i === incr) {
|
|
584
|
-
incr = incr / 10;
|
|
585
|
-
}
|
|
586
|
-
}
|
|
587
|
-
digits.push(i);
|
|
588
|
-
num -= i;
|
|
589
|
-
}
|
|
590
|
-
return digits;
|
|
591
|
-
}
|
|
592
|
-
/**
|
|
593
|
-
* Converts a numerical value to a string of Hebrew letters.
|
|
594
|
-
*
|
|
595
|
-
* When specifying years of the Hebrew calendar in the present millennium,
|
|
596
|
-
* we omit the thousands (which is presently 5 [ה]).
|
|
597
|
-
* @example
|
|
598
|
-
* gematriya(5774) // 'תשע״ד' - cropped to 774
|
|
599
|
-
* gematriya(25) // 'כ״ה'
|
|
600
|
-
* gematriya(60) // 'ס׳'
|
|
601
|
-
* gematriya(3761) // 'ג׳תשס״א'
|
|
602
|
-
* gematriya(1123) // 'א׳קכ״ג'
|
|
603
|
-
*/
|
|
604
|
-
function gematriya(num) {
|
|
605
|
-
const num1 = parseInt(num, 10);
|
|
606
|
-
if (!num1 || num1 < 0) {
|
|
607
|
-
throw new TypeError(`invalid number: ${num}`);
|
|
608
|
-
}
|
|
609
|
-
let str = '';
|
|
610
|
-
const thousands = Math.floor(num1 / 1000);
|
|
611
|
-
if (thousands > 0 && thousands !== 5) {
|
|
612
|
-
const tdigits = num2digits(thousands);
|
|
613
|
-
for (const tdig of tdigits) {
|
|
614
|
-
str += num2heb[tdig];
|
|
615
|
-
}
|
|
616
|
-
str += GERESH;
|
|
617
|
-
}
|
|
618
|
-
const digits = num2digits(num1 % 1000);
|
|
619
|
-
if (digits.length === 1) {
|
|
620
|
-
return str + num2heb[digits[0]] + GERESH;
|
|
621
|
-
}
|
|
622
|
-
for (let i = 0; i < digits.length; i++) {
|
|
623
|
-
if (i + 1 === digits.length) {
|
|
624
|
-
str += GERSHAYIM;
|
|
625
|
-
}
|
|
626
|
-
str += num2heb[digits[i]];
|
|
627
|
-
}
|
|
628
|
-
return str;
|
|
629
|
-
}
|
|
630
|
-
/**
|
|
631
|
-
* Converts a string of Hebrew letters to a numerical value.
|
|
632
|
-
*
|
|
633
|
-
* Only considers the value of Hebrew letters `א` through `ת`.
|
|
634
|
-
* Ignores final Hebrew letters such as `ך` (kaf sofit) or `ם` (mem sofit)
|
|
635
|
-
* and vowels (nekudot).
|
|
636
|
-
*/
|
|
637
|
-
function gematriyaStrToNum(str) {
|
|
638
|
-
let num = 0;
|
|
639
|
-
const gereshIdx = str.indexOf(GERESH);
|
|
640
|
-
if (gereshIdx !== -1 && gereshIdx !== str.length - 1) {
|
|
641
|
-
const thousands = str.substring(0, gereshIdx);
|
|
642
|
-
num += gematriyaStrToNum(thousands) * 1000;
|
|
643
|
-
str = str.substring(gereshIdx);
|
|
644
|
-
}
|
|
645
|
-
for (const ch of str) {
|
|
646
|
-
const n = heb2num[ch];
|
|
647
|
-
if (typeof n === 'number') {
|
|
648
|
-
num += n;
|
|
649
|
-
}
|
|
650
|
-
}
|
|
651
|
-
return num;
|
|
652
|
-
}
|
|
653
|
-
/*! @hebcal/hdate v0.21.1, distributed under GPLv2 https://www.gnu.org/licenses/gpl-2.0.txt */
|
|
654
|
-
var poAshkenazi$1 = { "headers": { "plural-forms": "nplurals=2; plural=(n > 1);", "language": "en_CA@ashkenazi" }, "contexts": { "": { "Tevet": ["Teves"] } } };
|
|
655
|
-
/*! @hebcal/hdate v0.21.1, distributed under GPLv2 https://www.gnu.org/licenses/gpl-2.0.txt */
|
|
656
|
-
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": ["תִּשְׁרֵי"] } } };
|
|
657
|
-
/*! @hebcal/hdate v0.21.1, distributed under GPLv2 https://www.gnu.org/licenses/gpl-2.0.txt */
|
|
658
|
-
const noopLocale = {
|
|
659
|
-
headers: { 'plural-forms': 'nplurals=2; plural=(n!=1);' },
|
|
660
|
-
contexts: { '': {} },
|
|
661
|
-
};
|
|
662
|
-
const alias = {
|
|
663
|
-
h: 'he',
|
|
664
|
-
a: 'ashkenazi',
|
|
665
|
-
s: 'en',
|
|
666
|
-
'': 'en',
|
|
667
|
-
};
|
|
668
|
-
/** @private */
|
|
669
|
-
const locales = new Map();
|
|
670
|
-
/** @private */
|
|
671
|
-
function getEnOrdinal(n) {
|
|
672
|
-
const s = ['th', 'st', 'nd', 'rd'];
|
|
673
|
-
const v = n % 100;
|
|
674
|
-
return n + (s[(v - 20) % 10] || s[v] || s[0]);
|
|
675
|
-
}
|
|
676
|
-
/** @private */
|
|
677
|
-
function checkLocale(locale) {
|
|
678
|
-
if (typeof locale !== 'string') {
|
|
679
|
-
throw new TypeError(`Invalid locale name: ${locale}`);
|
|
680
|
-
}
|
|
681
|
-
locale = alias[locale] || locale;
|
|
682
|
-
return locale.toLowerCase();
|
|
683
|
-
}
|
|
684
|
-
/** @private */
|
|
685
|
-
function getExistingLocale(locale) {
|
|
686
|
-
const locale1 = checkLocale(locale);
|
|
687
|
-
const loc = locales.get(locale1);
|
|
688
|
-
if (!loc) {
|
|
689
|
-
throw new RangeError(`Locale '${locale}' not found`);
|
|
690
|
-
}
|
|
691
|
-
return loc;
|
|
692
|
-
}
|
|
693
|
-
/**
|
|
694
|
-
* A locale in Hebcal is used for translations/transliterations of
|
|
695
|
-
* holidays. `@hebcal/hdate` supports four locales by default
|
|
696
|
-
* * `en` - default, Sephardic transliterations (e.g. "Shabbat")
|
|
697
|
-
* * `ashkenazi` - Ashkenazi transliterations (e.g. "Shabbos")
|
|
698
|
-
* * `he` - Hebrew (e.g. "שַׁבָּת")
|
|
699
|
-
* * `he-x-NoNikud` - Hebrew without nikud (e.g. "שבת")
|
|
700
|
-
*/
|
|
701
|
-
class Locale {
|
|
702
|
-
/**
|
|
703
|
-
* Returns translation only if `locale` offers a non-empty translation for `id`.
|
|
704
|
-
* Otherwise, returns `undefined`.
|
|
705
|
-
* @param id Message ID to translate
|
|
706
|
-
* @param [locale] Optional locale name (i.e: `'he'`, `'fr'`). Defaults to no-op locale.
|
|
707
|
-
*/
|
|
708
|
-
static lookupTranslation(id, locale) {
|
|
709
|
-
const loc = (typeof locale === 'string' && locales.get(checkLocale(locale))) ||
|
|
710
|
-
noopLocale.contexts[''];
|
|
711
|
-
const array = loc[id];
|
|
712
|
-
if ((array === null || array === void 0 ? void 0 : array.length) && array[0].length) {
|
|
713
|
-
return array[0];
|
|
714
|
-
}
|
|
715
|
-
return undefined;
|
|
716
|
-
}
|
|
717
|
-
/**
|
|
718
|
-
* By default, if no translation was found, returns `id`.
|
|
719
|
-
* @param id Message ID to translate
|
|
720
|
-
* @param [locale] Optional locale name (i.e: `'he'`, `'fr'`). Defaults to no-op locale.
|
|
721
|
-
*/
|
|
722
|
-
static gettext(id, locale) {
|
|
723
|
-
const text = this.lookupTranslation(id, locale);
|
|
724
|
-
if (typeof text === 'undefined') {
|
|
725
|
-
return id;
|
|
726
|
-
}
|
|
727
|
-
return text;
|
|
728
|
-
}
|
|
729
|
-
/**
|
|
730
|
-
* Register locale translations.
|
|
731
|
-
* @param locale Locale name (i.e.: `'he'`, `'fr'`)
|
|
732
|
-
* @param data parsed data from a `.po` file.
|
|
733
|
-
*/
|
|
734
|
-
static addLocale(locale, data) {
|
|
735
|
-
locale = checkLocale(locale);
|
|
736
|
-
const ctx = data.contexts;
|
|
737
|
-
if (typeof ctx !== 'object' || typeof ctx[''] !== 'object') {
|
|
738
|
-
throw new TypeError(`Locale '${locale}' invalid compact format`);
|
|
739
|
-
}
|
|
740
|
-
locales.set(locale, ctx['']);
|
|
741
|
-
}
|
|
742
|
-
/**
|
|
743
|
-
* Adds a translation to `locale`, replacing any previous translation.
|
|
744
|
-
* @param locale Locale name (i.e: `'he'`, `'fr'`).
|
|
745
|
-
* @param id Message ID to translate
|
|
746
|
-
* @param translation Translation text
|
|
747
|
-
*/
|
|
748
|
-
static addTranslation(locale, id, translation) {
|
|
749
|
-
const loc = getExistingLocale(locale);
|
|
750
|
-
if (typeof id !== 'string' || id.length === 0) {
|
|
751
|
-
throw new TypeError(`Invalid id string: ${id}`);
|
|
752
|
-
}
|
|
753
|
-
const isArray = Array.isArray(translation);
|
|
754
|
-
if (isArray) {
|
|
755
|
-
const t0 = translation[0];
|
|
756
|
-
if (typeof t0 !== 'string' || t0.length === 0) {
|
|
757
|
-
throw new TypeError(`Invalid translation array: ${translation}`);
|
|
758
|
-
}
|
|
759
|
-
}
|
|
760
|
-
else if (typeof translation !== 'string') {
|
|
761
|
-
throw new TypeError(`Invalid translation string: ${translation}`);
|
|
762
|
-
}
|
|
763
|
-
loc[id] = isArray ? translation : [translation];
|
|
764
|
-
}
|
|
765
|
-
/**
|
|
766
|
-
* Adds multiple translations to `locale`, replacing any previous translations.
|
|
767
|
-
* @param locale Locale name (i.e: `'he'`, `'fr'`).
|
|
768
|
-
* @param data parsed data from a `.po` file.
|
|
769
|
-
*/
|
|
770
|
-
static addTranslations(locale, data) {
|
|
771
|
-
const loc = getExistingLocale(locale);
|
|
772
|
-
const ctx = data.contexts;
|
|
773
|
-
if (typeof ctx !== 'object' || typeof ctx[''] !== 'object') {
|
|
774
|
-
throw new TypeError(`Locale '${locale}' invalid compact format`);
|
|
775
|
-
}
|
|
776
|
-
Object.assign(loc, ctx['']);
|
|
777
|
-
}
|
|
778
|
-
/**
|
|
779
|
-
* Returns the names of registered locales
|
|
780
|
-
*/
|
|
781
|
-
static getLocaleNames() {
|
|
782
|
-
const keys = Array.from(locales.keys());
|
|
783
|
-
return keys.sort((a, b) => a.localeCompare(b));
|
|
784
|
-
}
|
|
785
|
-
/**
|
|
786
|
-
* Checks whether a locale has been registered
|
|
787
|
-
* @param locale Locale name (i.e: `'he'`, `'fr'`).
|
|
788
|
-
*/
|
|
789
|
-
static hasLocale(locale) {
|
|
790
|
-
const locale1 = checkLocale(locale);
|
|
791
|
-
return locales.has(locale1);
|
|
792
|
-
}
|
|
793
|
-
/**
|
|
794
|
-
* Renders a number in ordinal, such as 1st, 2nd or 3rd
|
|
795
|
-
* @param [locale] Optional locale name (i.e: `'he'`, `'fr'`). Defaults to no-op locale.
|
|
796
|
-
*/
|
|
797
|
-
static ordinal(n, locale) {
|
|
798
|
-
let locale0 = locale === null || locale === void 0 ? void 0 : locale.toLowerCase();
|
|
799
|
-
if (!locale0) {
|
|
800
|
-
return getEnOrdinal(n);
|
|
801
|
-
}
|
|
802
|
-
locale0 = alias[locale0] || locale0;
|
|
803
|
-
switch (locale0) {
|
|
804
|
-
case 'en':
|
|
805
|
-
case 'ashkenazi':
|
|
806
|
-
return getEnOrdinal(n);
|
|
807
|
-
case 'es':
|
|
808
|
-
return n + 'º';
|
|
809
|
-
case 'he':
|
|
810
|
-
case 'he-x-nonikud':
|
|
811
|
-
return String(n);
|
|
812
|
-
}
|
|
813
|
-
if (locale0.startsWith('ashkenazi')) {
|
|
814
|
-
return getEnOrdinal(n);
|
|
815
|
-
}
|
|
816
|
-
return n + '.';
|
|
817
|
-
}
|
|
818
|
-
/**
|
|
819
|
-
* Removes nekudot from Hebrew string
|
|
820
|
-
*/
|
|
821
|
-
static hebrewStripNikkud(str) {
|
|
822
|
-
return hebrewStripNikkud(str);
|
|
823
|
-
}
|
|
824
|
-
/**
|
|
825
|
-
* Makes a copy of entire Hebrew locale with no niqqud
|
|
826
|
-
*/
|
|
827
|
-
static copyLocaleNoNikud(data) {
|
|
828
|
-
const strs = data.contexts[''];
|
|
829
|
-
const m = {};
|
|
830
|
-
for (const [key, val] of Object.entries(strs)) {
|
|
831
|
-
m[key] = [hebrewStripNikkud(val[0])];
|
|
832
|
-
}
|
|
833
|
-
return {
|
|
834
|
-
headers: data.headers,
|
|
835
|
-
contexts: { '': m },
|
|
836
|
-
};
|
|
837
|
-
}
|
|
838
|
-
}
|
|
839
|
-
Locale.addLocale('en', noopLocale);
|
|
840
|
-
/* Ashkenazic transliterations */
|
|
841
|
-
Locale.addLocale('ashkenazi', poAshkenazi$1);
|
|
842
|
-
/* Hebrew with nikkud */
|
|
843
|
-
Locale.addLocale('he', poHe$1);
|
|
844
|
-
/* Hebrew without nikkud */
|
|
845
|
-
const poHeNoNikud$1 = Locale.copyLocaleNoNikud(poHe$1);
|
|
846
|
-
Locale.addLocale('he-x-NoNikud', poHeNoNikud$1);
|
|
847
|
-
/*! @hebcal/hdate v0.21.1, distributed under GPLv2 https://www.gnu.org/licenses/gpl-2.0.txt */
|
|
848
|
-
/*
|
|
849
|
-
Hebcal - A Jewish Calendar Generator
|
|
850
|
-
Copyright (c) 1994-2020 Danny Sadinoff
|
|
851
|
-
Portions copyright Eyal Schachter and Michael J. Radwin
|
|
852
|
-
|
|
853
|
-
https://github.com/hebcal/hebcal-es6
|
|
854
|
-
|
|
855
|
-
This program is free software; you can redistribute it and/or
|
|
856
|
-
modify it under the terms of the GNU General Public License
|
|
857
|
-
as published by the Free Software Foundation; either version 2
|
|
858
|
-
of the License, or (at your option) any later version.
|
|
859
|
-
|
|
860
|
-
This program is distributed in the hope that it will be useful,
|
|
861
|
-
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
862
|
-
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
863
|
-
GNU General Public License for more details.
|
|
864
|
-
|
|
865
|
-
You should have received a copy of the GNU General Public License
|
|
866
|
-
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
867
|
-
*/
|
|
868
|
-
function mod(x, y) {
|
|
869
|
-
return x - y * Math.floor(x / y);
|
|
870
|
-
}
|
|
871
|
-
function isSimpleHebrewDate(obj) {
|
|
872
|
-
return obj.yy !== undefined;
|
|
873
|
-
}
|
|
874
|
-
const UNITS_DAY = 'day';
|
|
875
|
-
const UNITS_WEEK = 'week';
|
|
876
|
-
const UNITS_MONTH = 'month';
|
|
877
|
-
const UNITS_YEAR = 'year';
|
|
878
|
-
/**
|
|
879
|
-
* A `HDate` represents a Hebrew calendar date.
|
|
880
|
-
*
|
|
881
|
-
* An instance of this class encapsulates a date in the Hebrew calendar system.
|
|
882
|
-
* It consists of a year, month, and day, without any associated time or location data.
|
|
883
|
-
* The Hebrew calendar is a lunisolar calendar, meaning it is based on both lunar and solar cycles.
|
|
884
|
-
*
|
|
885
|
-
* A Hebrew date internally stores three numbers:
|
|
886
|
-
* - year: The Hebrew year (1-9999). Counted from the traditional Hebrew date of creation (3761 BCE in the Gregorian calendar)
|
|
887
|
-
* - 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.
|
|
888
|
-
* - day: The day of the month (1-30)
|
|
889
|
-
*
|
|
890
|
-
* This class uses Rata Die to convert between the Hebrew and Gregorian calendars.
|
|
891
|
-
*
|
|
892
|
-
* To calculate times of day, use `Zmanim` class from `@hebcal/core`
|
|
893
|
-
* @see {@link https://en.wikipedia.org/wiki/Rata_Die | Rata Die}
|
|
894
|
-
* @see {@link https://hebcal.github.io/api/core/classes/Zmanim.html | Zmanim}
|
|
895
|
-
*/
|
|
896
|
-
class HDate {
|
|
897
|
-
/**
|
|
898
|
-
* Create a Hebrew date. There are 3 basic forms for the `HDate()` constructor.
|
|
899
|
-
*
|
|
900
|
-
* 1. No parameters - represents the current Hebrew date at time of instantiation
|
|
901
|
-
* 2. One parameter
|
|
902
|
-
* * `Date` - represents the Hebrew date corresponding to the Gregorian date using
|
|
903
|
-
* local time. Hours, minutes, seconds and milliseconds are ignored.
|
|
904
|
-
* * `HDate` - clones a copy of the given Hebrew date
|
|
905
|
-
* * `number` - Converts absolute R.D. days to Hebrew date.
|
|
906
|
-
* R.D. 1 == the imaginary date January 1, 1 (Gregorian)
|
|
907
|
-
* 3. Three parameters: Hebrew day, Hebrew month, Hebrew year. Hebrew day should
|
|
908
|
-
* be a number between 1-30, Hebrew month can be a number or string, and
|
|
909
|
-
* Hebrew year is always a number.
|
|
910
|
-
* @example
|
|
911
|
-
* import {HDate, months} from '@hebcal/hdate';
|
|
912
|
-
*
|
|
913
|
-
* const hd1 = new HDate();
|
|
914
|
-
* const hd2 = new HDate(new Date(2008, 10, 13));
|
|
915
|
-
* const hd3 = new HDate(15, 'Cheshvan', 5769);
|
|
916
|
-
* const hd4 = new HDate(15, months.CHESHVAN, 5769);
|
|
917
|
-
* const hd5 = new HDate(733359); // ==> 15 Cheshvan 5769
|
|
918
|
-
* const monthName = 'אייר';
|
|
919
|
-
* const hd6 = new HDate(5, monthName, 5773);
|
|
920
|
-
* @param [day] - Day of month (1-30) if a `number`.
|
|
921
|
-
* If a `Date` is specified, represents the Hebrew date corresponding to the
|
|
922
|
-
* Gregorian date using local time.
|
|
923
|
-
* If an `HDate` is specified, clones a copy of the given Hebrew date.
|
|
924
|
-
* @param [month] - Hebrew month of year (1=NISAN, 7=TISHREI)
|
|
925
|
-
* @param [year] - Hebrew year
|
|
926
|
-
*/
|
|
927
|
-
constructor(day, month, year) {
|
|
928
|
-
if (arguments.length === 2 || arguments.length > 3) {
|
|
929
|
-
throw new TypeError('HDate constructor requires 0, 1 or 3 arguments');
|
|
930
|
-
}
|
|
931
|
-
if (arguments.length === 3) {
|
|
932
|
-
// Hebrew day, Hebrew month, Hebrew year
|
|
933
|
-
this.dd = this.mm = 1;
|
|
934
|
-
const yy = typeof year === 'string' ? parseInt(year, 10) : year;
|
|
935
|
-
if (isNaN(yy)) {
|
|
936
|
-
throw new TypeError(`HDate called with bad year: ${year}`);
|
|
937
|
-
}
|
|
938
|
-
this.yy = yy;
|
|
939
|
-
setMonth(this, month); // will throw if we can't parse
|
|
940
|
-
const dd = typeof day === 'string' ? parseInt(day, 10) : day;
|
|
941
|
-
if (isNaN(dd)) {
|
|
942
|
-
throw new TypeError(`HDate called with bad day: ${day}`);
|
|
943
|
-
}
|
|
944
|
-
setDate(this, dd);
|
|
945
|
-
}
|
|
946
|
-
else {
|
|
947
|
-
// 0 arguments
|
|
948
|
-
if (typeof day === 'undefined' || day === null) {
|
|
949
|
-
day = new Date();
|
|
950
|
-
}
|
|
951
|
-
// 1 argument
|
|
952
|
-
const abs0 = typeof day === 'number' && !isNaN(day)
|
|
953
|
-
? day
|
|
954
|
-
: isDate(day)
|
|
955
|
-
? greg2abs(day)
|
|
956
|
-
: isSimpleHebrewDate(day)
|
|
957
|
-
? day
|
|
958
|
-
: null;
|
|
959
|
-
if (abs0 === null) {
|
|
960
|
-
throw new TypeError(`HDate called with bad arg: ${day}`);
|
|
961
|
-
}
|
|
962
|
-
const isNumber = typeof abs0 === 'number';
|
|
963
|
-
const d = isNumber ? abs2hebrew(abs0) : abs0;
|
|
964
|
-
this.yy = d.yy;
|
|
965
|
-
this.mm = d.mm;
|
|
966
|
-
this.dd = d.dd;
|
|
967
|
-
if (isNumber) {
|
|
968
|
-
this.rd = abs0;
|
|
969
|
-
}
|
|
970
|
-
}
|
|
971
|
-
}
|
|
972
|
-
/**
|
|
973
|
-
* Returns the Hebrew year of this Hebrew date
|
|
974
|
-
* @returns an integer >= 1
|
|
975
|
-
* @example
|
|
976
|
-
* const hd = new HDate(new Date(2008, 10, 13)); // 15 Cheshvan 5769
|
|
977
|
-
* hd.getFullYear(); // 5769
|
|
978
|
-
*/
|
|
979
|
-
getFullYear() {
|
|
980
|
-
return this.yy;
|
|
981
|
-
}
|
|
982
|
-
/**
|
|
983
|
-
* Returns `true` if this Hebrew date occurs during a Hebrew leap year
|
|
984
|
-
* @example
|
|
985
|
-
* const hd = new HDate(new Date(2008, 10, 13)); // 15 Cheshvan 5769
|
|
986
|
-
* hd.isLeapYear(); // false
|
|
987
|
-
*/
|
|
988
|
-
isLeapYear() {
|
|
989
|
-
return isLeapYear(this.yy);
|
|
990
|
-
}
|
|
991
|
-
/**
|
|
992
|
-
* Returns the Hebrew month (1=NISAN, 7=TISHREI) of this Hebrew date
|
|
993
|
-
* @returns an integer 1-13
|
|
994
|
-
* @example
|
|
995
|
-
* const hd = new HDate(new Date(2008, 10, 13)); // 15 Cheshvan 5769
|
|
996
|
-
* hd.getMonth(); // 8
|
|
997
|
-
*/
|
|
998
|
-
getMonth() {
|
|
999
|
-
return this.mm;
|
|
1000
|
-
}
|
|
1001
|
-
/**
|
|
1002
|
-
* The Tishrei-based month of this Hebrew date. 1 is Tishrei, 7 is Nisan, 13 is Elul in a leap year
|
|
1003
|
-
* @returns an integer 1-13
|
|
1004
|
-
* @example
|
|
1005
|
-
* const hd = new HDate(new Date(2008, 10, 13)); // 15 Cheshvan 5769
|
|
1006
|
-
* hd.getTishreiMonth(); // 2
|
|
1007
|
-
*/
|
|
1008
|
-
getTishreiMonth() {
|
|
1009
|
-
const nummonths = monthsInYear(this.getFullYear());
|
|
1010
|
-
return (this.getMonth() + nummonths - 6) % nummonths || nummonths;
|
|
1011
|
-
}
|
|
1012
|
-
/**
|
|
1013
|
-
* Number of days in the month of this Hebrew date (29 or 30)
|
|
1014
|
-
* @returns an integer 29-30
|
|
1015
|
-
* @example
|
|
1016
|
-
* const hd = new HDate(new Date(2008, 10, 13)); // 15 Cheshvan 5769
|
|
1017
|
-
* hd.daysInMonth(); // 29
|
|
1018
|
-
*/
|
|
1019
|
-
daysInMonth() {
|
|
1020
|
-
return daysInMonth(this.getMonth(), this.getFullYear());
|
|
1021
|
-
}
|
|
1022
|
-
/**
|
|
1023
|
-
* Gets the day within the month (1-30)
|
|
1024
|
-
* @returns an integer 1-30
|
|
1025
|
-
* @example
|
|
1026
|
-
* const hd = new HDate(new Date(2008, 10, 13)); // 15 Cheshvan 5769
|
|
1027
|
-
* hd.getDate(); // 15
|
|
1028
|
-
*/
|
|
1029
|
-
getDate() {
|
|
1030
|
-
return this.dd;
|
|
1031
|
-
}
|
|
1032
|
-
/**
|
|
1033
|
-
* Returns the day of the week for this Hebrew date,
|
|
1034
|
-
* where 0 represents Sunday, 1 represents Monday, 6 represents Saturday.
|
|
1035
|
-
*
|
|
1036
|
-
* For the day of the month, see `getDate()`
|
|
1037
|
-
* @returns an integer 0-6
|
|
1038
|
-
* @example
|
|
1039
|
-
* const hd = new HDate(new Date(2008, 10, 13)); // 15 Cheshvan 5769
|
|
1040
|
-
* hd.getDate(); // 4
|
|
1041
|
-
*/
|
|
1042
|
-
getDay() {
|
|
1043
|
-
return mod(this.abs(), 7);
|
|
1044
|
-
}
|
|
1045
|
-
/**
|
|
1046
|
-
* Converts this Hebrew date to the corresponding Gregorian date.
|
|
1047
|
-
*
|
|
1048
|
-
* The returned `Date` object will be in the local (i.e. host system) time zone.
|
|
1049
|
-
* Hours, minutes, seconds and milliseconds will all be zero.
|
|
1050
|
-
*
|
|
1051
|
-
* Note that this function returns the daytime portion of the date.
|
|
1052
|
-
* For example, the 15th of Cheshvan 5769 began at sundown on
|
|
1053
|
-
* 12 November 2008 and continues through 13 November 2008. This
|
|
1054
|
-
* function would return only the date 13 November 2008.
|
|
1055
|
-
* @example
|
|
1056
|
-
* const hd = new HDate(15, 'Cheshvan', 5769);
|
|
1057
|
-
* const date = hd.greg(); // 13 November 2008
|
|
1058
|
-
* const year = date.getFullYear(); // 2008
|
|
1059
|
-
* const monthNum = date.getMonth() + 1; // 11
|
|
1060
|
-
* const day = date.getDate(); // 13
|
|
1061
|
-
*/
|
|
1062
|
-
greg() {
|
|
1063
|
-
return abs2greg(this.abs());
|
|
1064
|
-
}
|
|
1065
|
-
/**
|
|
1066
|
-
* Converts from Hebrew date representation to R.D. (Rata Die) fixed days.
|
|
1067
|
-
* R.D. 1 is the imaginary date Monday, January 1, 1 (Gregorian).
|
|
1068
|
-
* Note also that R.D. = Julian Date − 1,721,424.5
|
|
1069
|
-
* @see {@link https://en.wikipedia.org/wiki/Rata_Die | Rata Die}
|
|
1070
|
-
* @example
|
|
1071
|
-
* const hd = new HDate(15, 'Cheshvan', 5769);
|
|
1072
|
-
* hd.abs(); // 733359
|
|
1073
|
-
*/
|
|
1074
|
-
abs() {
|
|
1075
|
-
if (typeof this.rd !== 'number') {
|
|
1076
|
-
this.rd = hebrew2abs(this.yy, this.mm, this.dd);
|
|
1077
|
-
}
|
|
1078
|
-
return this.rd;
|
|
1079
|
-
}
|
|
1080
|
-
/**
|
|
1081
|
-
* Converts Hebrew date to R.D. (Rata Die) fixed days.
|
|
1082
|
-
* R.D. 1 is the imaginary date Monday, January 1, 1 on the Gregorian
|
|
1083
|
-
* Calendar.
|
|
1084
|
-
* @param year Hebrew year
|
|
1085
|
-
* @param month Hebrew month (1=NISAN, 7=TISHREI)
|
|
1086
|
-
* @param day Hebrew date (1-30)
|
|
1087
|
-
* @example
|
|
1088
|
-
* import {HDate, months} from '@hebcal/hdate';
|
|
1089
|
-
* HDate.hebrew2abs(5769, months.CHESHVAN, 15); // 733359
|
|
1090
|
-
*/
|
|
1091
|
-
static hebrew2abs(year, month, day) {
|
|
1092
|
-
return hebrew2abs(year, month, day);
|
|
1093
|
-
}
|
|
1094
|
-
/**
|
|
1095
|
-
* Returns a transliterated Hebrew month name, e.g. `'Elul'` or `'Cheshvan'`.
|
|
1096
|
-
* @example
|
|
1097
|
-
* const hd = new HDate(new Date(2008, 10, 13)); // 15 Cheshvan 5769
|
|
1098
|
-
* hd.getMonthName(); // 'Cheshvan'
|
|
1099
|
-
*/
|
|
1100
|
-
getMonthName() {
|
|
1101
|
-
return getMonthName(this.getMonth(), this.getFullYear());
|
|
1102
|
-
}
|
|
1103
|
-
/**
|
|
1104
|
-
* Renders this Hebrew date as a translated or transliterated string,
|
|
1105
|
-
* including ordinal e.g. `'15th of Cheshvan, 5769'`.
|
|
1106
|
-
* @example
|
|
1107
|
-
* import {HDate, months} from '@hebcal/hdate';
|
|
1108
|
-
*
|
|
1109
|
-
* const hd = new HDate(15, months.CHESHVAN, 5769);
|
|
1110
|
-
* console.log(hd.render('en')); // '15th of Cheshvan, 5769'
|
|
1111
|
-
* console.log(hd.render('he')); // '15 חֶשְׁוָן, 5769'
|
|
1112
|
-
* console.log(hd.render('en', false)); // '15th of Cheshvan'
|
|
1113
|
-
* console.log(hd.render('he', false)); // '15 חֶשְׁוָן'
|
|
1114
|
-
* @param [locale] Optional locale name (defaults to active locale).
|
|
1115
|
-
* @param [showYear=true] Display year (defaults to true).
|
|
1116
|
-
* @see {@link Locale}
|
|
1117
|
-
*/
|
|
1118
|
-
render(locale, showYear = true) {
|
|
1119
|
-
const locale0 = locale || 'en';
|
|
1120
|
-
const day = this.getDate();
|
|
1121
|
-
const monthName0 = Locale.gettext(this.getMonthName(), locale0);
|
|
1122
|
-
const monthName = monthName0.replace(/'/g, '’');
|
|
1123
|
-
const nth = Locale.ordinal(day, locale0);
|
|
1124
|
-
const dayOf = getDayOfTranslation(locale0);
|
|
1125
|
-
const dateStr = `${nth}${dayOf} ${monthName}`;
|
|
1126
|
-
if (showYear) {
|
|
1127
|
-
const fullYear = this.getFullYear();
|
|
1128
|
-
return `${dateStr}, ${fullYear}`;
|
|
1129
|
-
}
|
|
1130
|
-
else {
|
|
1131
|
-
return dateStr;
|
|
1132
|
-
}
|
|
1133
|
-
}
|
|
1134
|
-
/**
|
|
1135
|
-
* Renders this Hebrew date in Hebrew gematriya, regardless of locale.
|
|
1136
|
-
* @param suppressNikud - suppress nekudot (default false)
|
|
1137
|
-
* @param suppressYear - suppress Hebrew year (default false)
|
|
1138
|
-
* @example
|
|
1139
|
-
* import {HDate, months} from '@hebcal/hdate';
|
|
1140
|
-
* const hd = new HDate(15, months.CHESHVAN, 5769);
|
|
1141
|
-
* hd.renderGematriya(); // 'ט״ו חֶשְׁוָן תשס״ט'
|
|
1142
|
-
* hd.renderGematriya(true); // 'ט״ו חשון תשס״ט'
|
|
1143
|
-
* hd.renderGematriya(false, true); // 'ט״ו חֶשְׁוָן'
|
|
1144
|
-
*/
|
|
1145
|
-
renderGematriya(suppressNikud = false, suppressYear = false) {
|
|
1146
|
-
const d = this.getDate();
|
|
1147
|
-
const locale = suppressNikud ? 'he-x-NoNikud' : 'he';
|
|
1148
|
-
const m = Locale.gettext(this.getMonthName(), locale);
|
|
1149
|
-
const prefix = gematriya(d) + ' ' + m;
|
|
1150
|
-
if (suppressYear) {
|
|
1151
|
-
return prefix;
|
|
1152
|
-
}
|
|
1153
|
-
const y = this.getFullYear();
|
|
1154
|
-
return prefix + ' ' + gematriya(y);
|
|
1155
|
-
}
|
|
1156
|
-
/**
|
|
1157
|
-
* Returns an `HDate` corresponding to the specified day of week
|
|
1158
|
-
* **before** this Hebrew date
|
|
1159
|
-
* @example
|
|
1160
|
-
* new HDate(new Date('Wednesday February 19, 2014')).before(6).greg() // Sat Feb 15 2014
|
|
1161
|
-
* @param dayOfWeek day of week: Sunday=0, Saturday=6
|
|
1162
|
-
*/
|
|
1163
|
-
before(dayOfWeek) {
|
|
1164
|
-
return onOrBefore(dayOfWeek, this, -1);
|
|
1165
|
-
}
|
|
1166
|
-
/**
|
|
1167
|
-
* Returns an `HDate` corresponding to the specified day of week
|
|
1168
|
-
* **on or before** this Hebrew date
|
|
1169
|
-
* @example
|
|
1170
|
-
* new HDate(new Date('Wednesday February 19, 2014')).onOrBefore(6).greg() // Sat Feb 15 2014
|
|
1171
|
-
* new HDate(new Date('Saturday February 22, 2014')).onOrBefore(6).greg() // Sat Feb 22 2014
|
|
1172
|
-
* new HDate(new Date('Sunday February 23, 2014')).onOrBefore(6).greg() // Sat Feb 22 2014
|
|
1173
|
-
* @param dayOfWeek day of week: Sunday=0, Saturday=6
|
|
1174
|
-
*/
|
|
1175
|
-
onOrBefore(dayOfWeek) {
|
|
1176
|
-
return onOrBefore(dayOfWeek, this, 0);
|
|
1177
|
-
}
|
|
1178
|
-
/**
|
|
1179
|
-
* Returns an `HDate` corresponding to the specified day of week
|
|
1180
|
-
* **nearest** to this Hebrew date
|
|
1181
|
-
* @example
|
|
1182
|
-
* new HDate(new Date('Wednesday February 19, 2014')).nearest(6).greg() // Sat Feb 22 2014
|
|
1183
|
-
* new HDate(new Date('Tuesday February 18, 2014')).nearest(6).greg() // Sat Feb 15 2014
|
|
1184
|
-
* @param dayOfWeek day of week: Sunday=0, Saturday=6
|
|
1185
|
-
*/
|
|
1186
|
-
nearest(dayOfWeek) {
|
|
1187
|
-
return onOrBefore(dayOfWeek, this, 3);
|
|
1188
|
-
}
|
|
1189
|
-
/**
|
|
1190
|
-
* Returns an `HDate` corresponding to the specified day of week
|
|
1191
|
-
* **on or after** this Hebrew date
|
|
1192
|
-
* @example
|
|
1193
|
-
* new HDate(new Date('Wednesday February 19, 2014')).onOrAfter(6).greg() // Sat Feb 22 2014
|
|
1194
|
-
* new HDate(new Date('Saturday February 22, 2014')).onOrAfter(6).greg() // Sat Feb 22 2014
|
|
1195
|
-
* new HDate(new Date('Sunday February 23, 2014')).onOrAfter(6).greg() // Sat Mar 01 2014
|
|
1196
|
-
* @param dayOfWeek day of week: Sunday=0, Saturday=6
|
|
1197
|
-
*/
|
|
1198
|
-
onOrAfter(dayOfWeek) {
|
|
1199
|
-
return onOrBefore(dayOfWeek, this, 6);
|
|
1200
|
-
}
|
|
1201
|
-
/**
|
|
1202
|
-
* Returns an `HDate` corresponding to the specified day of week
|
|
1203
|
-
* **after** this Hebrew date
|
|
1204
|
-
* @example
|
|
1205
|
-
* new HDate(new Date('Wednesday February 19, 2014')).after(6).greg() // Sat Feb 22 2014
|
|
1206
|
-
* new HDate(new Date('Saturday February 22, 2014')).after(6).greg() // Sat Mar 01 2014
|
|
1207
|
-
* new HDate(new Date('Sunday February 23, 2014')).after(6).greg() // Sat Mar 01 2014
|
|
1208
|
-
* @param dayOfWeek day of week: Sunday=0, Saturday=6
|
|
1209
|
-
*/
|
|
1210
|
-
after(dayOfWeek) {
|
|
1211
|
-
return onOrBefore(dayOfWeek, this, 7);
|
|
1212
|
-
}
|
|
1213
|
-
/**
|
|
1214
|
-
* Returns the next Hebrew date
|
|
1215
|
-
* @example
|
|
1216
|
-
* const hd = new HDate(new Date(2008, 10, 13)); // 15 Cheshvan 5769
|
|
1217
|
-
* hd.next(); // '16 Cheshvan 5769'
|
|
1218
|
-
*/
|
|
1219
|
-
next() {
|
|
1220
|
-
return new HDate(this.abs() + 1);
|
|
1221
|
-
}
|
|
1222
|
-
/**
|
|
1223
|
-
* Returns the previous Hebrew date
|
|
1224
|
-
* @example
|
|
1225
|
-
* const hd = new HDate(new Date(2008, 10, 13)); // 15 Cheshvan 5769
|
|
1226
|
-
* hd.prev(); // '14 Cheshvan 5769'
|
|
1227
|
-
*/
|
|
1228
|
-
prev() {
|
|
1229
|
-
return new HDate(this.abs() - 1);
|
|
1230
|
-
}
|
|
1231
|
-
/**
|
|
1232
|
-
* Returns a cloned `HDate` object with a specified amount of time added
|
|
1233
|
-
*
|
|
1234
|
-
* Units are case insensitive, and support plural and short forms.
|
|
1235
|
-
* Note, short forms are case sensitive.
|
|
1236
|
-
*
|
|
1237
|
-
* | Unit | Shorthand | Description
|
|
1238
|
-
* | --- | --- | --- |
|
|
1239
|
-
* | `day` | `d` | days |
|
|
1240
|
-
* | `week` | `w` | weeks |
|
|
1241
|
-
* | `month` | `M` | months |
|
|
1242
|
-
* | `year` | `y` | years |
|
|
1243
|
-
*/
|
|
1244
|
-
add(amount, units = 'd') {
|
|
1245
|
-
amount =
|
|
1246
|
-
typeof amount === 'string' ? parseInt(amount, 10) : amount;
|
|
1247
|
-
if (!amount) {
|
|
1248
|
-
return new HDate(this);
|
|
1249
|
-
}
|
|
1250
|
-
units = standardizeUnits(units);
|
|
1251
|
-
if (units === UNITS_DAY) {
|
|
1252
|
-
return new HDate(this.abs() + amount);
|
|
1253
|
-
}
|
|
1254
|
-
else if (units === UNITS_WEEK) {
|
|
1255
|
-
return new HDate(this.abs() + 7 * amount);
|
|
1256
|
-
}
|
|
1257
|
-
else if (units === UNITS_YEAR) {
|
|
1258
|
-
return new HDate(this.getDate(), this.getMonth(), this.getFullYear() + amount);
|
|
1259
|
-
}
|
|
1260
|
-
else {
|
|
1261
|
-
// units === UNITS_MONTH
|
|
1262
|
-
let hd = new HDate(this);
|
|
1263
|
-
const sign = amount > 0 ? 1 : -1;
|
|
1264
|
-
amount = Math.abs(amount);
|
|
1265
|
-
for (let i = 0; i < amount; i++) {
|
|
1266
|
-
hd = new HDate(hd.abs() + sign * hd.daysInMonth());
|
|
1267
|
-
}
|
|
1268
|
-
return hd;
|
|
1269
|
-
}
|
|
1270
|
-
}
|
|
1271
|
-
/**
|
|
1272
|
-
* Returns a cloned `HDate` object with a specified amount of time subracted
|
|
1273
|
-
*
|
|
1274
|
-
* Units are case insensitive, and support plural and short forms.
|
|
1275
|
-
* Note, short forms are case sensitive.
|
|
1276
|
-
*
|
|
1277
|
-
* | Unit | Shorthand | Description
|
|
1278
|
-
* | --- | --- | --- |
|
|
1279
|
-
* | `day` | `d` | days |
|
|
1280
|
-
* | `week` | `w` | weeks |
|
|
1281
|
-
* | `month` | `M` | months |
|
|
1282
|
-
* | `year` | `y` | years |
|
|
1283
|
-
* @example
|
|
1284
|
-
* import {HDate, months} from '@hebcal/hdate';
|
|
1285
|
-
*
|
|
1286
|
-
* const hd1 = new HDate(15, months.CHESHVAN, 5769);
|
|
1287
|
-
* const hd2 = hd1.add(1, 'weeks'); // 7 Kislev 5769
|
|
1288
|
-
* const hd3 = hd1.add(-3, 'M'); // 30 Av 5768
|
|
1289
|
-
*/
|
|
1290
|
-
subtract(amount, units = 'd') {
|
|
1291
|
-
return this.add(amount * -1, units);
|
|
1292
|
-
}
|
|
1293
|
-
/**
|
|
1294
|
-
* Returns the difference in days between the two given HDates.
|
|
1295
|
-
*
|
|
1296
|
-
* The result is positive if `this` date is comes chronologically
|
|
1297
|
-
* after the `other` date, and negative
|
|
1298
|
-
* if the order of the two dates is reversed.
|
|
1299
|
-
*
|
|
1300
|
-
* The result is zero if the two dates are identical.
|
|
1301
|
-
* @example
|
|
1302
|
-
* import {HDate, months} from '@hebcal/hdate';
|
|
1303
|
-
*
|
|
1304
|
-
* const hd1 = new HDate(25, months.KISLEV, 5770);
|
|
1305
|
-
* const hd2 = new HDate(15, months.CHESHVAN, 5769);
|
|
1306
|
-
* const days = hd1.deltaDays(hd2); // 394
|
|
1307
|
-
* @param other Hebrew date to compare
|
|
1308
|
-
*/
|
|
1309
|
-
deltaDays(other) {
|
|
1310
|
-
return this.abs() - other.abs();
|
|
1311
|
-
}
|
|
1312
|
-
/**
|
|
1313
|
-
* Compares this Hebrew date to another date, returning `true` if the dates match.
|
|
1314
|
-
* @param other Hebrew date to compare
|
|
1315
|
-
* @example
|
|
1316
|
-
* const hd1 = new HDate(new Date(2008, 10, 13));
|
|
1317
|
-
* const hd2 = new HDate(15, 'Cheshvan', 5769);
|
|
1318
|
-
* hd1.isSameDate(hd2); // true
|
|
1319
|
-
*/
|
|
1320
|
-
isSameDate(other) {
|
|
1321
|
-
return this.yy === other.yy && this.mm === other.mm && this.dd === other.dd;
|
|
1322
|
-
}
|
|
1323
|
-
/**
|
|
1324
|
-
* Returns a string representation of this Hebrew date using English transliterations
|
|
1325
|
-
* @example
|
|
1326
|
-
* const hd = new HDate(new Date(2008, 10, 13)); // 15 Cheshvan 5769
|
|
1327
|
-
* hd.toString(); // '15 Cheshvan 5769'
|
|
1328
|
-
*/
|
|
1329
|
-
toString() {
|
|
1330
|
-
const day = this.getDate();
|
|
1331
|
-
const fullYear = this.getFullYear();
|
|
1332
|
-
const monthName = this.getMonthName();
|
|
1333
|
-
return `${day} ${monthName} ${fullYear}`;
|
|
1334
|
-
}
|
|
1335
|
-
/**
|
|
1336
|
-
* Returns true if Hebrew year is a leap year
|
|
1337
|
-
* @param year Hebrew year
|
|
1338
|
-
* @example
|
|
1339
|
-
* HDate.isLeapYear(5783); // false
|
|
1340
|
-
* HDate.isLeapYear(5784); // true
|
|
1341
|
-
*/
|
|
1342
|
-
static isLeapYear(year) {
|
|
1343
|
-
return isLeapYear(year);
|
|
1344
|
-
}
|
|
1345
|
-
/**
|
|
1346
|
-
* Number of months in this Hebrew year (either 12 or 13 depending on leap year)
|
|
1347
|
-
* @param year Hebrew year
|
|
1348
|
-
* @example
|
|
1349
|
-
* HDate.monthsInYear(5783); // 12
|
|
1350
|
-
* HDate.monthsInYear(5784); // 13
|
|
1351
|
-
*/
|
|
1352
|
-
static monthsInYear(year) {
|
|
1353
|
-
return monthsInYear(year);
|
|
1354
|
-
}
|
|
1355
|
-
/**
|
|
1356
|
-
* Number of days in Hebrew month in a given year (29 or 30)
|
|
1357
|
-
* @param month Hebrew month (e.g. months.TISHREI)
|
|
1358
|
-
* @param year Hebrew year
|
|
1359
|
-
* @example
|
|
1360
|
-
* import {HDate, months} from '@hebcal/hdate';
|
|
1361
|
-
* HDate.daysInMonth(months.CHESHVAN, 5769); // 29
|
|
1362
|
-
*/
|
|
1363
|
-
static daysInMonth(month, year) {
|
|
1364
|
-
return daysInMonth(month, year);
|
|
1365
|
-
}
|
|
1366
|
-
/**
|
|
1367
|
-
* Returns a transliterated string name of Hebrew month in year,
|
|
1368
|
-
* for example 'Elul' or 'Cheshvan'.
|
|
1369
|
-
* @param month Hebrew month (e.g. months.TISHREI)
|
|
1370
|
-
* @param year Hebrew year
|
|
1371
|
-
* @example
|
|
1372
|
-
* import {HDate, months} from '@hebcal/hdate';
|
|
1373
|
-
* HDate.getMonthName(months.CHESHVAN, 5769); // 'Cheshvan'
|
|
1374
|
-
*/
|
|
1375
|
-
static getMonthName(month, year) {
|
|
1376
|
-
return getMonthName(month, year);
|
|
1377
|
-
}
|
|
1378
|
-
/**
|
|
1379
|
-
* Returns the Hebrew month number (NISAN=1, TISHREI=7)
|
|
1380
|
-
* @param month A number, or Hebrew month name string
|
|
1381
|
-
* @example
|
|
1382
|
-
* import {HDate, months} from '@hebcal/hdate';
|
|
1383
|
-
* HDate.monthNum(months.CHESHVAN); // 8
|
|
1384
|
-
* HDate.monthNum('Cheshvan'); // 8
|
|
1385
|
-
* HDate.monthNum('חשון'); // 8
|
|
1386
|
-
*/
|
|
1387
|
-
static monthNum(month) {
|
|
1388
|
-
if (typeof month === 'number') {
|
|
1389
|
-
if (isNaN(month) || month > 14) {
|
|
1390
|
-
throw new RangeError(`bad monthNum: ${month}`);
|
|
1391
|
-
}
|
|
1392
|
-
return month;
|
|
1393
|
-
}
|
|
1394
|
-
return month.charCodeAt(0) >= 48 && month.charCodeAt(0) <= 57 /* number */
|
|
1395
|
-
? parseInt(month, 10)
|
|
1396
|
-
: monthFromName(month);
|
|
1397
|
-
}
|
|
1398
|
-
/**
|
|
1399
|
-
* Number of days in the Hebrew year.
|
|
1400
|
-
* Regular years can have 353, 354, or 355 days.
|
|
1401
|
-
* Leap years can have 383, 384, or 385 days.
|
|
1402
|
-
* @param year Hebrew year
|
|
1403
|
-
* @example
|
|
1404
|
-
* HDate.daysInYear(5783); // 355
|
|
1405
|
-
* HDate.daysInYear(5784); // 383
|
|
1406
|
-
*/
|
|
1407
|
-
static daysInYear(year) {
|
|
1408
|
-
return daysInYear(year);
|
|
1409
|
-
}
|
|
1410
|
-
/**
|
|
1411
|
-
* true if Cheshvan is long in Hebrew year
|
|
1412
|
-
* @param year Hebrew year
|
|
1413
|
-
* @example
|
|
1414
|
-
* HDate.longCheshvan(5783); // true
|
|
1415
|
-
* HDate.longCheshvan(5784); // false
|
|
1416
|
-
*/
|
|
1417
|
-
static longCheshvan(year) {
|
|
1418
|
-
return longCheshvan(year);
|
|
1419
|
-
}
|
|
1420
|
-
/**
|
|
1421
|
-
* true if Kislev is short in Hebrew year
|
|
1422
|
-
* @param year Hebrew year
|
|
1423
|
-
* @example
|
|
1424
|
-
* HDate.shortKislev(5783); // false
|
|
1425
|
-
* HDate.shortKislev(5784); // true
|
|
1426
|
-
*/
|
|
1427
|
-
static shortKislev(year) {
|
|
1428
|
-
return shortKislev(year);
|
|
1429
|
-
}
|
|
1430
|
-
/**
|
|
1431
|
-
* Converts Hebrew month string name to numeric
|
|
1432
|
-
* @example
|
|
1433
|
-
* import {HDate, months} from '@hebcal/hdate';
|
|
1434
|
-
* HDate.monthFromName(months.CHESHVAN); // 8
|
|
1435
|
-
* HDate.monthFromName('Cheshvan'); // 8
|
|
1436
|
-
* HDate.monthFromName('חשון'); // 8
|
|
1437
|
-
*/
|
|
1438
|
-
static monthFromName(monthName) {
|
|
1439
|
-
return monthFromName(monthName);
|
|
1440
|
-
}
|
|
1441
|
-
/**
|
|
1442
|
-
* Convenience function for determining the R.D. date
|
|
1443
|
-
* near a specified R.D. date, corresponding to the specified day of week.
|
|
1444
|
-
*
|
|
1445
|
-
* Note: Applying this function to d+6 gives us the `dayOfWeek` on or after an
|
|
1446
|
-
* absolute day d. Similarly, applying it to d+3 gives the `dayOfWeek` nearest to
|
|
1447
|
-
* absolute date d, applying it to d-1 gives the `dayOfWeek` previous to absolute
|
|
1448
|
-
* date d, and applying it to d+7 gives the `dayOfWeek` following absolute date d.
|
|
1449
|
-
* @param dayOfWeek day of week: Sunday=0, Saturday=6
|
|
1450
|
-
*/
|
|
1451
|
-
static dayOnOrBefore(dayOfWeek, absdate) {
|
|
1452
|
-
return absdate - ((absdate - dayOfWeek) % 7);
|
|
1453
|
-
}
|
|
1454
|
-
/**
|
|
1455
|
-
* Tests if the object is an instance of `HDate`
|
|
1456
|
-
* @example
|
|
1457
|
-
* HDate.isHDate(new HDate()); // true
|
|
1458
|
-
* HDate.isHDate(new Date()); // false
|
|
1459
|
-
* HDate.isHDate(null); // false
|
|
1460
|
-
* HDate.isHDate(12345); // false
|
|
1461
|
-
* HDate.isHDate('15 Cheshvan 5769'); // false
|
|
1462
|
-
*/
|
|
1463
|
-
static isHDate(obj) {
|
|
1464
|
-
return (obj !== null &&
|
|
1465
|
-
typeof obj === 'object' &&
|
|
1466
|
-
typeof obj.yy === 'number' &&
|
|
1467
|
-
typeof obj.mm === 'number' &&
|
|
1468
|
-
typeof obj.dd === 'number' &&
|
|
1469
|
-
typeof obj.greg === 'function' &&
|
|
1470
|
-
typeof obj.abs === 'function');
|
|
1471
|
-
}
|
|
1472
|
-
/**
|
|
1473
|
-
* Construct a new instance of `HDate` from a Gematriya-formatted string
|
|
1474
|
-
* @example
|
|
1475
|
-
* HDate.fromGematriyaString('כ״ז בְּתַמּוּז תשפ״ג') // 27 Tamuz 5783
|
|
1476
|
-
* HDate.fromGematriyaString('כ׳ סיון תש״ד') // 20 Sivan 5704
|
|
1477
|
-
* HDate.fromGematriyaString('ה׳ אִיָיר תש״ח') // 5 Iyyar 5708
|
|
1478
|
-
*/
|
|
1479
|
-
static fromGematriyaString(str, currentThousands = 5000) {
|
|
1480
|
-
const parts = str.split(' ').filter(x => x.length !== 0);
|
|
1481
|
-
const numParts = parts.length;
|
|
1482
|
-
if (numParts !== 3 && numParts !== 4) {
|
|
1483
|
-
throw new RangeError(`cannot parse gematriya str: "${str}"`);
|
|
1484
|
-
}
|
|
1485
|
-
const day = gematriyaStrToNum(parts[0]);
|
|
1486
|
-
const monthStr = numParts === 3 ? parts[1] : parts[1] + ' ' + parts[2];
|
|
1487
|
-
const month = monthFromName(monthStr);
|
|
1488
|
-
const yearStr = numParts === 3 ? parts[2] : parts[3];
|
|
1489
|
-
let year = gematriyaStrToNum(yearStr);
|
|
1490
|
-
if (year < 1000) {
|
|
1491
|
-
year += currentThousands;
|
|
1492
|
-
}
|
|
1493
|
-
return new HDate(day, month, year);
|
|
1494
|
-
}
|
|
1495
|
-
}
|
|
1496
|
-
function standardizeUnits(units) {
|
|
1497
|
-
switch (units) {
|
|
1498
|
-
case 'd':
|
|
1499
|
-
return UNITS_DAY;
|
|
1500
|
-
case 'w':
|
|
1501
|
-
return UNITS_WEEK;
|
|
1502
|
-
case 'M':
|
|
1503
|
-
return UNITS_MONTH;
|
|
1504
|
-
case 'y':
|
|
1505
|
-
return UNITS_YEAR;
|
|
1506
|
-
}
|
|
1507
|
-
const str = String(units || '')
|
|
1508
|
-
.toLowerCase()
|
|
1509
|
-
.replace(/s$/, '');
|
|
1510
|
-
switch (str) {
|
|
1511
|
-
case UNITS_DAY:
|
|
1512
|
-
case UNITS_WEEK:
|
|
1513
|
-
case UNITS_MONTH:
|
|
1514
|
-
case UNITS_YEAR:
|
|
1515
|
-
return str;
|
|
1516
|
-
}
|
|
1517
|
-
throw new TypeError(`Invalid units '${units}'`);
|
|
1518
|
-
}
|
|
1519
|
-
function getDayOfTranslation(locale) {
|
|
1520
|
-
switch (locale) {
|
|
1521
|
-
case 'en':
|
|
1522
|
-
case 's':
|
|
1523
|
-
case 'a':
|
|
1524
|
-
case 'ashkenazi':
|
|
1525
|
-
return ' of';
|
|
1526
|
-
}
|
|
1527
|
-
const ofStr = Locale.lookupTranslation('of', locale);
|
|
1528
|
-
if (ofStr) {
|
|
1529
|
-
return ' ' + ofStr;
|
|
1530
|
-
}
|
|
1531
|
-
if (locale.startsWith('ashkenazi')) {
|
|
1532
|
-
return ' of';
|
|
1533
|
-
}
|
|
1534
|
-
return '';
|
|
1535
|
-
}
|
|
1536
|
-
/**
|
|
1537
|
-
* Sets the day of the month of the date. Returns the object it was called upon
|
|
1538
|
-
* @private
|
|
1539
|
-
* @param month A number, or Hebrew month name string
|
|
1540
|
-
*/
|
|
1541
|
-
function setMonth(hd, month) {
|
|
1542
|
-
hd.mm = HDate.monthNum(month);
|
|
1543
|
-
fix(hd);
|
|
1544
|
-
return hd;
|
|
1545
|
-
}
|
|
1546
|
-
function setDate(hd, date) {
|
|
1547
|
-
hd.dd = date;
|
|
1548
|
-
fix(hd);
|
|
1549
|
-
return hd;
|
|
1550
|
-
}
|
|
1551
|
-
function fix(hd) {
|
|
1552
|
-
fixMonth(hd);
|
|
1553
|
-
fixDate(hd);
|
|
1554
|
-
}
|
|
1555
|
-
function fixDate(hd) {
|
|
1556
|
-
if (hd.dd < 1) {
|
|
1557
|
-
if (hd.mm === months.TISHREI) {
|
|
1558
|
-
hd.yy -= 1;
|
|
1559
|
-
}
|
|
1560
|
-
hd.dd += daysInMonth(hd.mm, hd.yy);
|
|
1561
|
-
hd.mm -= 1;
|
|
1562
|
-
fix(hd);
|
|
1563
|
-
}
|
|
1564
|
-
if (hd.dd > daysInMonth(hd.mm, hd.yy)) {
|
|
1565
|
-
if (hd.mm === months.ELUL) {
|
|
1566
|
-
hd.yy += 1;
|
|
1567
|
-
}
|
|
1568
|
-
hd.dd -= daysInMonth(hd.mm, hd.yy);
|
|
1569
|
-
if (hd.mm === monthsInYear(hd.yy)) {
|
|
1570
|
-
hd.mm = 1; // rollover to NISAN
|
|
1571
|
-
}
|
|
1572
|
-
else {
|
|
1573
|
-
hd.mm += 1;
|
|
1574
|
-
}
|
|
1575
|
-
fix(hd);
|
|
1576
|
-
}
|
|
1577
|
-
fixMonth(hd);
|
|
1578
|
-
}
|
|
1579
|
-
function fixMonth(hd) {
|
|
1580
|
-
if (hd.mm === months.ADAR_II && !hd.isLeapYear()) {
|
|
1581
|
-
hd.mm -= 1; // to Adar I
|
|
1582
|
-
fix(hd);
|
|
1583
|
-
}
|
|
1584
|
-
else if (hd.mm < 1) {
|
|
1585
|
-
hd.mm += monthsInYear(hd.yy);
|
|
1586
|
-
hd.yy -= 1;
|
|
1587
|
-
fix(hd);
|
|
1588
|
-
}
|
|
1589
|
-
else if (hd.mm > monthsInYear(hd.yy)) {
|
|
1590
|
-
hd.mm -= monthsInYear(hd.yy);
|
|
1591
|
-
hd.yy += 1;
|
|
1592
|
-
fix(hd);
|
|
1593
|
-
}
|
|
1594
|
-
delete hd.rd;
|
|
1595
|
-
}
|
|
1596
|
-
function onOrBefore(day, t, offset) {
|
|
1597
|
-
return new HDate(HDate.dayOnOrBefore(day, t.abs() + offset));
|
|
1598
|
-
}
|
|
1599
|
-
class QuickLRU extends Map {
|
|
1600
|
-
constructor(options = {}) {
|
|
1601
|
-
super();
|
|
1602
|
-
_QuickLRU_instances.add(this);
|
|
1603
|
-
_QuickLRU_size.set(this, 0);
|
|
1604
|
-
_QuickLRU_cache.set(this, new Map());
|
|
1605
|
-
_QuickLRU_oldCache.set(this, new Map());
|
|
1606
|
-
_QuickLRU_maxSize.set(this, void 0);
|
|
1607
|
-
_QuickLRU_maxAge.set(this, void 0);
|
|
1608
|
-
_QuickLRU_onEviction.set(this, void 0);
|
|
1609
|
-
if (!(options.maxSize && options.maxSize > 0)) {
|
|
1610
|
-
throw new TypeError('`maxSize` must be a number greater than 0');
|
|
1611
|
-
}
|
|
1612
|
-
if (typeof options.maxAge === 'number' && options.maxAge === 0) {
|
|
1613
|
-
throw new TypeError('`maxAge` must be a number greater than 0');
|
|
1614
|
-
}
|
|
1615
|
-
__classPrivateFieldSet(this, _QuickLRU_maxSize, options.maxSize, "f");
|
|
1616
|
-
__classPrivateFieldSet(this, _QuickLRU_maxAge, options.maxAge || Number.POSITIVE_INFINITY, "f");
|
|
1617
|
-
__classPrivateFieldSet(this, _QuickLRU_onEviction, options.onEviction, "f");
|
|
1618
|
-
}
|
|
1619
|
-
// For tests.
|
|
1620
|
-
get __oldCache() {
|
|
1621
|
-
return __classPrivateFieldGet(this, _QuickLRU_oldCache, "f");
|
|
1622
|
-
}
|
|
1623
|
-
get(key) {
|
|
1624
|
-
if (__classPrivateFieldGet(this, _QuickLRU_cache, "f").has(key)) {
|
|
1625
|
-
const item = __classPrivateFieldGet(this, _QuickLRU_cache, "f").get(key);
|
|
1626
|
-
return __classPrivateFieldGet(this, _QuickLRU_instances, "m", _QuickLRU_getItemValue).call(this, key, item);
|
|
1627
|
-
}
|
|
1628
|
-
if (__classPrivateFieldGet(this, _QuickLRU_oldCache, "f").has(key)) {
|
|
1629
|
-
const item = __classPrivateFieldGet(this, _QuickLRU_oldCache, "f").get(key);
|
|
1630
|
-
if (__classPrivateFieldGet(this, _QuickLRU_instances, "m", _QuickLRU_deleteIfExpired).call(this, key, item) === false) {
|
|
1631
|
-
__classPrivateFieldGet(this, _QuickLRU_instances, "m", _QuickLRU_moveToRecent).call(this, key, item);
|
|
1632
|
-
return item.value;
|
|
1633
|
-
}
|
|
1634
|
-
}
|
|
1635
|
-
}
|
|
1636
|
-
set(key, value, { maxAge = __classPrivateFieldGet(this, _QuickLRU_maxAge, "f") } = {}) {
|
|
1637
|
-
const expiry = typeof maxAge === 'number' && maxAge !== Number.POSITIVE_INFINITY
|
|
1638
|
-
? (Date.now() + maxAge)
|
|
1639
|
-
: undefined;
|
|
1640
|
-
if (__classPrivateFieldGet(this, _QuickLRU_cache, "f").has(key)) {
|
|
1641
|
-
__classPrivateFieldGet(this, _QuickLRU_cache, "f").set(key, {
|
|
1642
|
-
value,
|
|
1643
|
-
expiry,
|
|
1644
|
-
});
|
|
1645
|
-
}
|
|
1646
|
-
else {
|
|
1647
|
-
__classPrivateFieldGet(this, _QuickLRU_instances, "m", _QuickLRU_set).call(this, key, { value, expiry });
|
|
1648
|
-
}
|
|
1649
|
-
return this;
|
|
1650
|
-
}
|
|
1651
|
-
has(key) {
|
|
1652
|
-
if (__classPrivateFieldGet(this, _QuickLRU_cache, "f").has(key)) {
|
|
1653
|
-
return !__classPrivateFieldGet(this, _QuickLRU_instances, "m", _QuickLRU_deleteIfExpired).call(this, key, __classPrivateFieldGet(this, _QuickLRU_cache, "f").get(key));
|
|
1654
|
-
}
|
|
1655
|
-
if (__classPrivateFieldGet(this, _QuickLRU_oldCache, "f").has(key)) {
|
|
1656
|
-
return !__classPrivateFieldGet(this, _QuickLRU_instances, "m", _QuickLRU_deleteIfExpired).call(this, key, __classPrivateFieldGet(this, _QuickLRU_oldCache, "f").get(key));
|
|
1657
|
-
}
|
|
1658
|
-
return false;
|
|
1659
|
-
}
|
|
1660
|
-
peek(key) {
|
|
1661
|
-
if (__classPrivateFieldGet(this, _QuickLRU_cache, "f").has(key)) {
|
|
1662
|
-
return __classPrivateFieldGet(this, _QuickLRU_instances, "m", _QuickLRU_peek).call(this, key, __classPrivateFieldGet(this, _QuickLRU_cache, "f"));
|
|
1663
|
-
}
|
|
1664
|
-
if (__classPrivateFieldGet(this, _QuickLRU_oldCache, "f").has(key)) {
|
|
1665
|
-
return __classPrivateFieldGet(this, _QuickLRU_instances, "m", _QuickLRU_peek).call(this, key, __classPrivateFieldGet(this, _QuickLRU_oldCache, "f"));
|
|
1666
|
-
}
|
|
1667
|
-
}
|
|
1668
|
-
expiresIn(key) {
|
|
1669
|
-
var _a;
|
|
1670
|
-
const item = (_a = __classPrivateFieldGet(this, _QuickLRU_cache, "f").get(key)) !== null && _a !== void 0 ? _a : __classPrivateFieldGet(this, _QuickLRU_oldCache, "f").get(key);
|
|
1671
|
-
if (item) {
|
|
1672
|
-
return item.expiry ? item.expiry - Date.now() : Number.POSITIVE_INFINITY;
|
|
1673
|
-
}
|
|
1674
|
-
}
|
|
1675
|
-
delete(key) {
|
|
1676
|
-
var _a;
|
|
1677
|
-
const deleted = __classPrivateFieldGet(this, _QuickLRU_cache, "f").delete(key);
|
|
1678
|
-
if (deleted) {
|
|
1679
|
-
__classPrivateFieldSet(this, _QuickLRU_size, (_a = __classPrivateFieldGet(this, _QuickLRU_size, "f"), _a--, _a), "f");
|
|
1680
|
-
}
|
|
1681
|
-
return __classPrivateFieldGet(this, _QuickLRU_oldCache, "f").delete(key) || deleted;
|
|
1682
|
-
}
|
|
1683
|
-
clear() {
|
|
1684
|
-
__classPrivateFieldGet(this, _QuickLRU_cache, "f").clear();
|
|
1685
|
-
__classPrivateFieldGet(this, _QuickLRU_oldCache, "f").clear();
|
|
1686
|
-
__classPrivateFieldSet(this, _QuickLRU_size, 0, "f");
|
|
1687
|
-
}
|
|
1688
|
-
resize(newSize) {
|
|
1689
|
-
if (!(newSize && newSize > 0)) {
|
|
1690
|
-
throw new TypeError('`maxSize` must be a number greater than 0');
|
|
1691
|
-
}
|
|
1692
|
-
const items = [...__classPrivateFieldGet(this, _QuickLRU_instances, "m", _QuickLRU_entriesAscending).call(this)];
|
|
1693
|
-
const removeCount = items.length - newSize;
|
|
1694
|
-
if (removeCount < 0) {
|
|
1695
|
-
__classPrivateFieldSet(this, _QuickLRU_cache, new Map(items), "f");
|
|
1696
|
-
__classPrivateFieldSet(this, _QuickLRU_oldCache, new Map(), "f");
|
|
1697
|
-
__classPrivateFieldSet(this, _QuickLRU_size, items.length, "f");
|
|
1698
|
-
}
|
|
1699
|
-
else {
|
|
1700
|
-
if (removeCount > 0) {
|
|
1701
|
-
__classPrivateFieldGet(this, _QuickLRU_instances, "m", _QuickLRU_emitEvictions).call(this, items.slice(0, removeCount));
|
|
1702
|
-
}
|
|
1703
|
-
__classPrivateFieldSet(this, _QuickLRU_oldCache, new Map(items.slice(removeCount)), "f");
|
|
1704
|
-
__classPrivateFieldSet(this, _QuickLRU_cache, new Map(), "f");
|
|
1705
|
-
__classPrivateFieldSet(this, _QuickLRU_size, 0, "f");
|
|
1706
|
-
}
|
|
1707
|
-
__classPrivateFieldSet(this, _QuickLRU_maxSize, newSize, "f");
|
|
1708
|
-
}
|
|
1709
|
-
evict(count = 1) {
|
|
1710
|
-
const requested = Number(count);
|
|
1711
|
-
if (!requested || requested <= 0) {
|
|
1712
|
-
return;
|
|
1713
|
-
}
|
|
1714
|
-
const items = [...__classPrivateFieldGet(this, _QuickLRU_instances, "m", _QuickLRU_entriesAscending).call(this)];
|
|
1715
|
-
const evictCount = Math.trunc(Math.min(requested, Math.max(items.length - 1, 0)));
|
|
1716
|
-
if (evictCount <= 0) {
|
|
1717
|
-
return;
|
|
1718
|
-
}
|
|
1719
|
-
__classPrivateFieldGet(this, _QuickLRU_instances, "m", _QuickLRU_emitEvictions).call(this, items.slice(0, evictCount));
|
|
1720
|
-
__classPrivateFieldSet(this, _QuickLRU_oldCache, new Map(items.slice(evictCount)), "f");
|
|
1721
|
-
__classPrivateFieldSet(this, _QuickLRU_cache, new Map(), "f");
|
|
1722
|
-
__classPrivateFieldSet(this, _QuickLRU_size, 0, "f");
|
|
1723
|
-
}
|
|
1724
|
-
*keys() {
|
|
1725
|
-
for (const [key] of this) {
|
|
1726
|
-
yield key;
|
|
1727
|
-
}
|
|
1728
|
-
}
|
|
1729
|
-
*values() {
|
|
1730
|
-
for (const [, value] of this) {
|
|
1731
|
-
yield value;
|
|
1732
|
-
}
|
|
1733
|
-
}
|
|
1734
|
-
*[(_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) {
|
|
1735
|
-
if (typeof __classPrivateFieldGet(this, _QuickLRU_onEviction, "f") !== 'function') {
|
|
1736
|
-
return;
|
|
1737
|
-
}
|
|
1738
|
-
for (const [key, item] of cache) {
|
|
1739
|
-
__classPrivateFieldGet(this, _QuickLRU_onEviction, "f").call(this, key, item.value);
|
|
1740
|
-
}
|
|
1741
|
-
}, _QuickLRU_deleteIfExpired = function _QuickLRU_deleteIfExpired(key, item) {
|
|
1742
|
-
if (typeof item.expiry === 'number' && item.expiry <= Date.now()) {
|
|
1743
|
-
if (typeof __classPrivateFieldGet(this, _QuickLRU_onEviction, "f") === 'function') {
|
|
1744
|
-
__classPrivateFieldGet(this, _QuickLRU_onEviction, "f").call(this, key, item.value);
|
|
1745
|
-
}
|
|
1746
|
-
return this.delete(key);
|
|
1747
|
-
}
|
|
1748
|
-
return false;
|
|
1749
|
-
}, _QuickLRU_getOrDeleteIfExpired = function _QuickLRU_getOrDeleteIfExpired(key, item) {
|
|
1750
|
-
const deleted = __classPrivateFieldGet(this, _QuickLRU_instances, "m", _QuickLRU_deleteIfExpired).call(this, key, item);
|
|
1751
|
-
if (deleted === false) {
|
|
1752
|
-
return item.value;
|
|
1753
|
-
}
|
|
1754
|
-
}, _QuickLRU_getItemValue = function _QuickLRU_getItemValue(key, item) {
|
|
1755
|
-
return item.expiry ? __classPrivateFieldGet(this, _QuickLRU_instances, "m", _QuickLRU_getOrDeleteIfExpired).call(this, key, item) : item.value;
|
|
1756
|
-
}, _QuickLRU_peek = function _QuickLRU_peek(key, cache) {
|
|
1757
|
-
const item = cache.get(key);
|
|
1758
|
-
return __classPrivateFieldGet(this, _QuickLRU_instances, "m", _QuickLRU_getItemValue).call(this, key, item);
|
|
1759
|
-
}, _QuickLRU_set = function _QuickLRU_set(key, value) {
|
|
1760
|
-
var _a;
|
|
1761
|
-
__classPrivateFieldGet(this, _QuickLRU_cache, "f").set(key, value);
|
|
1762
|
-
__classPrivateFieldSet(this, _QuickLRU_size, (_a = __classPrivateFieldGet(this, _QuickLRU_size, "f"), _a++, _a), "f");
|
|
1763
|
-
if (__classPrivateFieldGet(this, _QuickLRU_size, "f") >= __classPrivateFieldGet(this, _QuickLRU_maxSize, "f")) {
|
|
1764
|
-
__classPrivateFieldSet(this, _QuickLRU_size, 0, "f");
|
|
1765
|
-
__classPrivateFieldGet(this, _QuickLRU_instances, "m", _QuickLRU_emitEvictions).call(this, __classPrivateFieldGet(this, _QuickLRU_oldCache, "f"));
|
|
1766
|
-
__classPrivateFieldSet(this, _QuickLRU_oldCache, __classPrivateFieldGet(this, _QuickLRU_cache, "f"), "f");
|
|
1767
|
-
__classPrivateFieldSet(this, _QuickLRU_cache, new Map(), "f");
|
|
1768
|
-
}
|
|
1769
|
-
}, _QuickLRU_moveToRecent = function _QuickLRU_moveToRecent(key, item) {
|
|
1770
|
-
__classPrivateFieldGet(this, _QuickLRU_oldCache, "f").delete(key);
|
|
1771
|
-
__classPrivateFieldGet(this, _QuickLRU_instances, "m", _QuickLRU_set).call(this, key, item);
|
|
1772
|
-
}, _QuickLRU_entriesAscending = function* _QuickLRU_entriesAscending() {
|
|
1773
|
-
for (const item of __classPrivateFieldGet(this, _QuickLRU_oldCache, "f")) {
|
|
1774
|
-
const [key, value] = item;
|
|
1775
|
-
if (!__classPrivateFieldGet(this, _QuickLRU_cache, "f").has(key)) {
|
|
1776
|
-
const deleted = __classPrivateFieldGet(this, _QuickLRU_instances, "m", _QuickLRU_deleteIfExpired).call(this, key, value);
|
|
1777
|
-
if (deleted === false) {
|
|
1778
|
-
yield item;
|
|
1779
|
-
}
|
|
1780
|
-
}
|
|
1781
|
-
}
|
|
1782
|
-
for (const item of __classPrivateFieldGet(this, _QuickLRU_cache, "f")) {
|
|
1783
|
-
const [key, value] = item;
|
|
1784
|
-
const deleted = __classPrivateFieldGet(this, _QuickLRU_instances, "m", _QuickLRU_deleteIfExpired).call(this, key, value);
|
|
1785
|
-
if (deleted === false) {
|
|
1786
|
-
yield item;
|
|
1787
|
-
}
|
|
1788
|
-
}
|
|
1789
|
-
}, Symbol.iterator)]() {
|
|
1790
|
-
for (const item of __classPrivateFieldGet(this, _QuickLRU_cache, "f")) {
|
|
1791
|
-
const [key, value] = item;
|
|
1792
|
-
const deleted = __classPrivateFieldGet(this, _QuickLRU_instances, "m", _QuickLRU_deleteIfExpired).call(this, key, value);
|
|
1793
|
-
if (deleted === false) {
|
|
1794
|
-
yield [key, value.value];
|
|
1795
|
-
}
|
|
1796
|
-
}
|
|
1797
|
-
for (const item of __classPrivateFieldGet(this, _QuickLRU_oldCache, "f")) {
|
|
1798
|
-
const [key, value] = item;
|
|
1799
|
-
if (!__classPrivateFieldGet(this, _QuickLRU_cache, "f").has(key)) {
|
|
1800
|
-
const deleted = __classPrivateFieldGet(this, _QuickLRU_instances, "m", _QuickLRU_deleteIfExpired).call(this, key, value);
|
|
1801
|
-
if (deleted === false) {
|
|
1802
|
-
yield [key, value.value];
|
|
1803
|
-
}
|
|
1804
|
-
}
|
|
1805
|
-
}
|
|
1806
|
-
}
|
|
1807
|
-
*entriesDescending() {
|
|
1808
|
-
let items = [...__classPrivateFieldGet(this, _QuickLRU_cache, "f")];
|
|
1809
|
-
for (let i = items.length - 1; i >= 0; --i) {
|
|
1810
|
-
const item = items[i];
|
|
1811
|
-
const [key, value] = item;
|
|
1812
|
-
const deleted = __classPrivateFieldGet(this, _QuickLRU_instances, "m", _QuickLRU_deleteIfExpired).call(this, key, value);
|
|
1813
|
-
if (deleted === false) {
|
|
1814
|
-
yield [key, value.value];
|
|
1815
|
-
}
|
|
1816
|
-
}
|
|
1817
|
-
items = [...__classPrivateFieldGet(this, _QuickLRU_oldCache, "f")];
|
|
1818
|
-
for (let i = items.length - 1; i >= 0; --i) {
|
|
1819
|
-
const item = items[i];
|
|
1820
|
-
const [key, value] = item;
|
|
1821
|
-
if (!__classPrivateFieldGet(this, _QuickLRU_cache, "f").has(key)) {
|
|
1822
|
-
const deleted = __classPrivateFieldGet(this, _QuickLRU_instances, "m", _QuickLRU_deleteIfExpired).call(this, key, value);
|
|
1823
|
-
if (deleted === false) {
|
|
1824
|
-
yield [key, value.value];
|
|
1825
|
-
}
|
|
1826
|
-
}
|
|
1827
|
-
}
|
|
1828
|
-
}
|
|
1829
|
-
*entriesAscending() {
|
|
1830
|
-
for (const [key, value] of __classPrivateFieldGet(this, _QuickLRU_instances, "m", _QuickLRU_entriesAscending).call(this)) {
|
|
1831
|
-
yield [key, value.value];
|
|
1832
|
-
}
|
|
1833
|
-
}
|
|
1834
|
-
get size() {
|
|
1835
|
-
if (!__classPrivateFieldGet(this, _QuickLRU_size, "f")) {
|
|
1836
|
-
return __classPrivateFieldGet(this, _QuickLRU_oldCache, "f").size;
|
|
1837
|
-
}
|
|
1838
|
-
let oldCacheSize = 0;
|
|
1839
|
-
for (const key of __classPrivateFieldGet(this, _QuickLRU_oldCache, "f").keys()) {
|
|
1840
|
-
if (!__classPrivateFieldGet(this, _QuickLRU_cache, "f").has(key)) {
|
|
1841
|
-
oldCacheSize++;
|
|
1842
|
-
}
|
|
1843
|
-
}
|
|
1844
|
-
return Math.min(__classPrivateFieldGet(this, _QuickLRU_size, "f") + oldCacheSize, __classPrivateFieldGet(this, _QuickLRU_maxSize, "f"));
|
|
1845
|
-
}
|
|
1846
|
-
get maxSize() {
|
|
1847
|
-
return __classPrivateFieldGet(this, _QuickLRU_maxSize, "f");
|
|
1848
|
-
}
|
|
1849
|
-
get maxAge() {
|
|
1850
|
-
return __classPrivateFieldGet(this, _QuickLRU_maxAge, "f");
|
|
1851
|
-
}
|
|
1852
|
-
entries() {
|
|
1853
|
-
return this.entriesAscending();
|
|
1854
|
-
}
|
|
1855
|
-
forEach(callbackFunction, thisArgument = this) {
|
|
1856
|
-
for (const [key, value] of this.entriesAscending()) {
|
|
1857
|
-
callbackFunction.call(thisArgument, value, key, this);
|
|
1858
|
-
}
|
|
1859
|
-
}
|
|
1860
|
-
get [Symbol.toStringTag]() {
|
|
1861
|
-
return 'QuickLRU';
|
|
1862
|
-
}
|
|
1863
|
-
toString() {
|
|
1864
|
-
return `QuickLRU(${this.size}/${this.maxSize})`;
|
|
1865
|
-
}
|
|
1866
|
-
[Symbol.for('nodejs.util.inspect.custom')]() {
|
|
1867
|
-
return this.toString();
|
|
1868
|
-
}
|
|
1869
|
-
}
|
|
1870
|
-
/*! @hebcal/core v6.0.7, distributed under GPLv2 https://www.gnu.org/licenses/gpl-2.0.txt */
|
|
1871
|
-
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"] } } };
|
|
1872
|
-
/*! @hebcal/core v6.0.7, distributed under GPLv2 https://www.gnu.org/licenses/gpl-2.0.txt */
|
|
1873
|
-
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": ["חֲלָקִים"] } } };
|
|
1874
|
-
/*! @hebcal/core v6.0.7, distributed under GPLv2 https://www.gnu.org/licenses/gpl-2.0.txt */
|
|
1875
|
-
var noNikudOverride = { "headers": { "plural-forms": "nplurals=2; plural=(n != 1);", "language": "he-x-NoNikud" }, "contexts": { "": { "Korach": ["קורח"], "Chukat": ["חוקת"], "Yom Kippur": ["יום כיפור"], "Yom Kippur Katan": ["יום כיפור קטן"] } } };
|
|
1876
|
-
/*! @hebcal/core v6.0.7, distributed under GPLv2 https://www.gnu.org/licenses/gpl-2.0.txt */
|
|
1877
|
-
Locale.addTranslations('he', poHe);
|
|
1878
|
-
Locale.addTranslations('ashkenazi', poAshkenazi);
|
|
1879
|
-
/* Hebrew without nikkud */
|
|
1880
|
-
const poHeNoNikud = Locale.copyLocaleNoNikud(poHe);
|
|
1881
|
-
Locale.addTranslations('he-x-NoNikud', poHeNoNikud);
|
|
1882
|
-
Locale.addTranslations('he-x-NoNikud', noNikudOverride);
|
|
1883
|
-
/*! @hebcal/core v6.0.7, distributed under GPLv2 https://www.gnu.org/licenses/gpl-2.0.txt */
|
|
1884
|
-
/*
|
|
1885
|
-
Hebcal - A Jewish Calendar Generator
|
|
1886
|
-
Copyright (c) 1994-2020 Danny Sadinoff
|
|
1887
|
-
Portions copyright Eyal Schachter and Michael J. Radwin
|
|
1888
|
-
|
|
1889
|
-
https://github.com/hebcal/hebcal-es6
|
|
1890
|
-
|
|
1891
|
-
This program is free software; you can redistribute it and/or
|
|
1892
|
-
modify it under the terms of the GNU General Public License
|
|
1893
|
-
as published by the Free Software Foundation; either version 2
|
|
1894
|
-
of the License, or (at your option) any later version.
|
|
1895
|
-
|
|
1896
|
-
This program is distributed in the hope that it will be useful,
|
|
1897
|
-
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
1898
|
-
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
1899
|
-
GNU General Public License for more details.
|
|
1900
|
-
|
|
1901
|
-
You should have received a copy of the GNU General Public License
|
|
1902
|
-
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
1903
|
-
*/
|
|
1904
|
-
/*
|
|
1905
|
-
* Many of the following algorithms were taken from hebrew calendar
|
|
1906
|
-
* routines by Maimonedes, from his Mishneh Torah, and implemented by
|
|
1907
|
-
* Nachum Dershowitz Department of Computer Science
|
|
1908
|
-
* (217) 333-4219 University of Illinois at Urbana-Champaign
|
|
1909
|
-
* nachum@cs.uiuedu 1304 West Springfield Avenue
|
|
1910
|
-
* Urbana, Illinois 61801
|
|
1911
|
-
*
|
|
1912
|
-
* The routines were included in the emacs 19 distribution.
|
|
1913
|
-
*
|
|
1914
|
-
*/
|
|
1915
|
-
const INCOMPLETE = 0;
|
|
1916
|
-
const REGULAR = 1;
|
|
1917
|
-
const COMPLETE = 2;
|
|
1918
|
-
function yearType(hyear) {
|
|
1919
|
-
const longC = HDate.longCheshvan(hyear);
|
|
1920
|
-
const shortK = HDate.shortKislev(hyear);
|
|
1921
|
-
if (longC && !shortK) {
|
|
1922
|
-
return COMPLETE;
|
|
1923
|
-
}
|
|
1924
|
-
else if (!longC && shortK) {
|
|
1925
|
-
return INCOMPLETE;
|
|
1926
|
-
}
|
|
1927
|
-
else {
|
|
1928
|
-
return REGULAR;
|
|
1929
|
-
}
|
|
1930
|
-
}
|
|
1931
|
-
/**
|
|
1932
|
-
* Represents Parashah HaShavua for an entire Hebrew year
|
|
1933
|
-
*/
|
|
1934
|
-
class Sedra {
|
|
1935
|
-
/**
|
|
1936
|
-
* Caculates the Parashah HaShavua for an entire Hebrew year
|
|
1937
|
-
* @param hyear - Hebrew year (e.g. 5749)
|
|
1938
|
-
* @param il - Use Israel sedra schedule (false for Diaspora)
|
|
1939
|
-
*/
|
|
1940
|
-
constructor(hyear, il) {
|
|
1941
|
-
hyear = +hyear;
|
|
1942
|
-
this.year = hyear;
|
|
1943
|
-
const rh0 = new HDate(1, months.TISHREI, hyear);
|
|
1944
|
-
const rh = (this.rh = rh0.abs());
|
|
1945
|
-
const rhDay = rh0.getDay() + 1;
|
|
1946
|
-
// find the first Saturday on or after Rosh Hashana
|
|
1947
|
-
this.firstSaturday = HDate.dayOnOrBefore(6, rh + 6);
|
|
1948
|
-
const leap = +HDate.isLeapYear(hyear);
|
|
1949
|
-
this.il = Boolean(il);
|
|
1950
|
-
const type = yearType(hyear);
|
|
1951
|
-
let key = `${leap}${rhDay}${type}`;
|
|
1952
|
-
if (types[key]) {
|
|
1953
|
-
this.theSedraArray = types[key];
|
|
1954
|
-
this.yearKey = key;
|
|
1955
|
-
}
|
|
1956
|
-
else {
|
|
1957
|
-
key = key + +this.il; // cast to num, then concat
|
|
1958
|
-
this.theSedraArray = types[key];
|
|
1959
|
-
this.yearKey = key;
|
|
1960
|
-
}
|
|
1961
|
-
if (!this.theSedraArray) {
|
|
1962
|
-
throw new Error(`improper sedra year type ${key} calculated for ${hyear}`);
|
|
1963
|
-
}
|
|
1964
|
-
}
|
|
1965
|
-
/**
|
|
1966
|
-
* Returns the date that a parsha occurs
|
|
1967
|
-
* or `null` if the parsha doesn't occur this year
|
|
1968
|
-
* @param parsha if a `string`, specified with Sephardic transliterations
|
|
1969
|
-
* like `'Noach'` or `'Matot-Masei'`. If an array, must be a 1- or 2-element
|
|
1970
|
-
* array such as `['Noach']` or `['Matot', 'Masei']`. If a `number`, should
|
|
1971
|
-
* be a 0-based parsha index (`0` for Bereshit, `1` for Noach) or a negative
|
|
1972
|
-
* number for a doubled parsha (e.g. `-21` for Vayakhel-Pekudei)
|
|
1973
|
-
*/
|
|
1974
|
-
find(parsha) {
|
|
1975
|
-
if (typeof parsha === 'number') {
|
|
1976
|
-
if (parsha >= parshiot.length || (parsha < 0 && !isValidDouble(parsha))) {
|
|
1977
|
-
throw new RangeError(`Invalid parsha number: ${parsha}`);
|
|
1978
|
-
}
|
|
1979
|
-
return this.findInternal(parsha);
|
|
1980
|
-
}
|
|
1981
|
-
else if (typeof parsha === 'string') {
|
|
1982
|
-
const num = parsha2id.get(parsha);
|
|
1983
|
-
if (typeof num === 'number') {
|
|
1984
|
-
return this.find(num);
|
|
1985
|
-
}
|
|
1986
|
-
else if (parsha.indexOf('-') !== -1) {
|
|
1987
|
-
if (parsha === CHMPESACH || parsha === CHMSUKOT) {
|
|
1988
|
-
return this.findInternal(parsha);
|
|
1989
|
-
}
|
|
1990
|
-
return this.find(parsha.split('-'));
|
|
1991
|
-
}
|
|
1992
|
-
else {
|
|
1993
|
-
// try to find Saturday holiday like 'Yom Kippur'
|
|
1994
|
-
return this.findInternal(parsha);
|
|
1995
|
-
}
|
|
1996
|
-
}
|
|
1997
|
-
else if (Array.isArray(parsha)) {
|
|
1998
|
-
const plen = parsha.length;
|
|
1999
|
-
if ((plen !== 1 && plen !== 2) || typeof parsha[0] !== 'string') {
|
|
2000
|
-
throw new TypeError(`Invalid parsha argument: ${JSON.stringify(parsha)}`);
|
|
2001
|
-
}
|
|
2002
|
-
if (plen === 1) {
|
|
2003
|
-
return this.find(parsha[0]);
|
|
2004
|
-
}
|
|
2005
|
-
const p1 = parsha[0];
|
|
2006
|
-
const p2 = parsha[1];
|
|
2007
|
-
const num1 = parsha2id.get(p1);
|
|
2008
|
-
const num2 = parsha2id.get(p2);
|
|
2009
|
-
if (typeof num1 !== 'number' ||
|
|
2010
|
-
typeof num2 !== 'number' ||
|
|
2011
|
-
num2 !== num1 + 1 ||
|
|
2012
|
-
!isValidDouble(-num1)) {
|
|
2013
|
-
throw new RangeError(`Unrecognized parsha name: ${p1}-${p2}`);
|
|
2014
|
-
}
|
|
2015
|
-
return this.find(-num1);
|
|
2016
|
-
}
|
|
2017
|
-
return null; /* NOTREACHED */
|
|
2018
|
-
}
|
|
2019
|
-
findInternal(parsha) {
|
|
2020
|
-
const idx = this.theSedraArray.indexOf(parsha);
|
|
2021
|
-
if (idx === -1) {
|
|
2022
|
-
return null; // doesn't occur this year
|
|
2023
|
-
}
|
|
2024
|
-
return new HDate(this.firstSaturday + idx * 7);
|
|
2025
|
-
}
|
|
2026
|
-
/**
|
|
2027
|
-
* Returns the date that a parsha (or its doubled or undoubled counterpart)
|
|
2028
|
-
* occurs, or `null` if the parsha doesn't occur this year
|
|
2029
|
-
*/
|
|
2030
|
-
findContaining(parsha) {
|
|
2031
|
-
const hdate = this.find(parsha);
|
|
2032
|
-
if (hdate) {
|
|
2033
|
-
return hdate;
|
|
2034
|
-
}
|
|
2035
|
-
if (typeof parsha === 'number') {
|
|
2036
|
-
// a valid negative number (double parsha in a year where they are
|
|
2037
|
-
// combined) would've been found above, and a invalid negative number
|
|
2038
|
-
// would've thrown an error, so this parsha must be a positive number
|
|
2039
|
-
// representing either p1 or p2
|
|
2040
|
-
const p1 = -parsha;
|
|
2041
|
-
if (isValidDouble(p1)) {
|
|
2042
|
-
return this.find(p1);
|
|
2043
|
-
}
|
|
2044
|
-
else {
|
|
2045
|
-
// this must be the second individual parsha of a doubled pair
|
|
2046
|
-
// for example 29 for Kedoshim, so check for -28 for Achrei Mot-Kedoshim
|
|
2047
|
-
return this.find(p1 + 1);
|
|
2048
|
-
}
|
|
2049
|
-
}
|
|
2050
|
-
else {
|
|
2051
|
-
const num = parsha2id.get(parsha);
|
|
2052
|
-
if (num) {
|
|
2053
|
-
// parsha is either the first or second individual parsha of
|
|
2054
|
-
// a pair that is doubled this year
|
|
2055
|
-
const p1 = -num;
|
|
2056
|
-
if (isValidDouble(p1)) {
|
|
2057
|
-
return this.find(p1);
|
|
2058
|
-
}
|
|
2059
|
-
else {
|
|
2060
|
-
return this.find(p1 + 1);
|
|
2061
|
-
}
|
|
2062
|
-
}
|
|
2063
|
-
else {
|
|
2064
|
-
// this was indeed a doubled parsha, so return date of the first half
|
|
2065
|
-
const [p1] = parsha.split('-');
|
|
2066
|
-
return this.find(p1);
|
|
2067
|
-
}
|
|
2068
|
-
}
|
|
2069
|
-
}
|
|
2070
|
-
/**
|
|
2071
|
-
* Returns the underlying annual sedra schedule.
|
|
2072
|
-
* Used by `@hebcal/triennial`
|
|
2073
|
-
*/
|
|
2074
|
-
getSedraArray() {
|
|
2075
|
-
return this.theSedraArray;
|
|
2076
|
-
}
|
|
2077
|
-
/**
|
|
2078
|
-
* R.D. date of the first Saturday on or after Rosh Hashana
|
|
2079
|
-
*/
|
|
2080
|
-
getFirstSaturday() {
|
|
2081
|
-
return this.firstSaturday;
|
|
2082
|
-
}
|
|
2083
|
-
getYear() {
|
|
2084
|
-
return this.year;
|
|
2085
|
-
}
|
|
2086
|
-
/**
|
|
2087
|
-
* Returns an object describing the parsha on the first Saturday on or after `hd`
|
|
2088
|
-
* @param hd Hebrew date or R.D. days
|
|
2089
|
-
*/
|
|
2090
|
-
lookup(hd) {
|
|
2091
|
-
const abs = typeof hd === 'number' ? hd : HDate.isHDate(hd) ? hd.abs() : NaN;
|
|
2092
|
-
if (isNaN(abs)) {
|
|
2093
|
-
throw new TypeError(`Bad date argument: ${hd}`);
|
|
2094
|
-
}
|
|
2095
|
-
else if (abs < this.rh) {
|
|
2096
|
-
throw new RangeError(`Date ${hd} before start of Hebrew year ${this.year}`);
|
|
2097
|
-
}
|
|
2098
|
-
// find the first saturday on or after today's date
|
|
2099
|
-
const saturday = HDate.dayOnOrBefore(6, abs + 6);
|
|
2100
|
-
const weekNum = (saturday - this.firstSaturday) / 7;
|
|
2101
|
-
const index = this.theSedraArray[weekNum];
|
|
2102
|
-
if (typeof index === 'undefined') {
|
|
2103
|
-
const sedra = getSedra(this.year + 1, this.il);
|
|
2104
|
-
return sedra.lookup(saturday); // must be next year
|
|
2105
|
-
}
|
|
2106
|
-
const hdate = new HDate(saturday);
|
|
2107
|
-
if (typeof index === 'string') {
|
|
2108
|
-
// Shabbat has a chag. Return a description
|
|
2109
|
-
return { parsha: [index], chag: true, hdate, il: this.il, num: 0 };
|
|
2110
|
-
}
|
|
2111
|
-
if (index >= 0) {
|
|
2112
|
-
return {
|
|
2113
|
-
parsha: [parshiot[index]],
|
|
2114
|
-
chag: false,
|
|
2115
|
-
num: index + 1,
|
|
2116
|
-
hdate,
|
|
2117
|
-
il: this.il,
|
|
2118
|
-
};
|
|
2119
|
-
}
|
|
2120
|
-
const p1 = D(index); // undouble the parsha
|
|
2121
|
-
return {
|
|
2122
|
-
parsha: [parshiot[p1], parshiot[p1 + 1]],
|
|
2123
|
-
chag: false,
|
|
2124
|
-
num: [p1 + 1, p1 + 2],
|
|
2125
|
-
hdate,
|
|
2126
|
-
il: this.il,
|
|
2127
|
-
};
|
|
2128
|
-
}
|
|
2129
|
-
}
|
|
2130
|
-
/**
|
|
2131
|
-
* The 54 parshiyot of the Torah as transilterated strings.
|
|
2132
|
-
* * parshiot[0] == `Bereshit`
|
|
2133
|
-
* * parshiot[1] == `Noach`
|
|
2134
|
-
* * parshiot[52] == `Ha'azinu`
|
|
2135
|
-
* * parshiot[53] == `Vezot Haberakhah`
|
|
2136
|
-
* @readonly
|
|
2137
|
-
* @type {string[]}
|
|
2138
|
-
*/
|
|
2139
|
-
const parshiot = [
|
|
2140
|
-
'Bereshit',
|
|
2141
|
-
'Noach',
|
|
2142
|
-
'Lech-Lecha',
|
|
2143
|
-
'Vayera',
|
|
2144
|
-
'Chayei Sara',
|
|
2145
|
-
'Toldot',
|
|
2146
|
-
'Vayetzei',
|
|
2147
|
-
'Vayishlach',
|
|
2148
|
-
'Vayeshev',
|
|
2149
|
-
'Miketz',
|
|
2150
|
-
'Vayigash',
|
|
2151
|
-
'Vayechi',
|
|
2152
|
-
'Shemot',
|
|
2153
|
-
'Vaera',
|
|
2154
|
-
'Bo',
|
|
2155
|
-
'Beshalach',
|
|
2156
|
-
'Yitro',
|
|
2157
|
-
'Mishpatim',
|
|
2158
|
-
'Terumah',
|
|
2159
|
-
'Tetzaveh',
|
|
2160
|
-
'Ki Tisa',
|
|
2161
|
-
'Vayakhel',
|
|
2162
|
-
'Pekudei',
|
|
2163
|
-
'Vayikra',
|
|
2164
|
-
'Tzav',
|
|
2165
|
-
'Shmini',
|
|
2166
|
-
'Tazria',
|
|
2167
|
-
'Metzora',
|
|
2168
|
-
'Achrei Mot',
|
|
2169
|
-
'Kedoshim',
|
|
2170
|
-
'Emor',
|
|
2171
|
-
'Behar',
|
|
2172
|
-
'Bechukotai',
|
|
2173
|
-
'Bamidbar',
|
|
2174
|
-
'Nasso',
|
|
2175
|
-
"Beha'alotcha",
|
|
2176
|
-
"Sh'lach",
|
|
2177
|
-
'Korach',
|
|
2178
|
-
'Chukat',
|
|
2179
|
-
'Balak',
|
|
2180
|
-
'Pinchas',
|
|
2181
|
-
'Matot',
|
|
2182
|
-
'Masei',
|
|
2183
|
-
'Devarim',
|
|
2184
|
-
'Vaetchanan',
|
|
2185
|
-
'Eikev',
|
|
2186
|
-
"Re'eh",
|
|
2187
|
-
'Shoftim',
|
|
2188
|
-
'Ki Teitzei',
|
|
2189
|
-
'Ki Tavo',
|
|
2190
|
-
'Nitzavim',
|
|
2191
|
-
'Vayeilech',
|
|
2192
|
-
"Ha'azinu",
|
|
2193
|
-
'Vezot Haberakhah',
|
|
2194
|
-
];
|
|
2195
|
-
// 0-based parsha IDs
|
|
2196
|
-
const parsha2id = new Map();
|
|
2197
|
-
for (let id = 0; id < parshiot.length; id++) {
|
|
2198
|
-
const name = parshiot[id];
|
|
2199
|
-
parsha2id.set(name, id);
|
|
2200
|
-
}
|
|
2201
|
-
// 0-based parsha IDs
|
|
2202
|
-
const doubles = [
|
|
2203
|
-
21, // Vayakhel-Pekudei
|
|
2204
|
-
26, // Tazria-Metzora
|
|
2205
|
-
28, // Achrei Mot-Kedoshim
|
|
2206
|
-
31, // Behar-Bechukotai
|
|
2207
|
-
38, // Chukat-Balak
|
|
2208
|
-
41, // Matot-Masei
|
|
2209
|
-
50, // Nitzavim-Vayeilech
|
|
2210
|
-
];
|
|
2211
|
-
/**
|
|
2212
|
-
* @private
|
|
2213
|
-
* @param id a negative number
|
|
2214
|
-
*/
|
|
2215
|
-
function isValidDouble(id) {
|
|
2216
|
-
return doubles.includes(-id);
|
|
2217
|
-
}
|
|
2218
|
-
/**
|
|
2219
|
-
* parsha doubler/undoubler
|
|
2220
|
-
* @private
|
|
2221
|
-
* @param p
|
|
2222
|
-
*/
|
|
2223
|
-
function D(p) {
|
|
2224
|
-
return -p;
|
|
2225
|
-
}
|
|
2226
|
-
const RH = 'Rosh Hashana'; // 0
|
|
2227
|
-
const YK = 'Yom Kippur'; // 1
|
|
2228
|
-
const SUKKOT = 'Sukkot'; // 0
|
|
2229
|
-
const CHMSUKOT = 'Sukkot Shabbat Chol ha-Moed'; // 0
|
|
2230
|
-
const SHMINI = 'Shmini Atzeret'; // 0
|
|
2231
|
-
const PESACH = 'Pesach'; // 25
|
|
2232
|
-
const PESACH1 = 'Pesach I';
|
|
2233
|
-
const CHMPESACH = 'Pesach Shabbat Chol ha-Moed'; // 25
|
|
2234
|
-
const PESACH7 = 'Pesach VII'; // 25
|
|
2235
|
-
const PESACH8 = 'Pesach VIII';
|
|
2236
|
-
const SHAVUOT = 'Shavuot'; // 33
|
|
2237
|
-
/**
|
|
2238
|
-
* Returns an array from start to end
|
|
2239
|
-
* @private
|
|
2240
|
-
* @param start beginning number, inclusive
|
|
2241
|
-
* @param stop ending number, inclusive
|
|
2242
|
-
*/
|
|
2243
|
-
function range(start, stop) {
|
|
2244
|
-
return Array.from({ length: stop - start + 1 }, (v, k) => k + start);
|
|
2245
|
-
}
|
|
2246
|
-
const yearStartVayeilech = [51, 52, CHMSUKOT];
|
|
2247
|
-
const yearStartHaazinu = [52, YK, CHMSUKOT];
|
|
2248
|
-
const yearStartRH = [RH, 52, SUKKOT, SHMINI];
|
|
2249
|
-
const r020 = range(0, 20);
|
|
2250
|
-
const r027 = range(0, 27);
|
|
2251
|
-
const r3340 = range(33, 40);
|
|
2252
|
-
const r4349 = range(43, 49);
|
|
2253
|
-
const r4350 = range(43, 50);
|
|
2254
|
-
/**
|
|
2255
|
-
* The ordinary year types (keviot)
|
|
2256
|
-
* names are leap/nonleap - day - incomplete/regular/complete - diaspora/Israel
|
|
2257
|
-
* @private
|
|
2258
|
-
* @readonly
|
|
2259
|
-
*/
|
|
2260
|
-
const types = {
|
|
2261
|
-
/* Hebrew year that starts on Monday, is `incomplete' (Heshvan and
|
|
2262
|
-
* Kislev each have 29 days), and has Passover start on Tuesday. */
|
|
2263
|
-
// e.g. 5753
|
|
2264
|
-
'020': yearStartVayeilech.concat(r020, D(21), 23, 24, CHMPESACH, 25, D(26), D(28), 30, D(31), r3340, D(41), r4349, D(50)),
|
|
2265
|
-
/* Hebrew year that starts on Monday, is `complete' (Heshvan and
|
|
2266
|
-
* Kislev each have 30 days), and has Passover start on Thursday. */
|
|
2267
|
-
// e.g. 5756
|
|
2268
|
-
'0220': yearStartVayeilech.concat(r020, D(21), 23, 24, CHMPESACH, 25, D(26), D(28), 30, D(31), 33, SHAVUOT, range(34, 37), D(38), 40, D(41), r4349, D(50)),
|
|
2269
|
-
/* Hebrew year that starts on Thursday, is `regular' (Heshvan has 29
|
|
2270
|
-
* days and Kislev has 30 days), and has Passover start on Saturday. */
|
|
2271
|
-
// e.g. 5701
|
|
2272
|
-
'0510': yearStartHaazinu.concat(r020, D(21), 23, 24, PESACH1, PESACH8, 25, D(26), D(28), 30, D(31), r3340, D(41), r4350),
|
|
2273
|
-
/* Hebrew year that starts on Thursday, is `regular' (Heshvan has 29
|
|
2274
|
-
* days and Kislev has 30 days), and has Passover start on Saturday. */
|
|
2275
|
-
// e.g. 5745
|
|
2276
|
-
'0511': yearStartHaazinu.concat(r020, D(21), 23, 24, PESACH, 25, D(26), D(28), range(30, 40), D(41), r4350),
|
|
2277
|
-
/* Hebrew year that starts on Thursday, is `complete' (Heshvan and
|
|
2278
|
-
* Kislev each have 30 days), and has Passover start on Sunday. */
|
|
2279
|
-
// e.g. 5754
|
|
2280
|
-
'052': yearStartHaazinu.concat(range(0, 24), PESACH7, 25, D(26), D(28), 30, D(31), r3340, D(41), r4350),
|
|
2281
|
-
/* Hebrew year that starts on Saturday, is `incomplete' (Heshvan and Kislev
|
|
2282
|
-
* each have 29 days), and has Passover start on Sunday. */
|
|
2283
|
-
// e.g. 5761
|
|
2284
|
-
'070': yearStartRH.concat(r020, D(21), 23, 24, PESACH7, 25, D(26), D(28), 30, D(31), r3340, D(41), r4350),
|
|
2285
|
-
/* Hebrew year that starts on Saturday, is `complete' (Heshvan and
|
|
2286
|
-
* Kislev each have 30 days), and has Passover start on Tuesday. */
|
|
2287
|
-
// e.g. 5716
|
|
2288
|
-
'072': yearStartRH.concat(r020, D(21), 23, 24, CHMPESACH, 25, D(26), D(28), 30, D(31), r3340, D(41), r4349, D(50)),
|
|
2289
|
-
/* -- The leap year types (keviot) -- */
|
|
2290
|
-
/* Hebrew year that starts on Monday, is `incomplete' (Heshvan and
|
|
2291
|
-
* Kislev each have 29 days), and has Passover start on Thursday. */
|
|
2292
|
-
// e.g. 5746
|
|
2293
|
-
'1200': yearStartVayeilech.concat(r027, CHMPESACH, range(28, 33), SHAVUOT, range(34, 37), D(38), 40, D(41), r4349, D(50)),
|
|
2294
|
-
/* Hebrew year that starts on Monday, is `incomplete' (Heshvan and
|
|
2295
|
-
* Kislev each have 29 days), and has Passover start on Thursday. */
|
|
2296
|
-
// e.g. 5746
|
|
2297
|
-
'1201': yearStartVayeilech.concat(r027, CHMPESACH, range(28, 40), D(41), r4349, D(50)),
|
|
2298
|
-
/* Hebrew year that starts on Monday, is `complete' (Heshvan and
|
|
2299
|
-
* Kislev each have 30 days), and has Passover start on Saturday. */
|
|
2300
|
-
// e.g.5752
|
|
2301
|
-
'1220': yearStartVayeilech.concat(r027, PESACH1, PESACH8, range(28, 40), D(41), r4350),
|
|
2302
|
-
/* Hebrew year that starts on Monday, is `complete' (Heshvan and
|
|
2303
|
-
* Kislev each have 30 days), and has Passover start on Saturday. */
|
|
2304
|
-
// e.g.5752
|
|
2305
|
-
'1221': yearStartVayeilech.concat(r027, PESACH, range(28, 50)),
|
|
2306
|
-
/* Hebrew year that starts on Thursday, is `incomplete' (Heshvan and
|
|
2307
|
-
* Kislev both have 29 days), and has Passover start on Sunday. */
|
|
2308
|
-
// e.g. 5768
|
|
2309
|
-
'150': yearStartHaazinu.concat(range(0, 28), PESACH7, range(29, 50)),
|
|
2310
|
-
/* Hebrew year that starts on Thursday, is `complete' (Heshvan and
|
|
2311
|
-
* Kislev both have 30 days), and has Passover start on Tuesday. */
|
|
2312
|
-
// eg. 5771
|
|
2313
|
-
'152': yearStartHaazinu.concat(range(0, 28), CHMPESACH, range(29, 49), D(50)),
|
|
2314
|
-
/* Hebrew year that starts on Saturday, is `incomplete' (Heshvan and
|
|
2315
|
-
* Kislev each have 29 days), and has Passover start on Tuesday. */
|
|
2316
|
-
// e.g.5757
|
|
2317
|
-
'170': yearStartRH.concat(r027, CHMPESACH, range(28, 40), D(41), r4349, D(50)),
|
|
2318
|
-
/* Hebrew year that starts on Saturday, is `complete' (Heshvan and
|
|
2319
|
-
* Kislev each have 30 days), and has Passover start on Thursday. */
|
|
2320
|
-
'1720': yearStartRH.concat(r027, CHMPESACH, range(28, 33), SHAVUOT, range(34, 37), D(38), 40, D(41), r4349, D(50)),
|
|
2321
|
-
};
|
|
2322
|
-
/* Hebrew year that starts on Monday, is `complete' (Heshvan and
|
|
2323
|
-
* Kislev each have 30 days), and has Passover start on Thursday. */
|
|
2324
|
-
types['0221'] = types['020'];
|
|
2325
|
-
/* Hebrew year that starts on Tuesday, is `regular' (Heshvan has 29
|
|
2326
|
-
* days and Kislev has 30 days), and has Passover start on Thursday. */
|
|
2327
|
-
// e.g. 5715
|
|
2328
|
-
types['0310'] = types['0220'];
|
|
2329
|
-
/* Hebrew year that starts on Tuesday, is `regular' (Heshvan has 29
|
|
2330
|
-
* days and Kislev has 30 days), and has Passover start on Thursday. */
|
|
2331
|
-
types['0311'] = types['020'];
|
|
2332
|
-
/* Hebrew year that starts on Tuesday, is `regular' (Heshvan has 29
|
|
2333
|
-
* days and Kislev has 30 days), and has Passover start on Saturday. */
|
|
2334
|
-
// e.g. 5715
|
|
2335
|
-
types['1310'] = types['1220'];
|
|
2336
|
-
/* Hebrew year that starts on Tuesday, is `regular' (Heshvan has 29
|
|
2337
|
-
* days and Kislev has 30 days), and has Passover start on Saturday. */
|
|
2338
|
-
types['1311'] = types['1221'];
|
|
2339
|
-
/* Hebrew year that starts on Saturday, is `complete' (Heshvan and
|
|
2340
|
-
* Kislev each have 30 days), and has Passover start on Thursday. */
|
|
2341
|
-
types['1721'] = types['170'];
|
|
2342
|
-
const sedraCache = new QuickLRU({ maxSize: 400 });
|
|
2343
|
-
/**
|
|
2344
|
-
* Convenience function to create an instance of `Sedra` or reuse a previously
|
|
2345
|
-
* created and cached instance.
|
|
2346
|
-
* @param hyear
|
|
2347
|
-
* @param il
|
|
2348
|
-
*/
|
|
2349
|
-
function getSedra(hyear, il) {
|
|
2350
|
-
const cacheKey = `${hyear}-${il ? 1 : 0}`;
|
|
2351
|
-
let sedra = sedraCache.get(cacheKey);
|
|
2352
|
-
if (!sedra) {
|
|
2353
|
-
sedra = new Sedra(hyear, il);
|
|
2354
|
-
sedraCache.set(cacheKey, sedra);
|
|
2355
|
-
}
|
|
2356
|
-
return sedra;
|
|
2357
|
-
}
|
|
2358
|
-
const sedra = getSedra(5757, false);
|
|
2359
|
-
console.log(sedra.lookup(729122).parsha);
|