@hebcal/core 3.37.2 → 3.38.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +39 -37
- package/dist/bundle.js +1367 -1148
- package/dist/bundle.min.js +2 -2
- package/dist/hdate-bundle.js +473 -312
- package/dist/hdate-bundle.min.js +2 -2
- package/dist/hdate.js +494 -307
- package/dist/hdate.mjs +494 -307
- package/dist/hdate0-bundle.js +469 -0
- package/dist/hdate0-bundle.min.js +2 -0
- package/dist/index.js +510 -368
- package/dist/index.mjs +530 -368
- package/package.json +9 -9
package/dist/hdate.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! @hebcal/core v3.
|
|
1
|
+
/*! @hebcal/core v3.38.2 */
|
|
2
2
|
const GERESH = '׳';
|
|
3
3
|
const GERSHAYIM = '״';
|
|
4
4
|
/**
|
|
@@ -165,26 +165,15 @@ function gematriya(number) {
|
|
|
165
165
|
}
|
|
166
166
|
|
|
167
167
|
/*
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
Portions copyright Eyal Schachter and Michael J. Radwin
|
|
171
|
-
|
|
172
|
-
https://github.com/hebcal/hebcal-es6
|
|
173
|
-
|
|
174
|
-
This program is free software; you can redistribute it and/or
|
|
175
|
-
modify it under the terms of the GNU General Public License
|
|
176
|
-
as published by the Free Software Foundation; either version 2
|
|
177
|
-
of the License, or (at your option) any later version.
|
|
168
|
+
* More minimal greg routines
|
|
169
|
+
*/
|
|
178
170
|
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
GNU General Public License for more details.
|
|
171
|
+
/** @private */
|
|
172
|
+
const lengths = [0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
|
|
173
|
+
/** @private */
|
|
183
174
|
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
*/
|
|
187
|
-
const monthLengths = [[0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31], [0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]];
|
|
175
|
+
const monthLengths = [lengths, lengths.slice()];
|
|
176
|
+
monthLengths[1][2] = 29;
|
|
188
177
|
/**
|
|
189
178
|
* @private
|
|
190
179
|
* @param {number} x
|
|
@@ -206,9 +195,168 @@ function quotient(x, y) {
|
|
|
206
195
|
return Math.floor(x / y);
|
|
207
196
|
}
|
|
208
197
|
/**
|
|
209
|
-
* Gregorian
|
|
198
|
+
* Returns true if the Gregorian year is a leap year
|
|
199
|
+
* @private
|
|
200
|
+
* @param {number} year Gregorian year
|
|
201
|
+
* @return {boolean}
|
|
202
|
+
*/
|
|
203
|
+
|
|
204
|
+
|
|
205
|
+
function isLeapYear$1(year) {
|
|
206
|
+
return !(year % 4) && (!!(year % 100) || !(year % 400));
|
|
207
|
+
}
|
|
208
|
+
/**
|
|
209
|
+
* Number of days in the Gregorian month for given year
|
|
210
|
+
* @private
|
|
211
|
+
* @param {number} month Gregorian month (1=January, 12=December)
|
|
212
|
+
* @param {number} year Gregorian year
|
|
213
|
+
* @return {number}
|
|
214
|
+
*/
|
|
215
|
+
|
|
216
|
+
function daysInMonth$1(month, year) {
|
|
217
|
+
// 1 based months
|
|
218
|
+
return monthLengths[+isLeapYear$1(year)][month];
|
|
219
|
+
}
|
|
220
|
+
/**
|
|
221
|
+
* Returns true if the object is a Javascript Date
|
|
222
|
+
* @private
|
|
223
|
+
* @param {Object} obj
|
|
224
|
+
* @return {boolean}
|
|
225
|
+
*/
|
|
226
|
+
|
|
227
|
+
function isDate(obj) {
|
|
228
|
+
return typeof obj === 'object' && Date.prototype === obj.__proto__;
|
|
229
|
+
}
|
|
230
|
+
/**
|
|
231
|
+
* Returns number of days since January 1 of that year
|
|
232
|
+
* @private
|
|
233
|
+
* @param {Date} date Gregorian date
|
|
234
|
+
* @return {number}
|
|
235
|
+
*/
|
|
236
|
+
|
|
237
|
+
function dayOfYear(date) {
|
|
238
|
+
if (!isDate(date)) {
|
|
239
|
+
throw new TypeError(`Argument not a Date: ${date}`);
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
let doy = date.getDate() + 31 * date.getMonth();
|
|
243
|
+
|
|
244
|
+
if (date.getMonth() > 1) {
|
|
245
|
+
// FEB
|
|
246
|
+
doy -= Math.floor((4 * (date.getMonth() + 1) + 23) / 10);
|
|
247
|
+
|
|
248
|
+
if (isLeapYear$1(date.getFullYear())) {
|
|
249
|
+
doy++;
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
return doy;
|
|
254
|
+
}
|
|
255
|
+
/**
|
|
256
|
+
* Converts Gregorian date to absolute R.D. (Rata Die) days
|
|
257
|
+
* @private
|
|
258
|
+
* @param {Date} date Gregorian date
|
|
259
|
+
* @return {number}
|
|
260
|
+
*/
|
|
261
|
+
|
|
262
|
+
function greg2abs(date) {
|
|
263
|
+
if (!isDate(date)) {
|
|
264
|
+
throw new TypeError(`Argument not a Date: ${date}`);
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
const year = date.getFullYear() - 1;
|
|
268
|
+
return dayOfYear(date) + // days this year
|
|
269
|
+
365 * year + ( // + days in prior years
|
|
270
|
+
Math.floor(year / 4) - // + Julian Leap years
|
|
271
|
+
Math.floor(year / 100) + // - century years
|
|
272
|
+
Math.floor(year / 400)); // + Gregorian leap years
|
|
273
|
+
}
|
|
274
|
+
/**
|
|
275
|
+
* @private
|
|
276
|
+
* @param {number} abs - R.D. number of days
|
|
277
|
+
* @return {number}
|
|
210
278
|
*/
|
|
211
279
|
|
|
280
|
+
function yearFromFixed(abs) {
|
|
281
|
+
const l0 = abs - 1;
|
|
282
|
+
const n400 = quotient(l0, 146097);
|
|
283
|
+
const d1 = mod(l0, 146097);
|
|
284
|
+
const n100 = quotient(d1, 36524);
|
|
285
|
+
const d2 = mod(d1, 36524);
|
|
286
|
+
const n4 = quotient(d2, 1461);
|
|
287
|
+
const d3 = mod(d2, 1461);
|
|
288
|
+
const n1 = quotient(d3, 365);
|
|
289
|
+
const year = 400 * n400 + 100 * n100 + 4 * n4 + n1;
|
|
290
|
+
return n100 != 4 && n1 != 4 ? year + 1 : year;
|
|
291
|
+
}
|
|
292
|
+
/**
|
|
293
|
+
* @private
|
|
294
|
+
* @param {number} year
|
|
295
|
+
* @param {number} month
|
|
296
|
+
* @param {number} day
|
|
297
|
+
* @return {number}
|
|
298
|
+
*/
|
|
299
|
+
|
|
300
|
+
|
|
301
|
+
function toFixed(year, month, day) {
|
|
302
|
+
const py = year - 1;
|
|
303
|
+
return 0 + 365 * py + quotient(py, 4) - quotient(py, 100) + quotient(py, 400) + quotient(367 * month - 362, 12) + Math.floor(month <= 2 ? 0 : isLeapYear$1(year) ? -1 : -2) + day;
|
|
304
|
+
}
|
|
305
|
+
/**
|
|
306
|
+
* Converts from Rata Die (R.D. number) to Gregorian date.
|
|
307
|
+
* See the footnote on page 384 of ``Calendrical Calculations, Part II:
|
|
308
|
+
* Three Historical Calendars'' by E. M. Reingold, N. Dershowitz, and S. M.
|
|
309
|
+
* Clamen, Software--Practice and Experience, Volume 23, Number 4
|
|
310
|
+
* (April, 1993), pages 383-404 for an explanation.
|
|
311
|
+
* @private
|
|
312
|
+
* @param {number} abs - R.D. number of days
|
|
313
|
+
* @return {Date}
|
|
314
|
+
*/
|
|
315
|
+
|
|
316
|
+
|
|
317
|
+
function abs2greg(abs) {
|
|
318
|
+
if (typeof abs !== 'number') {
|
|
319
|
+
throw new TypeError(`Argument not a Number: ${abs}`);
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
abs = Math.trunc(abs);
|
|
323
|
+
const year = yearFromFixed(abs);
|
|
324
|
+
const priorDays = abs - toFixed(year, 1, 1);
|
|
325
|
+
const correction = abs < toFixed(year, 3, 1) ? 0 : isLeapYear$1(year) ? 1 : 2;
|
|
326
|
+
const month = quotient(12 * (priorDays + correction) + 373, 367);
|
|
327
|
+
const day = abs - toFixed(year, month, 1) + 1;
|
|
328
|
+
const dt = new Date(year, month - 1, day);
|
|
329
|
+
|
|
330
|
+
if (year < 100 && year >= 0) {
|
|
331
|
+
dt.setFullYear(year);
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
return dt;
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
/*
|
|
338
|
+
Hebcal - A Jewish Calendar Generator
|
|
339
|
+
Copyright (c) 1994-2020 Danny Sadinoff
|
|
340
|
+
Portions copyright Eyal Schachter and Michael J. Radwin
|
|
341
|
+
|
|
342
|
+
https://github.com/hebcal/hebcal-es6
|
|
343
|
+
|
|
344
|
+
This program is free software; you can redistribute it and/or
|
|
345
|
+
modify it under the terms of the GNU General Public License
|
|
346
|
+
as published by the Free Software Foundation; either version 2
|
|
347
|
+
of the License, or (at your option) any later version.
|
|
348
|
+
|
|
349
|
+
This program is distributed in the hope that it will be useful,
|
|
350
|
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
351
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
352
|
+
GNU General Public License for more details.
|
|
353
|
+
|
|
354
|
+
You should have received a copy of the GNU General Public License
|
|
355
|
+
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
356
|
+
*/
|
|
357
|
+
/**
|
|
358
|
+
* Gregorian date helper functions.
|
|
359
|
+
*/
|
|
212
360
|
|
|
213
361
|
class greg {
|
|
214
362
|
/**
|
|
@@ -224,7 +372,7 @@ class greg {
|
|
|
224
372
|
*/
|
|
225
373
|
|
|
226
374
|
static isLeapYear(year) {
|
|
227
|
-
return
|
|
375
|
+
return isLeapYear$1(year);
|
|
228
376
|
}
|
|
229
377
|
/**
|
|
230
378
|
* Number of days in the Gregorian month for given year
|
|
@@ -235,8 +383,7 @@ class greg {
|
|
|
235
383
|
|
|
236
384
|
|
|
237
385
|
static daysInMonth(month, year) {
|
|
238
|
-
|
|
239
|
-
return monthLengths[+this.isLeapYear(year)][month];
|
|
386
|
+
return daysInMonth$1(month, year);
|
|
240
387
|
}
|
|
241
388
|
/**
|
|
242
389
|
* Returns true if the object is a Javascript Date
|
|
@@ -246,7 +393,7 @@ class greg {
|
|
|
246
393
|
|
|
247
394
|
|
|
248
395
|
static isDate(obj) {
|
|
249
|
-
return
|
|
396
|
+
return isDate(obj);
|
|
250
397
|
}
|
|
251
398
|
/**
|
|
252
399
|
* Returns number of days since January 1 of that year
|
|
@@ -256,22 +403,7 @@ class greg {
|
|
|
256
403
|
|
|
257
404
|
|
|
258
405
|
static dayOfYear(date) {
|
|
259
|
-
|
|
260
|
-
throw new TypeError('Argument to greg.dayOfYear not a Date');
|
|
261
|
-
}
|
|
262
|
-
|
|
263
|
-
let doy = date.getDate() + 31 * date.getMonth();
|
|
264
|
-
|
|
265
|
-
if (date.getMonth() > 1) {
|
|
266
|
-
// FEB
|
|
267
|
-
doy -= Math.floor((4 * (date.getMonth() + 1) + 23) / 10);
|
|
268
|
-
|
|
269
|
-
if (this.isLeapYear(date.getFullYear())) {
|
|
270
|
-
doy++;
|
|
271
|
-
}
|
|
272
|
-
}
|
|
273
|
-
|
|
274
|
-
return doy;
|
|
406
|
+
return dayOfYear(date);
|
|
275
407
|
}
|
|
276
408
|
/**
|
|
277
409
|
* Converts Gregorian date to absolute R.D. (Rata Die) days
|
|
@@ -281,48 +413,7 @@ class greg {
|
|
|
281
413
|
|
|
282
414
|
|
|
283
415
|
static greg2abs(date) {
|
|
284
|
-
|
|
285
|
-
throw new TypeError('Argument to greg.greg2abs not a Date');
|
|
286
|
-
}
|
|
287
|
-
|
|
288
|
-
const year = date.getFullYear() - 1;
|
|
289
|
-
return this.dayOfYear(date) + // days this year
|
|
290
|
-
365 * year + ( // + days in prior years
|
|
291
|
-
Math.floor(year / 4) - // + Julian Leap years
|
|
292
|
-
Math.floor(year / 100) + // - century years
|
|
293
|
-
Math.floor(year / 400)); // + Gregorian leap years
|
|
294
|
-
}
|
|
295
|
-
/**
|
|
296
|
-
* @private
|
|
297
|
-
* @param {number} theDate - R.D. number of days
|
|
298
|
-
* @return {number}
|
|
299
|
-
*/
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
static yearFromFixed(theDate) {
|
|
303
|
-
const l0 = theDate - 1;
|
|
304
|
-
const n400 = quotient(l0, 146097);
|
|
305
|
-
const d1 = mod(l0, 146097);
|
|
306
|
-
const n100 = quotient(d1, 36524);
|
|
307
|
-
const d2 = mod(d1, 36524);
|
|
308
|
-
const n4 = quotient(d2, 1461);
|
|
309
|
-
const d3 = mod(d2, 1461);
|
|
310
|
-
const n1 = quotient(d3, 365);
|
|
311
|
-
const year = 400 * n400 + 100 * n100 + 4 * n4 + n1;
|
|
312
|
-
return n100 != 4 && n1 != 4 ? year + 1 : year;
|
|
313
|
-
}
|
|
314
|
-
/**
|
|
315
|
-
* @private
|
|
316
|
-
* @param {number} year
|
|
317
|
-
* @param {number} month
|
|
318
|
-
* @param {number} day
|
|
319
|
-
* @return {number}
|
|
320
|
-
*/
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
static toFixed(year, month, day) {
|
|
324
|
-
const py = year - 1;
|
|
325
|
-
return 0 + 365 * py + quotient(py, 4) - quotient(py, 100) + quotient(py, 400) + quotient(367 * month - 362, 12) + Math.floor(month <= 2 ? 0 : this.isLeapYear(year) ? -1 : -2) + day;
|
|
416
|
+
return greg2abs(date);
|
|
326
417
|
}
|
|
327
418
|
/**
|
|
328
419
|
* Converts from Rata Die (R.D. number) to Gregorian date.
|
|
@@ -336,23 +427,7 @@ class greg {
|
|
|
336
427
|
|
|
337
428
|
|
|
338
429
|
static abs2greg(theDate) {
|
|
339
|
-
|
|
340
|
-
throw new TypeError('Argument to greg.abs2greg not a Number');
|
|
341
|
-
}
|
|
342
|
-
|
|
343
|
-
theDate = Math.trunc(theDate);
|
|
344
|
-
const year = this.yearFromFixed(theDate);
|
|
345
|
-
const priorDays = theDate - this.toFixed(year, 1, 1);
|
|
346
|
-
const correction = theDate < this.toFixed(year, 3, 1) ? 0 : this.isLeapYear(year) ? 1 : 2;
|
|
347
|
-
const month = quotient(12 * (priorDays + correction) + 373, 367);
|
|
348
|
-
const day = theDate - this.toFixed(year, month, 1) + 1;
|
|
349
|
-
const dt = new Date(year, month - 1, day);
|
|
350
|
-
|
|
351
|
-
if (year < 100 && year >= 0) {
|
|
352
|
-
dt.setFullYear(year);
|
|
353
|
-
}
|
|
354
|
-
|
|
355
|
-
return dt;
|
|
430
|
+
return abs2greg(theDate);
|
|
356
431
|
}
|
|
357
432
|
|
|
358
433
|
}
|
|
@@ -545,36 +620,19 @@ Locale.addLocale('', noopLocale);
|
|
|
545
620
|
Locale.useLocale('en');
|
|
546
621
|
|
|
547
622
|
/*
|
|
548
|
-
|
|
549
|
-
Copyright (c) 1994-2020 Danny Sadinoff
|
|
550
|
-
Portions copyright Eyal Schachter and Michael J. Radwin
|
|
551
|
-
|
|
552
|
-
https://github.com/hebcal/hebcal-es6
|
|
553
|
-
|
|
554
|
-
This program is free software; you can redistribute it and/or
|
|
555
|
-
modify it under the terms of the GNU General Public License
|
|
556
|
-
as published by the Free Software Foundation; either version 2
|
|
557
|
-
of the License, or (at your option) any later version.
|
|
558
|
-
|
|
559
|
-
This program is distributed in the hope that it will be useful,
|
|
560
|
-
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
561
|
-
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
562
|
-
GNU General Public License for more details.
|
|
563
|
-
|
|
564
|
-
You should have received a copy of the GNU General Public License
|
|
565
|
-
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
623
|
+
* More minimal HDate
|
|
566
624
|
*/
|
|
567
625
|
const NISAN$1 = 1;
|
|
568
|
-
const IYYAR = 2;
|
|
569
|
-
|
|
570
|
-
const TAMUZ = 4;
|
|
571
|
-
|
|
626
|
+
const IYYAR = 2; // const SIVAN = 3;
|
|
627
|
+
|
|
628
|
+
const TAMUZ = 4; // const AV = 5;
|
|
629
|
+
|
|
572
630
|
const ELUL = 6;
|
|
573
631
|
const TISHREI = 7;
|
|
574
632
|
const CHESHVAN$1 = 8;
|
|
575
633
|
const KISLEV$1 = 9;
|
|
576
|
-
const TEVET$1 = 10;
|
|
577
|
-
|
|
634
|
+
const TEVET$1 = 10; // const SHVAT = 11;
|
|
635
|
+
|
|
578
636
|
const ADAR_I$1 = 12;
|
|
579
637
|
const ADAR_II$1 = 13;
|
|
580
638
|
/**
|
|
@@ -630,16 +688,237 @@ const monthNames0 = ['', 'Nisan', 'Iyyar', 'Sivan', 'Tamuz', 'Av', 'Elul', 'Tish
|
|
|
630
688
|
* @private
|
|
631
689
|
*/
|
|
632
690
|
|
|
633
|
-
const monthNames = [monthNames0.concat(['Adar', 'Nisan']), monthNames0.concat(['Adar I', 'Adar II', 'Nisan'])];
|
|
691
|
+
const monthNames = [monthNames0.concat(['Adar', 'Nisan']), monthNames0.concat(['Adar I', 'Adar II', 'Nisan'])];
|
|
692
|
+
const edCache = Object.create(null);
|
|
693
|
+
const EPOCH = -1373428; // Avg year length in the cycle (19 solar years with 235 lunar months)
|
|
694
|
+
|
|
695
|
+
const AVG_HEBYEAR_DAYS = 365.24682220597794;
|
|
696
|
+
/**
|
|
697
|
+
* Converts Hebrew date to R.D. (Rata Die) fixed days.
|
|
698
|
+
* R.D. 1 is the imaginary date Monday, January 1, 1 on the Gregorian
|
|
699
|
+
* Calendar.
|
|
700
|
+
* @private
|
|
701
|
+
* @param {number} year Hebrew year
|
|
702
|
+
* @param {number} month Hebrew month
|
|
703
|
+
* @param {number} day Hebrew date (1-30)
|
|
704
|
+
* @return {number}
|
|
705
|
+
*/
|
|
706
|
+
|
|
707
|
+
function hebrew2abs(year, month, day) {
|
|
708
|
+
let tempabs = day;
|
|
709
|
+
|
|
710
|
+
if (month < TISHREI) {
|
|
711
|
+
for (let m = TISHREI; m <= monthsInYear(year); m++) {
|
|
712
|
+
tempabs += daysInMonth(m, year);
|
|
713
|
+
}
|
|
714
|
+
|
|
715
|
+
for (let m = NISAN$1; m < month; m++) {
|
|
716
|
+
tempabs += daysInMonth(m, year);
|
|
717
|
+
}
|
|
718
|
+
} else {
|
|
719
|
+
for (let m = TISHREI; m < month; m++) {
|
|
720
|
+
tempabs += daysInMonth(m, year);
|
|
721
|
+
}
|
|
722
|
+
}
|
|
723
|
+
|
|
724
|
+
return EPOCH + elapsedDays(year) + tempabs - 1;
|
|
725
|
+
}
|
|
726
|
+
/**
|
|
727
|
+
* @private
|
|
728
|
+
* @param {number} year
|
|
729
|
+
* @return {number}
|
|
730
|
+
*/
|
|
731
|
+
|
|
732
|
+
function newYear(year) {
|
|
733
|
+
return EPOCH + elapsedDays(year);
|
|
734
|
+
}
|
|
735
|
+
/**
|
|
736
|
+
* Converts absolute R.D. days to Hebrew date
|
|
737
|
+
* @private
|
|
738
|
+
* @param {number} abs absolute R.D. days
|
|
739
|
+
* @return {SimpleHebrewDate}
|
|
740
|
+
*/
|
|
741
|
+
|
|
742
|
+
|
|
743
|
+
function abs2hebrew(abs) {
|
|
744
|
+
if (typeof abs !== 'number' || isNaN(abs)) {
|
|
745
|
+
throw new TypeError(`invalid parameter to abs2hebrew ${abs}`);
|
|
746
|
+
}
|
|
747
|
+
|
|
748
|
+
abs = Math.trunc(abs); // first, quickly approximate year
|
|
749
|
+
|
|
750
|
+
let year = Math.floor((abs - EPOCH) / AVG_HEBYEAR_DAYS);
|
|
751
|
+
|
|
752
|
+
while (newYear(year) <= abs) {
|
|
753
|
+
++year;
|
|
754
|
+
}
|
|
755
|
+
|
|
756
|
+
--year;
|
|
757
|
+
let month = abs < hebrew2abs(year, 1, 1) ? 7 : 1;
|
|
758
|
+
|
|
759
|
+
while (abs > hebrew2abs(year, month, daysInMonth(month, year))) {
|
|
760
|
+
++month;
|
|
761
|
+
}
|
|
762
|
+
|
|
763
|
+
const day = 1 + abs - hebrew2abs(year, month, 1);
|
|
764
|
+
return {
|
|
765
|
+
yy: year,
|
|
766
|
+
mm: month,
|
|
767
|
+
dd: day
|
|
768
|
+
};
|
|
769
|
+
}
|
|
770
|
+
/**
|
|
771
|
+
* Returns true if Hebrew year is a leap year
|
|
772
|
+
* @private
|
|
773
|
+
* @param {number} year Hebrew year
|
|
774
|
+
* @return {boolean}
|
|
775
|
+
*/
|
|
776
|
+
|
|
777
|
+
function isLeapYear(year) {
|
|
778
|
+
return (1 + year * 7) % 19 < 7;
|
|
779
|
+
}
|
|
780
|
+
/**
|
|
781
|
+
* Number of months in this Hebrew year (either 12 or 13 depending on leap year)
|
|
782
|
+
* @private
|
|
783
|
+
* @param {number} year Hebrew year
|
|
784
|
+
* @return {number}
|
|
785
|
+
*/
|
|
786
|
+
|
|
787
|
+
function monthsInYear(year) {
|
|
788
|
+
return 12 + isLeapYear(year); // boolean is cast to 1 or 0
|
|
789
|
+
}
|
|
790
|
+
/**
|
|
791
|
+
* Number of days in Hebrew month in a given year (29 or 30)
|
|
792
|
+
* @private
|
|
793
|
+
* @param {number} month Hebrew month (e.g. months.TISHREI)
|
|
794
|
+
* @param {number} year Hebrew year
|
|
795
|
+
* @return {number}
|
|
796
|
+
*/
|
|
797
|
+
|
|
798
|
+
function daysInMonth(month, year) {
|
|
799
|
+
switch (month) {
|
|
800
|
+
case IYYAR:
|
|
801
|
+
case TAMUZ:
|
|
802
|
+
case ELUL:
|
|
803
|
+
case TEVET$1:
|
|
804
|
+
case ADAR_II$1:
|
|
805
|
+
return 29;
|
|
806
|
+
}
|
|
807
|
+
|
|
808
|
+
if (month === ADAR_I$1 && !isLeapYear(year) || month === CHESHVAN$1 && !longCheshvan(year) || month === KISLEV$1 && shortKislev(year)) {
|
|
809
|
+
return 29;
|
|
810
|
+
} else {
|
|
811
|
+
return 30;
|
|
812
|
+
}
|
|
813
|
+
}
|
|
814
|
+
/**
|
|
815
|
+
* Returns a transliterated string name of Hebrew month in year,
|
|
816
|
+
* for example 'Elul' or 'Cheshvan'.
|
|
817
|
+
* @private
|
|
818
|
+
* @param {number} month Hebrew month (e.g. months.TISHREI)
|
|
819
|
+
* @param {number} year Hebrew year
|
|
820
|
+
* @return {string}
|
|
821
|
+
*/
|
|
822
|
+
|
|
823
|
+
function getMonthName(month, year) {
|
|
824
|
+
if (typeof month !== 'number' || isNaN(month) || month < 1 || month > 14) {
|
|
825
|
+
throw new TypeError(`bad month argument ${month}`);
|
|
826
|
+
}
|
|
827
|
+
|
|
828
|
+
return monthNames[+isLeapYear(year)][month];
|
|
829
|
+
}
|
|
830
|
+
/**
|
|
831
|
+
* Days from sunday prior to start of Hebrew calendar to mean
|
|
832
|
+
* conjunction of Tishrei in Hebrew YEAR
|
|
833
|
+
* @private
|
|
834
|
+
* @param {number} year Hebrew year
|
|
835
|
+
* @return {number}
|
|
836
|
+
*/
|
|
837
|
+
|
|
838
|
+
function elapsedDays(year) {
|
|
839
|
+
const elapsed = edCache[year] = edCache[year] || elapsedDays0(year);
|
|
840
|
+
return elapsed;
|
|
841
|
+
}
|
|
842
|
+
/**
|
|
843
|
+
* Days from sunday prior to start of Hebrew calendar to mean
|
|
844
|
+
* conjunction of Tishrei in Hebrew YEAR
|
|
845
|
+
* @private
|
|
846
|
+
* @param {number} year Hebrew year
|
|
847
|
+
* @return {number}
|
|
848
|
+
*/
|
|
849
|
+
|
|
850
|
+
function elapsedDays0(year) {
|
|
851
|
+
const prevYear = year - 1;
|
|
852
|
+
const mElapsed = 235 * Math.floor(prevYear / 19) + // Months in complete 19 year lunar (Metonic) cycles so far
|
|
853
|
+
12 * (prevYear % 19) + // Regular months in this cycle
|
|
854
|
+
Math.floor((prevYear % 19 * 7 + 1) / 19); // Leap months this cycle
|
|
855
|
+
|
|
856
|
+
const pElapsed = 204 + 793 * (mElapsed % 1080);
|
|
857
|
+
const hElapsed = 5 + 12 * mElapsed + 793 * Math.floor(mElapsed / 1080) + Math.floor(pElapsed / 1080);
|
|
858
|
+
const parts = pElapsed % 1080 + 1080 * (hElapsed % 24);
|
|
859
|
+
const day = 1 + 29 * mElapsed + Math.floor(hElapsed / 24);
|
|
860
|
+
const altDay = day + (parts >= 19440 || 2 === day % 7 && parts >= 9924 && !isLeapYear(year) || 1 === day % 7 && parts >= 16789 && isLeapYear(prevYear));
|
|
861
|
+
return altDay + (altDay % 7 === 0 || altDay % 7 === 3 || altDay % 7 === 5);
|
|
862
|
+
}
|
|
863
|
+
/**
|
|
864
|
+
* Number of days in the hebrew YEAR.
|
|
865
|
+
* A common Hebrew calendar year can have a length of 353, 354 or 355 days
|
|
866
|
+
* A leap Hebrew calendar year can have a length of 383, 384 or 385 days
|
|
867
|
+
* @private
|
|
868
|
+
* @param {number} year Hebrew year
|
|
869
|
+
* @return {number}
|
|
870
|
+
*/
|
|
871
|
+
|
|
872
|
+
|
|
873
|
+
function daysInYear(year) {
|
|
874
|
+
return elapsedDays(year + 1) - elapsedDays(year);
|
|
875
|
+
}
|
|
876
|
+
/**
|
|
877
|
+
* true if Cheshvan is long in Hebrew year
|
|
878
|
+
* @private
|
|
879
|
+
* @param {number} year Hebrew year
|
|
880
|
+
* @return {boolean}
|
|
881
|
+
*/
|
|
882
|
+
|
|
883
|
+
function longCheshvan(year) {
|
|
884
|
+
return daysInYear(year) % 10 === 5;
|
|
885
|
+
}
|
|
886
|
+
/**
|
|
887
|
+
* true if Kislev is short in Hebrew year
|
|
888
|
+
* @private
|
|
889
|
+
* @param {number} year Hebrew year
|
|
890
|
+
* @return {boolean}
|
|
891
|
+
*/
|
|
892
|
+
|
|
893
|
+
function shortKislev(year) {
|
|
894
|
+
return daysInYear(year) % 10 === 3;
|
|
895
|
+
}
|
|
896
|
+
|
|
897
|
+
/*
|
|
898
|
+
Hebcal - A Jewish Calendar Generator
|
|
899
|
+
Copyright (c) 1994-2020 Danny Sadinoff
|
|
900
|
+
Portions copyright Eyal Schachter and Michael J. Radwin
|
|
901
|
+
|
|
902
|
+
https://github.com/hebcal/hebcal-es6
|
|
903
|
+
|
|
904
|
+
This program is free software; you can redistribute it and/or
|
|
905
|
+
modify it under the terms of the GNU General Public License
|
|
906
|
+
as published by the Free Software Foundation; either version 2
|
|
907
|
+
of the License, or (at your option) any later version.
|
|
908
|
+
|
|
909
|
+
This program is distributed in the hope that it will be useful,
|
|
910
|
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
911
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
912
|
+
GNU General Public License for more details.
|
|
913
|
+
|
|
914
|
+
You should have received a copy of the GNU General Public License
|
|
915
|
+
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
916
|
+
*/
|
|
634
917
|
|
|
635
918
|
function throwTypeError(msg) {
|
|
636
919
|
throw new TypeError(msg);
|
|
637
920
|
}
|
|
638
921
|
|
|
639
|
-
const edCache = Object.create(null);
|
|
640
|
-
const EPOCH = -1373428; // Avg year length in the cycle (19 solar years with 235 lunar months)
|
|
641
|
-
|
|
642
|
-
const AVG_HEBYEAR_DAYS = 365.24682220597794;
|
|
643
922
|
const UNITS_DAY = 'day';
|
|
644
923
|
const UNITS_WEEK = 'week';
|
|
645
924
|
const UNITS_MONTH = 'month';
|
|
@@ -716,19 +995,22 @@ class HDate {
|
|
|
716
995
|
* @type {number}
|
|
717
996
|
*/
|
|
718
997
|
|
|
719
|
-
|
|
998
|
+
year = parseInt(year, 10);
|
|
720
999
|
|
|
721
|
-
if (isNaN(
|
|
1000
|
+
if (isNaN(year)) {
|
|
722
1001
|
throw new TypeError(`HDate called with bad year argument: ${year}`);
|
|
723
1002
|
}
|
|
724
1003
|
|
|
1004
|
+
this.year = year;
|
|
725
1005
|
this.setMonth(month); // will throw if we can't parse
|
|
726
1006
|
|
|
727
|
-
|
|
1007
|
+
day = parseInt(day, 10);
|
|
728
1008
|
|
|
729
|
-
if (isNaN(
|
|
1009
|
+
if (isNaN(day)) {
|
|
730
1010
|
throw new TypeError(`HDate called with bad day argument: ${day}`);
|
|
731
1011
|
}
|
|
1012
|
+
|
|
1013
|
+
this.setDate(day);
|
|
732
1014
|
} else {
|
|
733
1015
|
// 0 arguments
|
|
734
1016
|
if (typeof day === 'undefined') {
|
|
@@ -736,13 +1018,13 @@ class HDate {
|
|
|
736
1018
|
} // 1 argument
|
|
737
1019
|
|
|
738
1020
|
|
|
739
|
-
const abs0 = typeof day === 'number' && !isNaN(day) ? day :
|
|
1021
|
+
const abs0 = typeof day === 'number' && !isNaN(day) ? day : isDate(day) ? greg2abs(day) : HDate.isHDate(day) ? {
|
|
740
1022
|
dd: day.day,
|
|
741
1023
|
mm: day.month,
|
|
742
1024
|
yy: day.year
|
|
743
1025
|
} : throwTypeError(`HDate called with bad argument: ${day}`);
|
|
744
1026
|
const isNumber = typeof abs0 === 'number';
|
|
745
|
-
const d = isNumber ?
|
|
1027
|
+
const d = isNumber ? abs2hebrew(abs0) : abs0;
|
|
746
1028
|
/**
|
|
747
1029
|
* @private
|
|
748
1030
|
* @type {number}
|
|
@@ -787,7 +1069,7 @@ class HDate {
|
|
|
787
1069
|
|
|
788
1070
|
|
|
789
1071
|
isLeapYear() {
|
|
790
|
-
return
|
|
1072
|
+
return isLeapYear(this.year);
|
|
791
1073
|
}
|
|
792
1074
|
/**
|
|
793
1075
|
* Gets the Hebrew month (1=NISAN, 7=TISHREI) of this Hebrew date
|
|
@@ -805,7 +1087,7 @@ class HDate {
|
|
|
805
1087
|
|
|
806
1088
|
|
|
807
1089
|
getTishreiMonth() {
|
|
808
|
-
const nummonths =
|
|
1090
|
+
const nummonths = monthsInYear(this.getFullYear());
|
|
809
1091
|
return (this.getMonth() + nummonths - 6) % nummonths || nummonths;
|
|
810
1092
|
}
|
|
811
1093
|
/**
|
|
@@ -815,7 +1097,7 @@ class HDate {
|
|
|
815
1097
|
|
|
816
1098
|
|
|
817
1099
|
daysInMonth() {
|
|
818
|
-
return
|
|
1100
|
+
return daysInMonth(this.getMonth(), this.getFullYear());
|
|
819
1101
|
}
|
|
820
1102
|
/**
|
|
821
1103
|
* Gets the day within the month (1-30)
|
|
@@ -881,7 +1163,7 @@ class HDate {
|
|
|
881
1163
|
|
|
882
1164
|
|
|
883
1165
|
greg() {
|
|
884
|
-
return
|
|
1166
|
+
return abs2greg(this.abs());
|
|
885
1167
|
}
|
|
886
1168
|
/**
|
|
887
1169
|
* Returns R.D. (Rata Die) fixed days.
|
|
@@ -894,7 +1176,7 @@ class HDate {
|
|
|
894
1176
|
|
|
895
1177
|
abs() {
|
|
896
1178
|
if (typeof this.abs0 !== 'number') {
|
|
897
|
-
this.abs0 =
|
|
1179
|
+
this.abs0 = hebrew2abs(this.year, this.month, this.day);
|
|
898
1180
|
}
|
|
899
1181
|
|
|
900
1182
|
return this.abs0;
|
|
@@ -911,51 +1193,7 @@ class HDate {
|
|
|
911
1193
|
|
|
912
1194
|
|
|
913
1195
|
static hebrew2abs(year, month, day) {
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
if (month < TISHREI) {
|
|
917
|
-
for (let m = TISHREI; m <= HDate.monthsInYear(year); m++) {
|
|
918
|
-
tempabs += HDate.daysInMonth(m, year);
|
|
919
|
-
}
|
|
920
|
-
|
|
921
|
-
for (let m = NISAN$1; m < month; m++) {
|
|
922
|
-
tempabs += HDate.daysInMonth(m, year);
|
|
923
|
-
}
|
|
924
|
-
} else {
|
|
925
|
-
for (let m = TISHREI; m < month; m++) {
|
|
926
|
-
tempabs += HDate.daysInMonth(m, year);
|
|
927
|
-
}
|
|
928
|
-
}
|
|
929
|
-
|
|
930
|
-
return EPOCH + HDate.elapsedDays(year) + tempabs - 1;
|
|
931
|
-
}
|
|
932
|
-
/**
|
|
933
|
-
* @private
|
|
934
|
-
* @param {number} year
|
|
935
|
-
* @return {number}
|
|
936
|
-
*/
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
static newYear(year) {
|
|
940
|
-
return EPOCH + HDate.elapsedDays(year) + HDate.newYearDelay(year);
|
|
941
|
-
}
|
|
942
|
-
/**
|
|
943
|
-
* @private
|
|
944
|
-
* @param {number} year
|
|
945
|
-
* @return {number}
|
|
946
|
-
*/
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
static newYearDelay(year) {
|
|
950
|
-
const ny1 = HDate.elapsedDays(year);
|
|
951
|
-
const ny2 = HDate.elapsedDays(year + 1);
|
|
952
|
-
|
|
953
|
-
if (ny2 - ny1 === 356) {
|
|
954
|
-
return 2;
|
|
955
|
-
} else {
|
|
956
|
-
const ny0 = HDate.elapsedDays(year - 1);
|
|
957
|
-
return ny1 - ny0 === 382 ? 1 : 0;
|
|
958
|
-
}
|
|
1196
|
+
return hebrew2abs(year, month, day);
|
|
959
1197
|
}
|
|
960
1198
|
/**
|
|
961
1199
|
* Converts absolute R.D. days to Hebrew date
|
|
@@ -966,31 +1204,7 @@ class HDate {
|
|
|
966
1204
|
|
|
967
1205
|
|
|
968
1206
|
static abs2hebrew(abs) {
|
|
969
|
-
|
|
970
|
-
throw new TypeError(`invalid parameter to abs2hebrew ${abs}`);
|
|
971
|
-
}
|
|
972
|
-
|
|
973
|
-
abs = Math.trunc(abs); // first, quickly approximate year
|
|
974
|
-
|
|
975
|
-
let year = Math.floor((abs - EPOCH) / AVG_HEBYEAR_DAYS);
|
|
976
|
-
|
|
977
|
-
while (HDate.newYear(year) <= abs) {
|
|
978
|
-
++year;
|
|
979
|
-
}
|
|
980
|
-
|
|
981
|
-
--year;
|
|
982
|
-
let month = abs < HDate.hebrew2abs(year, 1, 1) ? 7 : 1;
|
|
983
|
-
|
|
984
|
-
while (abs > HDate.hebrew2abs(year, month, HDate.daysInMonth(month, year))) {
|
|
985
|
-
++month;
|
|
986
|
-
}
|
|
987
|
-
|
|
988
|
-
const day = 1 + abs - HDate.hebrew2abs(year, month, 1);
|
|
989
|
-
return {
|
|
990
|
-
yy: year,
|
|
991
|
-
mm: month,
|
|
992
|
-
dd: day
|
|
993
|
-
};
|
|
1207
|
+
return abs2hebrew(abs);
|
|
994
1208
|
}
|
|
995
1209
|
/**
|
|
996
1210
|
* Returns a transliterated Hebrew month name, e.g. `'Elul'` or `'Cheshvan'`.
|
|
@@ -999,7 +1213,7 @@ class HDate {
|
|
|
999
1213
|
|
|
1000
1214
|
|
|
1001
1215
|
getMonthName() {
|
|
1002
|
-
return
|
|
1216
|
+
return getMonthName(this.getMonth(), this.getFullYear());
|
|
1003
1217
|
}
|
|
1004
1218
|
/**
|
|
1005
1219
|
* Renders this Hebrew date as a translated or transliterated string,
|
|
@@ -1305,7 +1519,7 @@ class HDate {
|
|
|
1305
1519
|
|
|
1306
1520
|
|
|
1307
1521
|
static isLeapYear(year) {
|
|
1308
|
-
return (
|
|
1522
|
+
return isLeapYear(year);
|
|
1309
1523
|
}
|
|
1310
1524
|
/**
|
|
1311
1525
|
* Number of months in this Hebrew year (either 12 or 13 depending on leap year)
|
|
@@ -1315,7 +1529,7 @@ class HDate {
|
|
|
1315
1529
|
|
|
1316
1530
|
|
|
1317
1531
|
static monthsInYear(year) {
|
|
1318
|
-
return
|
|
1532
|
+
return monthsInYear(year);
|
|
1319
1533
|
}
|
|
1320
1534
|
/**
|
|
1321
1535
|
* Number of days in Hebrew month in a given year (29 or 30)
|
|
@@ -1326,11 +1540,7 @@ class HDate {
|
|
|
1326
1540
|
|
|
1327
1541
|
|
|
1328
1542
|
static daysInMonth(month, year) {
|
|
1329
|
-
|
|
1330
|
-
return 29;
|
|
1331
|
-
} else {
|
|
1332
|
-
return 30;
|
|
1333
|
-
}
|
|
1543
|
+
return daysInMonth(month, year);
|
|
1334
1544
|
}
|
|
1335
1545
|
/**
|
|
1336
1546
|
* Returns a transliterated string name of Hebrew month in year,
|
|
@@ -1342,11 +1552,7 @@ class HDate {
|
|
|
1342
1552
|
|
|
1343
1553
|
|
|
1344
1554
|
static getMonthName(month, year) {
|
|
1345
|
-
|
|
1346
|
-
throw new TypeError(`bad month argument ${month}`);
|
|
1347
|
-
}
|
|
1348
|
-
|
|
1349
|
-
return monthNames[+HDate.isLeapYear(year)][month];
|
|
1555
|
+
return getMonthName(month, year);
|
|
1350
1556
|
}
|
|
1351
1557
|
/**
|
|
1352
1558
|
* Returns the Hebrew month number (NISAN=1, TISHREI=7)
|
|
@@ -1356,43 +1562,17 @@ class HDate {
|
|
|
1356
1562
|
|
|
1357
1563
|
|
|
1358
1564
|
static monthNum(month) {
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
/**
|
|
1364
|
-
* Days from sunday prior to start of Hebrew calendar to mean
|
|
1365
|
-
* conjunction of Tishrei in Hebrew YEAR
|
|
1366
|
-
* @param {number} year Hebrew year
|
|
1367
|
-
* @return {number}
|
|
1368
|
-
*/
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
static elapsedDays(year) {
|
|
1372
|
-
const elapsed = edCache[year] = edCache[year] || HDate.elapsedDays0(year);
|
|
1373
|
-
return elapsed;
|
|
1374
|
-
}
|
|
1375
|
-
/**
|
|
1376
|
-
* Days from sunday prior to start of Hebrew calendar to mean
|
|
1377
|
-
* conjunction of Tishrei in Hebrew YEAR
|
|
1378
|
-
* @private
|
|
1379
|
-
* @param {number} year Hebrew year
|
|
1380
|
-
* @return {number}
|
|
1381
|
-
*/
|
|
1382
|
-
|
|
1565
|
+
if (typeof month === 'number') {
|
|
1566
|
+
if (isNaN(month) || month > 14) {
|
|
1567
|
+
throw new RangeError(`Invalid month number: ${month}`);
|
|
1568
|
+
}
|
|
1383
1569
|
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
const mElapsed = 235 * Math.floor(prevYear / 19) + // Months in complete 19 year lunar (Metonic) cycles so far
|
|
1387
|
-
12 * (prevYear % 19) + // Regular months in this cycle
|
|
1388
|
-
Math.floor((prevYear % 19 * 7 + 1) / 19); // Leap months this cycle
|
|
1570
|
+
return month;
|
|
1571
|
+
}
|
|
1389
1572
|
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
const day = 1 + 29 * mElapsed + Math.floor(hElapsed / 24);
|
|
1394
|
-
const altDay = day + (parts >= 19440 || 2 == day % 7 && parts >= 9924 && !HDate.isLeapYear(year) || 1 == day % 7 && parts >= 16789 && HDate.isLeapYear(prevYear));
|
|
1395
|
-
return altDay + (altDay % 7 === 0 || altDay % 7 == 3 || altDay % 7 == 5);
|
|
1573
|
+
return month.charCodeAt(0) >= 48 && month.charCodeAt(0) <= 57 ?
|
|
1574
|
+
/* number */
|
|
1575
|
+
parseInt(month, 10) : HDate.monthFromName(month);
|
|
1396
1576
|
}
|
|
1397
1577
|
/**
|
|
1398
1578
|
* Number of days in the hebrew YEAR
|
|
@@ -1402,7 +1582,7 @@ class HDate {
|
|
|
1402
1582
|
|
|
1403
1583
|
|
|
1404
1584
|
static daysInYear(year) {
|
|
1405
|
-
return
|
|
1585
|
+
return daysInYear(year);
|
|
1406
1586
|
}
|
|
1407
1587
|
/**
|
|
1408
1588
|
* true if Cheshvan is long in Hebrew year
|
|
@@ -1412,7 +1592,7 @@ class HDate {
|
|
|
1412
1592
|
|
|
1413
1593
|
|
|
1414
1594
|
static longCheshvan(year) {
|
|
1415
|
-
return
|
|
1595
|
+
return longCheshvan(year);
|
|
1416
1596
|
}
|
|
1417
1597
|
/**
|
|
1418
1598
|
* true if Kislev is short in Hebrew year
|
|
@@ -1422,7 +1602,7 @@ class HDate {
|
|
|
1422
1602
|
|
|
1423
1603
|
|
|
1424
1604
|
static shortKislev(year) {
|
|
1425
|
-
return
|
|
1605
|
+
return shortKislev(year);
|
|
1426
1606
|
}
|
|
1427
1607
|
/**
|
|
1428
1608
|
* Converts Hebrew month string name to numeric
|
|
@@ -1432,7 +1612,14 @@ class HDate {
|
|
|
1432
1612
|
|
|
1433
1613
|
|
|
1434
1614
|
static monthFromName(monthName) {
|
|
1435
|
-
if (typeof monthName === 'number')
|
|
1615
|
+
if (typeof monthName === 'number') {
|
|
1616
|
+
if (isNaN(monthName) || monthName < 1 || monthName > 14) {
|
|
1617
|
+
throw new RangeError(`Invalid month name: ${monthName}`);
|
|
1618
|
+
}
|
|
1619
|
+
|
|
1620
|
+
return monthName;
|
|
1621
|
+
}
|
|
1622
|
+
|
|
1436
1623
|
const c = monthName.toLowerCase();
|
|
1437
1624
|
/*
|
|
1438
1625
|
the Hebrew months are unique to their second letter
|
|
@@ -1464,41 +1651,41 @@ class HDate {
|
|
|
1464
1651
|
/* this catches "november" */
|
|
1465
1652
|
}
|
|
1466
1653
|
|
|
1467
|
-
return NISAN
|
|
1654
|
+
return months.NISAN;
|
|
1468
1655
|
|
|
1469
1656
|
case 'i':
|
|
1470
|
-
return IYYAR;
|
|
1657
|
+
return months.IYYAR;
|
|
1471
1658
|
|
|
1472
1659
|
case 'e':
|
|
1473
|
-
return ELUL;
|
|
1660
|
+
return months.ELUL;
|
|
1474
1661
|
|
|
1475
1662
|
case 'c':
|
|
1476
1663
|
case 'ח':
|
|
1477
|
-
return CHESHVAN
|
|
1664
|
+
return months.CHESHVAN;
|
|
1478
1665
|
|
|
1479
1666
|
case 'k':
|
|
1480
1667
|
case 'כ':
|
|
1481
|
-
return KISLEV
|
|
1668
|
+
return months.KISLEV;
|
|
1482
1669
|
|
|
1483
1670
|
case 's':
|
|
1484
1671
|
switch (c[1]) {
|
|
1485
1672
|
case 'i':
|
|
1486
|
-
return SIVAN;
|
|
1673
|
+
return months.SIVAN;
|
|
1487
1674
|
|
|
1488
1675
|
case 'h':
|
|
1489
|
-
return SHVAT
|
|
1676
|
+
return months.SHVAT;
|
|
1490
1677
|
}
|
|
1491
1678
|
|
|
1492
1679
|
case 't':
|
|
1493
1680
|
switch (c[1]) {
|
|
1494
1681
|
case 'a':
|
|
1495
|
-
return TAMUZ;
|
|
1682
|
+
return months.TAMUZ;
|
|
1496
1683
|
|
|
1497
1684
|
case 'i':
|
|
1498
|
-
return TISHREI;
|
|
1685
|
+
return months.TISHREI;
|
|
1499
1686
|
|
|
1500
1687
|
case 'e':
|
|
1501
|
-
return TEVET
|
|
1688
|
+
return months.TEVET;
|
|
1502
1689
|
}
|
|
1503
1690
|
|
|
1504
1691
|
break;
|
|
@@ -1506,46 +1693,46 @@ class HDate {
|
|
|
1506
1693
|
case 'a':
|
|
1507
1694
|
switch (c[1]) {
|
|
1508
1695
|
case 'v':
|
|
1509
|
-
return AV;
|
|
1696
|
+
return months.AV;
|
|
1510
1697
|
|
|
1511
1698
|
case 'd':
|
|
1512
1699
|
if (/(1|[^i]i|a|א)$/i.test(monthName)) {
|
|
1513
|
-
return ADAR_I
|
|
1700
|
+
return months.ADAR_I;
|
|
1514
1701
|
}
|
|
1515
1702
|
|
|
1516
|
-
return ADAR_II
|
|
1703
|
+
return months.ADAR_II;
|
|
1517
1704
|
// else assume sheini
|
|
1518
1705
|
}
|
|
1519
1706
|
|
|
1520
1707
|
break;
|
|
1521
1708
|
|
|
1522
1709
|
case 'ס':
|
|
1523
|
-
return SIVAN;
|
|
1710
|
+
return months.SIVAN;
|
|
1524
1711
|
|
|
1525
1712
|
case 'ט':
|
|
1526
|
-
return TEVET
|
|
1713
|
+
return months.TEVET;
|
|
1527
1714
|
|
|
1528
1715
|
case 'ש':
|
|
1529
|
-
return SHVAT
|
|
1716
|
+
return months.SHVAT;
|
|
1530
1717
|
|
|
1531
1718
|
case 'א':
|
|
1532
1719
|
switch (c[1]) {
|
|
1533
1720
|
case 'ב':
|
|
1534
|
-
return AV;
|
|
1721
|
+
return months.AV;
|
|
1535
1722
|
|
|
1536
1723
|
case 'ד':
|
|
1537
1724
|
if (/(1|[^i]i|a|א)$/i.test(monthName)) {
|
|
1538
|
-
return ADAR_I
|
|
1725
|
+
return months.ADAR_I;
|
|
1539
1726
|
}
|
|
1540
1727
|
|
|
1541
|
-
return ADAR_II
|
|
1728
|
+
return months.ADAR_II;
|
|
1542
1729
|
// else assume sheini
|
|
1543
1730
|
|
|
1544
1731
|
case 'י':
|
|
1545
|
-
return IYYAR;
|
|
1732
|
+
return months.IYYAR;
|
|
1546
1733
|
|
|
1547
1734
|
case 'ל':
|
|
1548
|
-
return ELUL;
|
|
1735
|
+
return months.ELUL;
|
|
1549
1736
|
}
|
|
1550
1737
|
|
|
1551
1738
|
break;
|
|
@@ -1553,10 +1740,10 @@ class HDate {
|
|
|
1553
1740
|
case 'ת':
|
|
1554
1741
|
switch (c[1]) {
|
|
1555
1742
|
case 'מ':
|
|
1556
|
-
return TAMUZ;
|
|
1743
|
+
return months.TAMUZ;
|
|
1557
1744
|
|
|
1558
1745
|
case 'ש':
|
|
1559
|
-
return TISHREI;
|
|
1746
|
+
return months.TISHREI;
|
|
1560
1747
|
}
|
|
1561
1748
|
|
|
1562
1749
|
break;
|
|
@@ -1607,21 +1794,21 @@ function fix(date) {
|
|
|
1607
1794
|
|
|
1608
1795
|
function fixDate(date) {
|
|
1609
1796
|
if (date.day < 1) {
|
|
1610
|
-
if (date.month == TISHREI) {
|
|
1797
|
+
if (date.month == months.TISHREI) {
|
|
1611
1798
|
date.year -= 1;
|
|
1612
1799
|
}
|
|
1613
1800
|
|
|
1614
|
-
date.day +=
|
|
1801
|
+
date.day += daysInMonth(date.month, date.year);
|
|
1615
1802
|
date.month -= 1;
|
|
1616
1803
|
fix(date);
|
|
1617
1804
|
}
|
|
1618
1805
|
|
|
1619
|
-
if (date.day >
|
|
1620
|
-
if (date.month
|
|
1806
|
+
if (date.day > daysInMonth(date.month, date.year)) {
|
|
1807
|
+
if (date.month === months.ELUL) {
|
|
1621
1808
|
date.year += 1;
|
|
1622
1809
|
}
|
|
1623
1810
|
|
|
1624
|
-
date.day -=
|
|
1811
|
+
date.day -= daysInMonth(date.month, date.year);
|
|
1625
1812
|
date.month += 1;
|
|
1626
1813
|
fix(date);
|
|
1627
1814
|
}
|
|
@@ -1635,16 +1822,16 @@ function fixDate(date) {
|
|
|
1635
1822
|
|
|
1636
1823
|
|
|
1637
1824
|
function fixMonth(date) {
|
|
1638
|
-
if (date.month
|
|
1825
|
+
if (date.month === months.ADAR_II && !date.isLeapYear()) {
|
|
1639
1826
|
date.month -= 1; // to Adar I
|
|
1640
1827
|
|
|
1641
1828
|
fix(date);
|
|
1642
1829
|
} else if (date.month < 1) {
|
|
1643
|
-
date.month +=
|
|
1830
|
+
date.month += monthsInYear(date.year);
|
|
1644
1831
|
date.year -= 1;
|
|
1645
1832
|
fix(date);
|
|
1646
|
-
} else if (date.month >
|
|
1647
|
-
date.month -=
|
|
1833
|
+
} else if (date.month > monthsInYear(date.year)) {
|
|
1834
|
+
date.month -= monthsInYear(date.year);
|
|
1648
1835
|
date.year += 1;
|
|
1649
1836
|
fix(date);
|
|
1650
1837
|
}
|
|
@@ -1691,18 +1878,18 @@ function getYahrzeit_(hyear, gdate) {
|
|
|
1691
1878
|
return undefined;
|
|
1692
1879
|
}
|
|
1693
1880
|
|
|
1694
|
-
if (hDeath.mm == CHESHVAN && hDeath.dd == 30 && !
|
|
1881
|
+
if (hDeath.mm == CHESHVAN && hDeath.dd == 30 && !longCheshvan(hDeath.yy + 1)) {
|
|
1695
1882
|
// If it's Heshvan 30 it depends on the first anniversary;
|
|
1696
1883
|
// if that was not Heshvan 30, use the day before Kislev 1.
|
|
1697
|
-
hDeath =
|
|
1698
|
-
} else if (hDeath.mm == KISLEV && hDeath.dd == 30 &&
|
|
1884
|
+
hDeath = abs2hebrew(hebrew2abs(hyear, KISLEV, 1) - 1);
|
|
1885
|
+
} else if (hDeath.mm == KISLEV && hDeath.dd == 30 && shortKislev(hDeath.yy + 1)) {
|
|
1699
1886
|
// If it's Kislev 30 it depends on the first anniversary;
|
|
1700
1887
|
// if that was not Kislev 30, use the day before Teveth 1.
|
|
1701
|
-
hDeath =
|
|
1888
|
+
hDeath = abs2hebrew(hebrew2abs(hyear, TEVET, 1) - 1);
|
|
1702
1889
|
} else if (hDeath.mm == ADAR_II) {
|
|
1703
1890
|
// If it's Adar II, use the same day in last month of year (Adar or Adar II).
|
|
1704
|
-
hDeath.mm =
|
|
1705
|
-
} else if (hDeath.mm == ADAR_I && hDeath.dd == 30 && !
|
|
1891
|
+
hDeath.mm = monthsInYear(hyear);
|
|
1892
|
+
} else if (hDeath.mm == ADAR_I && hDeath.dd == 30 && !isLeapYear(hyear)) {
|
|
1706
1893
|
// If it's the 30th in Adar I and year is not a leap year
|
|
1707
1894
|
// (so Adar has only 29 days), use the last day in Shevat.
|
|
1708
1895
|
hDeath.dd = 30;
|
|
@@ -1711,10 +1898,10 @@ function getYahrzeit_(hyear, gdate) {
|
|
|
1711
1898
|
// advance day to rosh chodesh if needed
|
|
1712
1899
|
|
|
1713
1900
|
|
|
1714
|
-
if (hDeath.mm == CHESHVAN && hDeath.dd == 30 && !
|
|
1901
|
+
if (hDeath.mm == CHESHVAN && hDeath.dd == 30 && !longCheshvan(hyear)) {
|
|
1715
1902
|
hDeath.mm = KISLEV;
|
|
1716
1903
|
hDeath.dd = 1;
|
|
1717
|
-
} else if (hDeath.mm == KISLEV && hDeath.dd == 30 &&
|
|
1904
|
+
} else if (hDeath.mm == KISLEV && hDeath.dd == 30 && shortKislev(hyear)) {
|
|
1718
1905
|
hDeath.mm = TEVET;
|
|
1719
1906
|
hDeath.dd = 1;
|
|
1720
1907
|
}
|
|
@@ -1737,19 +1924,19 @@ function getBirthdayOrAnniversary_(hyear, gdate) {
|
|
|
1737
1924
|
return undefined;
|
|
1738
1925
|
}
|
|
1739
1926
|
|
|
1740
|
-
const isOrigLeap =
|
|
1927
|
+
const isOrigLeap = isLeapYear(origYear);
|
|
1741
1928
|
let month = orig.getMonth();
|
|
1742
1929
|
let day = orig.getDate();
|
|
1743
1930
|
|
|
1744
1931
|
if (month == ADAR_I && !isOrigLeap || month == ADAR_II && isOrigLeap) {
|
|
1745
|
-
month =
|
|
1746
|
-
} else if (month == CHESHVAN && day == 30 && !
|
|
1932
|
+
month = monthsInYear(hyear);
|
|
1933
|
+
} else if (month == CHESHVAN && day == 30 && !longCheshvan(hyear)) {
|
|
1747
1934
|
month = KISLEV;
|
|
1748
1935
|
day = 1;
|
|
1749
|
-
} else if (month == KISLEV && day == 30 &&
|
|
1936
|
+
} else if (month == KISLEV && day == 30 && shortKislev(hyear)) {
|
|
1750
1937
|
month = TEVET;
|
|
1751
1938
|
day = 1;
|
|
1752
|
-
} else if (month == ADAR_I && day == 30 && isOrigLeap && !
|
|
1939
|
+
} else if (month == ADAR_I && day == 30 && isOrigLeap && !isLeapYear(hyear)) {
|
|
1753
1940
|
month = NISAN;
|
|
1754
1941
|
day = 1;
|
|
1755
1942
|
}
|
|
@@ -1757,7 +1944,7 @@ function getBirthdayOrAnniversary_(hyear, gdate) {
|
|
|
1757
1944
|
return new HDate(day, month, hyear);
|
|
1758
1945
|
}
|
|
1759
1946
|
|
|
1760
|
-
const version="3.
|
|
1947
|
+
const version="3.38.2";
|
|
1761
1948
|
|
|
1762
1949
|
const headers={"plural-forms":"nplurals=2; plural=(n > 1);",language:"he"};const contexts={"":{Adar:["אַדָר"],"Adar I":["אַדָר א׳"],"Adar II":["אַדָר ב׳"],Av:["אָב"],Cheshvan:["חֶשְׁוָן"],Elul:["אֱלוּל"],Iyyar:["אִיָיר"],Kislev:["כִּסְלֵו"],Nisan:["נִיסָן"],"Sh'vat":["שְׁבָט"],Sivan:["סִיוָן"],Tamuz:["תַּמּוּז"],Tevet:["טֵבֵת"],Tishrei:["תִשְׁרֵי"]}};var poHeMin = {headers:headers,contexts:contexts};
|
|
1763
1950
|
|