@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-bundle.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! @hebcal/core v3.
|
|
1
|
+
/*! @hebcal/core v3.38.2 */
|
|
2
2
|
var hebcal = (function (exports) {
|
|
3
3
|
'use strict';
|
|
4
4
|
|
|
@@ -218,26 +218,15 @@ function _defineProperty(obj, key, value) {
|
|
|
218
218
|
}
|
|
219
219
|
|
|
220
220
|
/*
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
Portions copyright Eyal Schachter and Michael J. Radwin
|
|
224
|
-
|
|
225
|
-
https://github.com/hebcal/hebcal-es6
|
|
226
|
-
|
|
227
|
-
This program is free software; you can redistribute it and/or
|
|
228
|
-
modify it under the terms of the GNU General Public License
|
|
229
|
-
as published by the Free Software Foundation; either version 2
|
|
230
|
-
of the License, or (at your option) any later version.
|
|
221
|
+
* More minimal greg routines
|
|
222
|
+
*/
|
|
231
223
|
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
GNU General Public License for more details.
|
|
224
|
+
/** @private */
|
|
225
|
+
var lengths = [0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
|
|
226
|
+
/** @private */
|
|
236
227
|
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
*/
|
|
240
|
-
var 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]];
|
|
228
|
+
var monthLengths = [lengths, lengths.slice()];
|
|
229
|
+
monthLengths[1][2] = 29;
|
|
241
230
|
/**
|
|
242
231
|
* @private
|
|
243
232
|
* @param {number} x
|
|
@@ -259,9 +248,148 @@ function quotient(x, y) {
|
|
|
259
248
|
return Math.floor(x / y);
|
|
260
249
|
}
|
|
261
250
|
/**
|
|
262
|
-
* Gregorian
|
|
251
|
+
* Returns true if the Gregorian year is a leap year
|
|
252
|
+
* @private
|
|
253
|
+
* @param {number} year Gregorian year
|
|
254
|
+
* @return {boolean}
|
|
255
|
+
*/
|
|
256
|
+
|
|
257
|
+
|
|
258
|
+
function isLeapYear$1(year) {
|
|
259
|
+
return !(year % 4) && (!!(year % 100) || !(year % 400));
|
|
260
|
+
}
|
|
261
|
+
/**
|
|
262
|
+
* Number of days in the Gregorian month for given year
|
|
263
|
+
* @private
|
|
264
|
+
* @param {number} month Gregorian month (1=January, 12=December)
|
|
265
|
+
* @param {number} year Gregorian year
|
|
266
|
+
* @return {number}
|
|
267
|
+
*/
|
|
268
|
+
|
|
269
|
+
function daysInMonth$1(month, year) {
|
|
270
|
+
// 1 based months
|
|
271
|
+
return monthLengths[+isLeapYear$1(year)][month];
|
|
272
|
+
}
|
|
273
|
+
/**
|
|
274
|
+
* Returns true if the object is a Javascript Date
|
|
275
|
+
* @private
|
|
276
|
+
* @param {Object} obj
|
|
277
|
+
* @return {boolean}
|
|
263
278
|
*/
|
|
264
279
|
|
|
280
|
+
function isDate(obj) {
|
|
281
|
+
return _typeof(obj) === 'object' && Date.prototype === obj.__proto__;
|
|
282
|
+
}
|
|
283
|
+
/**
|
|
284
|
+
* Returns number of days since January 1 of that year
|
|
285
|
+
* @private
|
|
286
|
+
* @param {Date} date Gregorian date
|
|
287
|
+
* @return {number}
|
|
288
|
+
*/
|
|
289
|
+
|
|
290
|
+
function dayOfYear(date) {
|
|
291
|
+
if (!isDate(date)) {
|
|
292
|
+
throw new TypeError("Argument not a Date: ".concat(date));
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
var doy = date.getDate() + 31 * date.getMonth();
|
|
296
|
+
|
|
297
|
+
if (date.getMonth() > 1) {
|
|
298
|
+
// FEB
|
|
299
|
+
doy -= Math.floor((4 * (date.getMonth() + 1) + 23) / 10);
|
|
300
|
+
|
|
301
|
+
if (isLeapYear$1(date.getFullYear())) {
|
|
302
|
+
doy++;
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
return doy;
|
|
307
|
+
}
|
|
308
|
+
/**
|
|
309
|
+
* Converts Gregorian date to absolute R.D. (Rata Die) days
|
|
310
|
+
* @private
|
|
311
|
+
* @param {Date} date Gregorian date
|
|
312
|
+
* @return {number}
|
|
313
|
+
*/
|
|
314
|
+
|
|
315
|
+
function greg2abs(date) {
|
|
316
|
+
if (!isDate(date)) {
|
|
317
|
+
throw new TypeError("Argument not a Date: ".concat(date));
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
var year = date.getFullYear() - 1;
|
|
321
|
+
return dayOfYear(date) + // days this year
|
|
322
|
+
365 * year + ( // + days in prior years
|
|
323
|
+
Math.floor(year / 4) - // + Julian Leap years
|
|
324
|
+
Math.floor(year / 100) + // - century years
|
|
325
|
+
Math.floor(year / 400)); // + Gregorian leap years
|
|
326
|
+
}
|
|
327
|
+
/**
|
|
328
|
+
* @private
|
|
329
|
+
* @param {number} abs - R.D. number of days
|
|
330
|
+
* @return {number}
|
|
331
|
+
*/
|
|
332
|
+
|
|
333
|
+
function yearFromFixed(abs) {
|
|
334
|
+
var l0 = abs - 1;
|
|
335
|
+
var n400 = quotient(l0, 146097);
|
|
336
|
+
var d1 = mod(l0, 146097);
|
|
337
|
+
var n100 = quotient(d1, 36524);
|
|
338
|
+
var d2 = mod(d1, 36524);
|
|
339
|
+
var n4 = quotient(d2, 1461);
|
|
340
|
+
var d3 = mod(d2, 1461);
|
|
341
|
+
var n1 = quotient(d3, 365);
|
|
342
|
+
var year = 400 * n400 + 100 * n100 + 4 * n4 + n1;
|
|
343
|
+
return n100 != 4 && n1 != 4 ? year + 1 : year;
|
|
344
|
+
}
|
|
345
|
+
/**
|
|
346
|
+
* @private
|
|
347
|
+
* @param {number} year
|
|
348
|
+
* @param {number} month
|
|
349
|
+
* @param {number} day
|
|
350
|
+
* @return {number}
|
|
351
|
+
*/
|
|
352
|
+
|
|
353
|
+
|
|
354
|
+
function toFixed(year, month, day) {
|
|
355
|
+
var py = year - 1;
|
|
356
|
+
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;
|
|
357
|
+
}
|
|
358
|
+
/**
|
|
359
|
+
* Converts from Rata Die (R.D. number) to Gregorian date.
|
|
360
|
+
* See the footnote on page 384 of ``Calendrical Calculations, Part II:
|
|
361
|
+
* Three Historical Calendars'' by E. M. Reingold, N. Dershowitz, and S. M.
|
|
362
|
+
* Clamen, Software--Practice and Experience, Volume 23, Number 4
|
|
363
|
+
* (April, 1993), pages 383-404 for an explanation.
|
|
364
|
+
* @private
|
|
365
|
+
* @param {number} abs - R.D. number of days
|
|
366
|
+
* @return {Date}
|
|
367
|
+
*/
|
|
368
|
+
|
|
369
|
+
|
|
370
|
+
function abs2greg(abs) {
|
|
371
|
+
if (typeof abs !== 'number') {
|
|
372
|
+
throw new TypeError("Argument not a Number: ".concat(abs));
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
abs = Math.trunc(abs);
|
|
376
|
+
var year = yearFromFixed(abs);
|
|
377
|
+
var priorDays = abs - toFixed(year, 1, 1);
|
|
378
|
+
var correction = abs < toFixed(year, 3, 1) ? 0 : isLeapYear$1(year) ? 1 : 2;
|
|
379
|
+
var month = quotient(12 * (priorDays + correction) + 373, 367);
|
|
380
|
+
var day = abs - toFixed(year, month, 1) + 1;
|
|
381
|
+
var dt = new Date(year, month - 1, day);
|
|
382
|
+
|
|
383
|
+
if (year < 100 && year >= 0) {
|
|
384
|
+
dt.setFullYear(year);
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
return dt;
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
/**
|
|
391
|
+
* Gregorian date helper functions.
|
|
392
|
+
*/
|
|
265
393
|
|
|
266
394
|
var greg = /*#__PURE__*/function () {
|
|
267
395
|
function greg() {
|
|
@@ -283,7 +411,7 @@ var greg = /*#__PURE__*/function () {
|
|
|
283
411
|
* @return {boolean}
|
|
284
412
|
*/
|
|
285
413
|
function isLeapYear(year) {
|
|
286
|
-
return
|
|
414
|
+
return isLeapYear$1(year);
|
|
287
415
|
}
|
|
288
416
|
/**
|
|
289
417
|
* Number of days in the Gregorian month for given year
|
|
@@ -295,8 +423,7 @@ var greg = /*#__PURE__*/function () {
|
|
|
295
423
|
}, {
|
|
296
424
|
key: "daysInMonth",
|
|
297
425
|
value: function daysInMonth(month, year) {
|
|
298
|
-
|
|
299
|
-
return monthLengths[+this.isLeapYear(year)][month];
|
|
426
|
+
return daysInMonth$1(month, year);
|
|
300
427
|
}
|
|
301
428
|
/**
|
|
302
429
|
* Returns true if the object is a Javascript Date
|
|
@@ -306,8 +433,8 @@ var greg = /*#__PURE__*/function () {
|
|
|
306
433
|
|
|
307
434
|
}, {
|
|
308
435
|
key: "isDate",
|
|
309
|
-
value: function isDate(obj) {
|
|
310
|
-
return
|
|
436
|
+
value: function isDate$1(obj) {
|
|
437
|
+
return isDate(obj);
|
|
311
438
|
}
|
|
312
439
|
/**
|
|
313
440
|
* Returns number of days since January 1 of that year
|
|
@@ -317,23 +444,8 @@ var greg = /*#__PURE__*/function () {
|
|
|
317
444
|
|
|
318
445
|
}, {
|
|
319
446
|
key: "dayOfYear",
|
|
320
|
-
value: function dayOfYear(date) {
|
|
321
|
-
|
|
322
|
-
throw new TypeError('Argument to greg.dayOfYear not a Date');
|
|
323
|
-
}
|
|
324
|
-
|
|
325
|
-
var doy = date.getDate() + 31 * date.getMonth();
|
|
326
|
-
|
|
327
|
-
if (date.getMonth() > 1) {
|
|
328
|
-
// FEB
|
|
329
|
-
doy -= Math.floor((4 * (date.getMonth() + 1) + 23) / 10);
|
|
330
|
-
|
|
331
|
-
if (this.isLeapYear(date.getFullYear())) {
|
|
332
|
-
doy++;
|
|
333
|
-
}
|
|
334
|
-
}
|
|
335
|
-
|
|
336
|
-
return doy;
|
|
447
|
+
value: function dayOfYear$1(date) {
|
|
448
|
+
return dayOfYear(date);
|
|
337
449
|
}
|
|
338
450
|
/**
|
|
339
451
|
* Converts Gregorian date to absolute R.D. (Rata Die) days
|
|
@@ -343,51 +455,8 @@ var greg = /*#__PURE__*/function () {
|
|
|
343
455
|
|
|
344
456
|
}, {
|
|
345
457
|
key: "greg2abs",
|
|
346
|
-
value: function greg2abs(date) {
|
|
347
|
-
|
|
348
|
-
throw new TypeError('Argument to greg.greg2abs not a Date');
|
|
349
|
-
}
|
|
350
|
-
|
|
351
|
-
var year = date.getFullYear() - 1;
|
|
352
|
-
return this.dayOfYear(date) + // days this year
|
|
353
|
-
365 * year + ( // + days in prior years
|
|
354
|
-
Math.floor(year / 4) - // + Julian Leap years
|
|
355
|
-
Math.floor(year / 100) + // - century years
|
|
356
|
-
Math.floor(year / 400)); // + Gregorian leap years
|
|
357
|
-
}
|
|
358
|
-
/**
|
|
359
|
-
* @private
|
|
360
|
-
* @param {number} theDate - R.D. number of days
|
|
361
|
-
* @return {number}
|
|
362
|
-
*/
|
|
363
|
-
|
|
364
|
-
}, {
|
|
365
|
-
key: "yearFromFixed",
|
|
366
|
-
value: function yearFromFixed(theDate) {
|
|
367
|
-
var l0 = theDate - 1;
|
|
368
|
-
var n400 = quotient(l0, 146097);
|
|
369
|
-
var d1 = mod(l0, 146097);
|
|
370
|
-
var n100 = quotient(d1, 36524);
|
|
371
|
-
var d2 = mod(d1, 36524);
|
|
372
|
-
var n4 = quotient(d2, 1461);
|
|
373
|
-
var d3 = mod(d2, 1461);
|
|
374
|
-
var n1 = quotient(d3, 365);
|
|
375
|
-
var year = 400 * n400 + 100 * n100 + 4 * n4 + n1;
|
|
376
|
-
return n100 != 4 && n1 != 4 ? year + 1 : year;
|
|
377
|
-
}
|
|
378
|
-
/**
|
|
379
|
-
* @private
|
|
380
|
-
* @param {number} year
|
|
381
|
-
* @param {number} month
|
|
382
|
-
* @param {number} day
|
|
383
|
-
* @return {number}
|
|
384
|
-
*/
|
|
385
|
-
|
|
386
|
-
}, {
|
|
387
|
-
key: "toFixed",
|
|
388
|
-
value: function toFixed(year, month, day) {
|
|
389
|
-
var py = year - 1;
|
|
390
|
-
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;
|
|
458
|
+
value: function greg2abs$1(date) {
|
|
459
|
+
return greg2abs(date);
|
|
391
460
|
}
|
|
392
461
|
/**
|
|
393
462
|
* Converts from Rata Die (R.D. number) to Gregorian date.
|
|
@@ -401,24 +470,8 @@ var greg = /*#__PURE__*/function () {
|
|
|
401
470
|
|
|
402
471
|
}, {
|
|
403
472
|
key: "abs2greg",
|
|
404
|
-
value: function abs2greg(theDate) {
|
|
405
|
-
|
|
406
|
-
throw new TypeError('Argument to greg.abs2greg not a Number');
|
|
407
|
-
}
|
|
408
|
-
|
|
409
|
-
theDate = Math.trunc(theDate);
|
|
410
|
-
var year = this.yearFromFixed(theDate);
|
|
411
|
-
var priorDays = theDate - this.toFixed(year, 1, 1);
|
|
412
|
-
var correction = theDate < this.toFixed(year, 3, 1) ? 0 : this.isLeapYear(year) ? 1 : 2;
|
|
413
|
-
var month = quotient(12 * (priorDays + correction) + 373, 367);
|
|
414
|
-
var day = theDate - this.toFixed(year, month, 1) + 1;
|
|
415
|
-
var dt = new Date(year, month - 1, day);
|
|
416
|
-
|
|
417
|
-
if (year < 100 && year >= 0) {
|
|
418
|
-
dt.setFullYear(year);
|
|
419
|
-
}
|
|
420
|
-
|
|
421
|
-
return dt;
|
|
473
|
+
value: function abs2greg$1(theDate) {
|
|
474
|
+
return abs2greg(theDate);
|
|
422
475
|
}
|
|
423
476
|
}]);
|
|
424
477
|
|
|
@@ -635,17 +688,20 @@ Locale.addLocale('s', noopLocale);
|
|
|
635
688
|
Locale.addLocale('', noopLocale);
|
|
636
689
|
Locale.useLocale('en');
|
|
637
690
|
|
|
691
|
+
/*
|
|
692
|
+
* More minimal HDate
|
|
693
|
+
*/
|
|
638
694
|
var NISAN$1 = 1;
|
|
639
|
-
var IYYAR = 2;
|
|
640
|
-
|
|
641
|
-
var TAMUZ = 4;
|
|
642
|
-
|
|
695
|
+
var IYYAR = 2; // const SIVAN = 3;
|
|
696
|
+
|
|
697
|
+
var TAMUZ = 4; // const AV = 5;
|
|
698
|
+
|
|
643
699
|
var ELUL = 6;
|
|
644
700
|
var TISHREI = 7;
|
|
645
701
|
var CHESHVAN$1 = 8;
|
|
646
702
|
var KISLEV$1 = 9;
|
|
647
|
-
var TEVET$1 = 10;
|
|
648
|
-
|
|
703
|
+
var TEVET$1 = 10; // const SHVAT = 11;
|
|
704
|
+
|
|
649
705
|
var ADAR_I$1 = 12;
|
|
650
706
|
var ADAR_II$1 = 13;
|
|
651
707
|
/**
|
|
@@ -701,16 +757,216 @@ var monthNames0 = ['', 'Nisan', 'Iyyar', 'Sivan', 'Tamuz', 'Av', 'Elul', 'Tishre
|
|
|
701
757
|
* @private
|
|
702
758
|
*/
|
|
703
759
|
|
|
704
|
-
var monthNames = [monthNames0.concat(['Adar', 'Nisan']), monthNames0.concat(['Adar I', 'Adar II', 'Nisan'])];
|
|
760
|
+
var monthNames = [monthNames0.concat(['Adar', 'Nisan']), monthNames0.concat(['Adar I', 'Adar II', 'Nisan'])];
|
|
761
|
+
var edCache = Object.create(null);
|
|
762
|
+
var EPOCH = -1373428; // Avg year length in the cycle (19 solar years with 235 lunar months)
|
|
763
|
+
|
|
764
|
+
var AVG_HEBYEAR_DAYS = 365.24682220597794;
|
|
765
|
+
/**
|
|
766
|
+
* Converts Hebrew date to R.D. (Rata Die) fixed days.
|
|
767
|
+
* R.D. 1 is the imaginary date Monday, January 1, 1 on the Gregorian
|
|
768
|
+
* Calendar.
|
|
769
|
+
* @private
|
|
770
|
+
* @param {number} year Hebrew year
|
|
771
|
+
* @param {number} month Hebrew month
|
|
772
|
+
* @param {number} day Hebrew date (1-30)
|
|
773
|
+
* @return {number}
|
|
774
|
+
*/
|
|
775
|
+
|
|
776
|
+
function hebrew2abs(year, month, day) {
|
|
777
|
+
var tempabs = day;
|
|
778
|
+
|
|
779
|
+
if (month < TISHREI) {
|
|
780
|
+
for (var m = TISHREI; m <= monthsInYear(year); m++) {
|
|
781
|
+
tempabs += daysInMonth(m, year);
|
|
782
|
+
}
|
|
783
|
+
|
|
784
|
+
for (var _m = NISAN$1; _m < month; _m++) {
|
|
785
|
+
tempabs += daysInMonth(_m, year);
|
|
786
|
+
}
|
|
787
|
+
} else {
|
|
788
|
+
for (var _m2 = TISHREI; _m2 < month; _m2++) {
|
|
789
|
+
tempabs += daysInMonth(_m2, year);
|
|
790
|
+
}
|
|
791
|
+
}
|
|
792
|
+
|
|
793
|
+
return EPOCH + elapsedDays(year) + tempabs - 1;
|
|
794
|
+
}
|
|
795
|
+
/**
|
|
796
|
+
* @private
|
|
797
|
+
* @param {number} year
|
|
798
|
+
* @return {number}
|
|
799
|
+
*/
|
|
800
|
+
|
|
801
|
+
function newYear(year) {
|
|
802
|
+
return EPOCH + elapsedDays(year);
|
|
803
|
+
}
|
|
804
|
+
/**
|
|
805
|
+
* Converts absolute R.D. days to Hebrew date
|
|
806
|
+
* @private
|
|
807
|
+
* @param {number} abs absolute R.D. days
|
|
808
|
+
* @return {SimpleHebrewDate}
|
|
809
|
+
*/
|
|
810
|
+
|
|
811
|
+
|
|
812
|
+
function abs2hebrew(abs) {
|
|
813
|
+
if (typeof abs !== 'number' || isNaN(abs)) {
|
|
814
|
+
throw new TypeError("invalid parameter to abs2hebrew ".concat(abs));
|
|
815
|
+
}
|
|
816
|
+
|
|
817
|
+
abs = Math.trunc(abs); // first, quickly approximate year
|
|
818
|
+
|
|
819
|
+
var year = Math.floor((abs - EPOCH) / AVG_HEBYEAR_DAYS);
|
|
820
|
+
|
|
821
|
+
while (newYear(year) <= abs) {
|
|
822
|
+
++year;
|
|
823
|
+
}
|
|
824
|
+
|
|
825
|
+
--year;
|
|
826
|
+
var month = abs < hebrew2abs(year, 1, 1) ? 7 : 1;
|
|
827
|
+
|
|
828
|
+
while (abs > hebrew2abs(year, month, daysInMonth(month, year))) {
|
|
829
|
+
++month;
|
|
830
|
+
}
|
|
831
|
+
|
|
832
|
+
var day = 1 + abs - hebrew2abs(year, month, 1);
|
|
833
|
+
return {
|
|
834
|
+
yy: year,
|
|
835
|
+
mm: month,
|
|
836
|
+
dd: day
|
|
837
|
+
};
|
|
838
|
+
}
|
|
839
|
+
/**
|
|
840
|
+
* Returns true if Hebrew year is a leap year
|
|
841
|
+
* @private
|
|
842
|
+
* @param {number} year Hebrew year
|
|
843
|
+
* @return {boolean}
|
|
844
|
+
*/
|
|
845
|
+
|
|
846
|
+
function isLeapYear(year) {
|
|
847
|
+
return (1 + year * 7) % 19 < 7;
|
|
848
|
+
}
|
|
849
|
+
/**
|
|
850
|
+
* Number of months in this Hebrew year (either 12 or 13 depending on leap year)
|
|
851
|
+
* @private
|
|
852
|
+
* @param {number} year Hebrew year
|
|
853
|
+
* @return {number}
|
|
854
|
+
*/
|
|
855
|
+
|
|
856
|
+
function monthsInYear(year) {
|
|
857
|
+
return 12 + isLeapYear(year); // boolean is cast to 1 or 0
|
|
858
|
+
}
|
|
859
|
+
/**
|
|
860
|
+
* Number of days in Hebrew month in a given year (29 or 30)
|
|
861
|
+
* @private
|
|
862
|
+
* @param {number} month Hebrew month (e.g. months.TISHREI)
|
|
863
|
+
* @param {number} year Hebrew year
|
|
864
|
+
* @return {number}
|
|
865
|
+
*/
|
|
866
|
+
|
|
867
|
+
function daysInMonth(month, year) {
|
|
868
|
+
switch (month) {
|
|
869
|
+
case IYYAR:
|
|
870
|
+
case TAMUZ:
|
|
871
|
+
case ELUL:
|
|
872
|
+
case TEVET$1:
|
|
873
|
+
case ADAR_II$1:
|
|
874
|
+
return 29;
|
|
875
|
+
}
|
|
876
|
+
|
|
877
|
+
if (month === ADAR_I$1 && !isLeapYear(year) || month === CHESHVAN$1 && !longCheshvan(year) || month === KISLEV$1 && shortKislev(year)) {
|
|
878
|
+
return 29;
|
|
879
|
+
} else {
|
|
880
|
+
return 30;
|
|
881
|
+
}
|
|
882
|
+
}
|
|
883
|
+
/**
|
|
884
|
+
* Returns a transliterated string name of Hebrew month in year,
|
|
885
|
+
* for example 'Elul' or 'Cheshvan'.
|
|
886
|
+
* @private
|
|
887
|
+
* @param {number} month Hebrew month (e.g. months.TISHREI)
|
|
888
|
+
* @param {number} year Hebrew year
|
|
889
|
+
* @return {string}
|
|
890
|
+
*/
|
|
891
|
+
|
|
892
|
+
function getMonthName(month, year) {
|
|
893
|
+
if (typeof month !== 'number' || isNaN(month) || month < 1 || month > 14) {
|
|
894
|
+
throw new TypeError("bad month argument ".concat(month));
|
|
895
|
+
}
|
|
896
|
+
|
|
897
|
+
return monthNames[+isLeapYear(year)][month];
|
|
898
|
+
}
|
|
899
|
+
/**
|
|
900
|
+
* Days from sunday prior to start of Hebrew calendar to mean
|
|
901
|
+
* conjunction of Tishrei in Hebrew YEAR
|
|
902
|
+
* @private
|
|
903
|
+
* @param {number} year Hebrew year
|
|
904
|
+
* @return {number}
|
|
905
|
+
*/
|
|
906
|
+
|
|
907
|
+
function elapsedDays(year) {
|
|
908
|
+
var elapsed = edCache[year] = edCache[year] || elapsedDays0(year);
|
|
909
|
+
return elapsed;
|
|
910
|
+
}
|
|
911
|
+
/**
|
|
912
|
+
* Days from sunday prior to start of Hebrew calendar to mean
|
|
913
|
+
* conjunction of Tishrei in Hebrew YEAR
|
|
914
|
+
* @private
|
|
915
|
+
* @param {number} year Hebrew year
|
|
916
|
+
* @return {number}
|
|
917
|
+
*/
|
|
918
|
+
|
|
919
|
+
function elapsedDays0(year) {
|
|
920
|
+
var prevYear = year - 1;
|
|
921
|
+
var mElapsed = 235 * Math.floor(prevYear / 19) + // Months in complete 19 year lunar (Metonic) cycles so far
|
|
922
|
+
12 * (prevYear % 19) + // Regular months in this cycle
|
|
923
|
+
Math.floor((prevYear % 19 * 7 + 1) / 19); // Leap months this cycle
|
|
924
|
+
|
|
925
|
+
var pElapsed = 204 + 793 * (mElapsed % 1080);
|
|
926
|
+
var hElapsed = 5 + 12 * mElapsed + 793 * Math.floor(mElapsed / 1080) + Math.floor(pElapsed / 1080);
|
|
927
|
+
var parts = pElapsed % 1080 + 1080 * (hElapsed % 24);
|
|
928
|
+
var day = 1 + 29 * mElapsed + Math.floor(hElapsed / 24);
|
|
929
|
+
var altDay = day + (parts >= 19440 || 2 === day % 7 && parts >= 9924 && !isLeapYear(year) || 1 === day % 7 && parts >= 16789 && isLeapYear(prevYear));
|
|
930
|
+
return altDay + (altDay % 7 === 0 || altDay % 7 === 3 || altDay % 7 === 5);
|
|
931
|
+
}
|
|
932
|
+
/**
|
|
933
|
+
* Number of days in the hebrew YEAR.
|
|
934
|
+
* A common Hebrew calendar year can have a length of 353, 354 or 355 days
|
|
935
|
+
* A leap Hebrew calendar year can have a length of 383, 384 or 385 days
|
|
936
|
+
* @private
|
|
937
|
+
* @param {number} year Hebrew year
|
|
938
|
+
* @return {number}
|
|
939
|
+
*/
|
|
940
|
+
|
|
941
|
+
|
|
942
|
+
function daysInYear(year) {
|
|
943
|
+
return elapsedDays(year + 1) - elapsedDays(year);
|
|
944
|
+
}
|
|
945
|
+
/**
|
|
946
|
+
* true if Cheshvan is long in Hebrew year
|
|
947
|
+
* @private
|
|
948
|
+
* @param {number} year Hebrew year
|
|
949
|
+
* @return {boolean}
|
|
950
|
+
*/
|
|
951
|
+
|
|
952
|
+
function longCheshvan(year) {
|
|
953
|
+
return daysInYear(year) % 10 === 5;
|
|
954
|
+
}
|
|
955
|
+
/**
|
|
956
|
+
* true if Kislev is short in Hebrew year
|
|
957
|
+
* @private
|
|
958
|
+
* @param {number} year Hebrew year
|
|
959
|
+
* @return {boolean}
|
|
960
|
+
*/
|
|
961
|
+
|
|
962
|
+
function shortKislev(year) {
|
|
963
|
+
return daysInYear(year) % 10 === 3;
|
|
964
|
+
}
|
|
705
965
|
|
|
706
966
|
function throwTypeError(msg) {
|
|
707
967
|
throw new TypeError(msg);
|
|
708
968
|
}
|
|
709
969
|
|
|
710
|
-
var edCache = Object.create(null);
|
|
711
|
-
var EPOCH = -1373428; // Avg year length in the cycle (19 solar years with 235 lunar months)
|
|
712
|
-
|
|
713
|
-
var AVG_HEBYEAR_DAYS = 365.24682220597794;
|
|
714
970
|
var UNITS_DAY = 'day';
|
|
715
971
|
var UNITS_WEEK = 'week';
|
|
716
972
|
var UNITS_MONTH = 'month';
|
|
@@ -789,19 +1045,22 @@ var HDate = /*#__PURE__*/function () {
|
|
|
789
1045
|
* @type {number}
|
|
790
1046
|
*/
|
|
791
1047
|
|
|
792
|
-
|
|
1048
|
+
year = parseInt(year, 10);
|
|
793
1049
|
|
|
794
|
-
if (isNaN(
|
|
1050
|
+
if (isNaN(year)) {
|
|
795
1051
|
throw new TypeError("HDate called with bad year argument: ".concat(year));
|
|
796
1052
|
}
|
|
797
1053
|
|
|
1054
|
+
this.year = year;
|
|
798
1055
|
this.setMonth(month); // will throw if we can't parse
|
|
799
1056
|
|
|
800
|
-
|
|
1057
|
+
day = parseInt(day, 10);
|
|
801
1058
|
|
|
802
|
-
if (isNaN(
|
|
1059
|
+
if (isNaN(day)) {
|
|
803
1060
|
throw new TypeError("HDate called with bad day argument: ".concat(day));
|
|
804
1061
|
}
|
|
1062
|
+
|
|
1063
|
+
this.setDate(day);
|
|
805
1064
|
} else {
|
|
806
1065
|
// 0 arguments
|
|
807
1066
|
if (typeof day === 'undefined') {
|
|
@@ -809,13 +1068,13 @@ var HDate = /*#__PURE__*/function () {
|
|
|
809
1068
|
} // 1 argument
|
|
810
1069
|
|
|
811
1070
|
|
|
812
|
-
var abs0 = typeof day === 'number' && !isNaN(day) ? day :
|
|
1071
|
+
var abs0 = typeof day === 'number' && !isNaN(day) ? day : isDate(day) ? greg2abs(day) : HDate.isHDate(day) ? {
|
|
813
1072
|
dd: day.day,
|
|
814
1073
|
mm: day.month,
|
|
815
1074
|
yy: day.year
|
|
816
1075
|
} : throwTypeError("HDate called with bad argument: ".concat(day));
|
|
817
1076
|
var isNumber = typeof abs0 === 'number';
|
|
818
|
-
var d = isNumber ?
|
|
1077
|
+
var d = isNumber ? abs2hebrew(abs0) : abs0;
|
|
819
1078
|
/**
|
|
820
1079
|
* @private
|
|
821
1080
|
* @type {number}
|
|
@@ -862,8 +1121,8 @@ var HDate = /*#__PURE__*/function () {
|
|
|
862
1121
|
|
|
863
1122
|
}, {
|
|
864
1123
|
key: "isLeapYear",
|
|
865
|
-
value: function isLeapYear() {
|
|
866
|
-
return
|
|
1124
|
+
value: function isLeapYear$1() {
|
|
1125
|
+
return isLeapYear(this.year);
|
|
867
1126
|
}
|
|
868
1127
|
/**
|
|
869
1128
|
* Gets the Hebrew month (1=NISAN, 7=TISHREI) of this Hebrew date
|
|
@@ -883,7 +1142,8 @@ var HDate = /*#__PURE__*/function () {
|
|
|
883
1142
|
}, {
|
|
884
1143
|
key: "getTishreiMonth",
|
|
885
1144
|
value: function getTishreiMonth() {
|
|
886
|
-
var nummonths =
|
|
1145
|
+
var nummonths = monthsInYear(this.getFullYear());
|
|
1146
|
+
|
|
887
1147
|
return (this.getMonth() + nummonths - 6) % nummonths || nummonths;
|
|
888
1148
|
}
|
|
889
1149
|
/**
|
|
@@ -893,8 +1153,8 @@ var HDate = /*#__PURE__*/function () {
|
|
|
893
1153
|
|
|
894
1154
|
}, {
|
|
895
1155
|
key: "daysInMonth",
|
|
896
|
-
value: function daysInMonth() {
|
|
897
|
-
return
|
|
1156
|
+
value: function daysInMonth$1() {
|
|
1157
|
+
return daysInMonth(this.getMonth(), this.getFullYear());
|
|
898
1158
|
}
|
|
899
1159
|
/**
|
|
900
1160
|
* Gets the day within the month (1-30)
|
|
@@ -965,8 +1225,8 @@ var HDate = /*#__PURE__*/function () {
|
|
|
965
1225
|
|
|
966
1226
|
}, {
|
|
967
1227
|
key: "greg",
|
|
968
|
-
value: function greg
|
|
969
|
-
return
|
|
1228
|
+
value: function greg() {
|
|
1229
|
+
return abs2greg(this.abs());
|
|
970
1230
|
}
|
|
971
1231
|
/**
|
|
972
1232
|
* Returns R.D. (Rata Die) fixed days.
|
|
@@ -980,7 +1240,7 @@ var HDate = /*#__PURE__*/function () {
|
|
|
980
1240
|
key: "abs",
|
|
981
1241
|
value: function abs() {
|
|
982
1242
|
if (typeof this.abs0 !== 'number') {
|
|
983
|
-
this.abs0 =
|
|
1243
|
+
this.abs0 = hebrew2abs(this.year, this.month, this.day);
|
|
984
1244
|
}
|
|
985
1245
|
|
|
986
1246
|
return this.abs0;
|
|
@@ -1002,8 +1262,8 @@ var HDate = /*#__PURE__*/function () {
|
|
|
1002
1262
|
* Returns a transliterated Hebrew month name, e.g. `'Elul'` or `'Cheshvan'`.
|
|
1003
1263
|
* @return {string}
|
|
1004
1264
|
*/
|
|
1005
|
-
function getMonthName() {
|
|
1006
|
-
return
|
|
1265
|
+
function getMonthName$1() {
|
|
1266
|
+
return getMonthName(this.getMonth(), this.getFullYear());
|
|
1007
1267
|
}
|
|
1008
1268
|
/**
|
|
1009
1269
|
* Renders this Hebrew date as a translated or transliterated string,
|
|
@@ -1300,54 +1560,8 @@ var HDate = /*#__PURE__*/function () {
|
|
|
1300
1560
|
|
|
1301
1561
|
}], [{
|
|
1302
1562
|
key: "hebrew2abs",
|
|
1303
|
-
value: function hebrew2abs(year, month, day) {
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
if (month < TISHREI) {
|
|
1307
|
-
for (var m = TISHREI; m <= HDate.monthsInYear(year); m++) {
|
|
1308
|
-
tempabs += HDate.daysInMonth(m, year);
|
|
1309
|
-
}
|
|
1310
|
-
|
|
1311
|
-
for (var _m = NISAN$1; _m < month; _m++) {
|
|
1312
|
-
tempabs += HDate.daysInMonth(_m, year);
|
|
1313
|
-
}
|
|
1314
|
-
} else {
|
|
1315
|
-
for (var _m2 = TISHREI; _m2 < month; _m2++) {
|
|
1316
|
-
tempabs += HDate.daysInMonth(_m2, year);
|
|
1317
|
-
}
|
|
1318
|
-
}
|
|
1319
|
-
|
|
1320
|
-
return EPOCH + HDate.elapsedDays(year) + tempabs - 1;
|
|
1321
|
-
}
|
|
1322
|
-
/**
|
|
1323
|
-
* @private
|
|
1324
|
-
* @param {number} year
|
|
1325
|
-
* @return {number}
|
|
1326
|
-
*/
|
|
1327
|
-
|
|
1328
|
-
}, {
|
|
1329
|
-
key: "newYear",
|
|
1330
|
-
value: function newYear(year) {
|
|
1331
|
-
return EPOCH + HDate.elapsedDays(year) + HDate.newYearDelay(year);
|
|
1332
|
-
}
|
|
1333
|
-
/**
|
|
1334
|
-
* @private
|
|
1335
|
-
* @param {number} year
|
|
1336
|
-
* @return {number}
|
|
1337
|
-
*/
|
|
1338
|
-
|
|
1339
|
-
}, {
|
|
1340
|
-
key: "newYearDelay",
|
|
1341
|
-
value: function newYearDelay(year) {
|
|
1342
|
-
var ny1 = HDate.elapsedDays(year);
|
|
1343
|
-
var ny2 = HDate.elapsedDays(year + 1);
|
|
1344
|
-
|
|
1345
|
-
if (ny2 - ny1 === 356) {
|
|
1346
|
-
return 2;
|
|
1347
|
-
} else {
|
|
1348
|
-
var ny0 = HDate.elapsedDays(year - 1);
|
|
1349
|
-
return ny1 - ny0 === 382 ? 1 : 0;
|
|
1350
|
-
}
|
|
1563
|
+
value: function hebrew2abs$1(year, month, day) {
|
|
1564
|
+
return hebrew2abs(year, month, day);
|
|
1351
1565
|
}
|
|
1352
1566
|
/**
|
|
1353
1567
|
* Converts absolute R.D. days to Hebrew date
|
|
@@ -1358,32 +1572,8 @@ var HDate = /*#__PURE__*/function () {
|
|
|
1358
1572
|
|
|
1359
1573
|
}, {
|
|
1360
1574
|
key: "abs2hebrew",
|
|
1361
|
-
value: function abs2hebrew(abs) {
|
|
1362
|
-
|
|
1363
|
-
throw new TypeError("invalid parameter to abs2hebrew ".concat(abs));
|
|
1364
|
-
}
|
|
1365
|
-
|
|
1366
|
-
abs = Math.trunc(abs); // first, quickly approximate year
|
|
1367
|
-
|
|
1368
|
-
var year = Math.floor((abs - EPOCH) / AVG_HEBYEAR_DAYS);
|
|
1369
|
-
|
|
1370
|
-
while (HDate.newYear(year) <= abs) {
|
|
1371
|
-
++year;
|
|
1372
|
-
}
|
|
1373
|
-
|
|
1374
|
-
--year;
|
|
1375
|
-
var month = abs < HDate.hebrew2abs(year, 1, 1) ? 7 : 1;
|
|
1376
|
-
|
|
1377
|
-
while (abs > HDate.hebrew2abs(year, month, HDate.daysInMonth(month, year))) {
|
|
1378
|
-
++month;
|
|
1379
|
-
}
|
|
1380
|
-
|
|
1381
|
-
var day = 1 + abs - HDate.hebrew2abs(year, month, 1);
|
|
1382
|
-
return {
|
|
1383
|
-
yy: year,
|
|
1384
|
-
mm: month,
|
|
1385
|
-
dd: day
|
|
1386
|
-
};
|
|
1575
|
+
value: function abs2hebrew$1(abs) {
|
|
1576
|
+
return abs2hebrew(abs);
|
|
1387
1577
|
}
|
|
1388
1578
|
}, {
|
|
1389
1579
|
key: "getDayOfTranslation",
|
|
@@ -1416,8 +1606,8 @@ var HDate = /*#__PURE__*/function () {
|
|
|
1416
1606
|
}
|
|
1417
1607
|
}, {
|
|
1418
1608
|
key: "isLeapYear",
|
|
1419
|
-
value: function isLeapYear(year) {
|
|
1420
|
-
return (
|
|
1609
|
+
value: function isLeapYear$1(year) {
|
|
1610
|
+
return isLeapYear(year);
|
|
1421
1611
|
}
|
|
1422
1612
|
/**
|
|
1423
1613
|
* Number of months in this Hebrew year (either 12 or 13 depending on leap year)
|
|
@@ -1427,8 +1617,8 @@ var HDate = /*#__PURE__*/function () {
|
|
|
1427
1617
|
|
|
1428
1618
|
}, {
|
|
1429
1619
|
key: "monthsInYear",
|
|
1430
|
-
value: function monthsInYear(year) {
|
|
1431
|
-
return
|
|
1620
|
+
value: function monthsInYear$1(year) {
|
|
1621
|
+
return monthsInYear(year);
|
|
1432
1622
|
}
|
|
1433
1623
|
/**
|
|
1434
1624
|
* Number of days in Hebrew month in a given year (29 or 30)
|
|
@@ -1439,12 +1629,8 @@ var HDate = /*#__PURE__*/function () {
|
|
|
1439
1629
|
|
|
1440
1630
|
}, {
|
|
1441
1631
|
key: "daysInMonth",
|
|
1442
|
-
value: function daysInMonth(month, year) {
|
|
1443
|
-
|
|
1444
|
-
return 29;
|
|
1445
|
-
} else {
|
|
1446
|
-
return 30;
|
|
1447
|
-
}
|
|
1632
|
+
value: function daysInMonth$1(month, year) {
|
|
1633
|
+
return daysInMonth(month, year);
|
|
1448
1634
|
}
|
|
1449
1635
|
/**
|
|
1450
1636
|
* Returns a transliterated string name of Hebrew month in year,
|
|
@@ -1456,12 +1642,8 @@ var HDate = /*#__PURE__*/function () {
|
|
|
1456
1642
|
|
|
1457
1643
|
}, {
|
|
1458
1644
|
key: "getMonthName",
|
|
1459
|
-
value: function getMonthName(month, year) {
|
|
1460
|
-
|
|
1461
|
-
throw new TypeError("bad month argument ".concat(month));
|
|
1462
|
-
}
|
|
1463
|
-
|
|
1464
|
-
return monthNames[+HDate.isLeapYear(year)][month];
|
|
1645
|
+
value: function getMonthName$1(month, year) {
|
|
1646
|
+
return getMonthName(month, year);
|
|
1465
1647
|
}
|
|
1466
1648
|
/**
|
|
1467
1649
|
* Returns the Hebrew month number (NISAN=1, TISHREI=7)
|
|
@@ -1472,45 +1654,17 @@ var HDate = /*#__PURE__*/function () {
|
|
|
1472
1654
|
}, {
|
|
1473
1655
|
key: "monthNum",
|
|
1474
1656
|
value: function monthNum(month) {
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
/**
|
|
1480
|
-
* Days from sunday prior to start of Hebrew calendar to mean
|
|
1481
|
-
* conjunction of Tishrei in Hebrew YEAR
|
|
1482
|
-
* @param {number} year Hebrew year
|
|
1483
|
-
* @return {number}
|
|
1484
|
-
*/
|
|
1657
|
+
if (typeof month === 'number') {
|
|
1658
|
+
if (isNaN(month) || month > 14) {
|
|
1659
|
+
throw new RangeError("Invalid month number: ".concat(month));
|
|
1660
|
+
}
|
|
1485
1661
|
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
value: function elapsedDays(year) {
|
|
1489
|
-
var elapsed = edCache[year] = edCache[year] || HDate.elapsedDays0(year);
|
|
1490
|
-
return elapsed;
|
|
1491
|
-
}
|
|
1492
|
-
/**
|
|
1493
|
-
* Days from sunday prior to start of Hebrew calendar to mean
|
|
1494
|
-
* conjunction of Tishrei in Hebrew YEAR
|
|
1495
|
-
* @private
|
|
1496
|
-
* @param {number} year Hebrew year
|
|
1497
|
-
* @return {number}
|
|
1498
|
-
*/
|
|
1662
|
+
return month;
|
|
1663
|
+
}
|
|
1499
1664
|
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
var prevYear = year - 1;
|
|
1504
|
-
var mElapsed = 235 * Math.floor(prevYear / 19) + // Months in complete 19 year lunar (Metonic) cycles so far
|
|
1505
|
-
12 * (prevYear % 19) + // Regular months in this cycle
|
|
1506
|
-
Math.floor((prevYear % 19 * 7 + 1) / 19); // Leap months this cycle
|
|
1507
|
-
|
|
1508
|
-
var pElapsed = 204 + 793 * (mElapsed % 1080);
|
|
1509
|
-
var hElapsed = 5 + 12 * mElapsed + 793 * Math.floor(mElapsed / 1080) + Math.floor(pElapsed / 1080);
|
|
1510
|
-
var parts = pElapsed % 1080 + 1080 * (hElapsed % 24);
|
|
1511
|
-
var day = 1 + 29 * mElapsed + Math.floor(hElapsed / 24);
|
|
1512
|
-
var altDay = day + (parts >= 19440 || 2 == day % 7 && parts >= 9924 && !HDate.isLeapYear(year) || 1 == day % 7 && parts >= 16789 && HDate.isLeapYear(prevYear));
|
|
1513
|
-
return altDay + (altDay % 7 === 0 || altDay % 7 == 3 || altDay % 7 == 5);
|
|
1665
|
+
return month.charCodeAt(0) >= 48 && month.charCodeAt(0) <= 57 ?
|
|
1666
|
+
/* number */
|
|
1667
|
+
parseInt(month, 10) : HDate.monthFromName(month);
|
|
1514
1668
|
}
|
|
1515
1669
|
/**
|
|
1516
1670
|
* Number of days in the hebrew YEAR
|
|
@@ -1520,8 +1674,8 @@ var HDate = /*#__PURE__*/function () {
|
|
|
1520
1674
|
|
|
1521
1675
|
}, {
|
|
1522
1676
|
key: "daysInYear",
|
|
1523
|
-
value: function daysInYear(year) {
|
|
1524
|
-
return
|
|
1677
|
+
value: function daysInYear$1(year) {
|
|
1678
|
+
return daysInYear(year);
|
|
1525
1679
|
}
|
|
1526
1680
|
/**
|
|
1527
1681
|
* true if Cheshvan is long in Hebrew year
|
|
@@ -1531,8 +1685,8 @@ var HDate = /*#__PURE__*/function () {
|
|
|
1531
1685
|
|
|
1532
1686
|
}, {
|
|
1533
1687
|
key: "longCheshvan",
|
|
1534
|
-
value: function longCheshvan(year) {
|
|
1535
|
-
return
|
|
1688
|
+
value: function longCheshvan$1(year) {
|
|
1689
|
+
return longCheshvan(year);
|
|
1536
1690
|
}
|
|
1537
1691
|
/**
|
|
1538
1692
|
* true if Kislev is short in Hebrew year
|
|
@@ -1542,8 +1696,8 @@ var HDate = /*#__PURE__*/function () {
|
|
|
1542
1696
|
|
|
1543
1697
|
}, {
|
|
1544
1698
|
key: "shortKislev",
|
|
1545
|
-
value: function shortKislev(year) {
|
|
1546
|
-
return
|
|
1699
|
+
value: function shortKislev$1(year) {
|
|
1700
|
+
return shortKislev(year);
|
|
1547
1701
|
}
|
|
1548
1702
|
/**
|
|
1549
1703
|
* Converts Hebrew month string name to numeric
|
|
@@ -1554,7 +1708,14 @@ var HDate = /*#__PURE__*/function () {
|
|
|
1554
1708
|
}, {
|
|
1555
1709
|
key: "monthFromName",
|
|
1556
1710
|
value: function monthFromName(monthName) {
|
|
1557
|
-
if (typeof monthName === 'number')
|
|
1711
|
+
if (typeof monthName === 'number') {
|
|
1712
|
+
if (isNaN(monthName) || monthName < 1 || monthName > 14) {
|
|
1713
|
+
throw new RangeError("Invalid month name: ".concat(monthName));
|
|
1714
|
+
}
|
|
1715
|
+
|
|
1716
|
+
return monthName;
|
|
1717
|
+
}
|
|
1718
|
+
|
|
1558
1719
|
var c = monthName.toLowerCase();
|
|
1559
1720
|
/*
|
|
1560
1721
|
the Hebrew months are unique to their second letter
|
|
@@ -1586,41 +1747,41 @@ var HDate = /*#__PURE__*/function () {
|
|
|
1586
1747
|
/* this catches "november" */
|
|
1587
1748
|
}
|
|
1588
1749
|
|
|
1589
|
-
return NISAN
|
|
1750
|
+
return months.NISAN;
|
|
1590
1751
|
|
|
1591
1752
|
case 'i':
|
|
1592
|
-
return IYYAR;
|
|
1753
|
+
return months.IYYAR;
|
|
1593
1754
|
|
|
1594
1755
|
case 'e':
|
|
1595
|
-
return ELUL;
|
|
1756
|
+
return months.ELUL;
|
|
1596
1757
|
|
|
1597
1758
|
case 'c':
|
|
1598
1759
|
case 'ח':
|
|
1599
|
-
return CHESHVAN
|
|
1760
|
+
return months.CHESHVAN;
|
|
1600
1761
|
|
|
1601
1762
|
case 'k':
|
|
1602
1763
|
case 'כ':
|
|
1603
|
-
return KISLEV
|
|
1764
|
+
return months.KISLEV;
|
|
1604
1765
|
|
|
1605
1766
|
case 's':
|
|
1606
1767
|
switch (c[1]) {
|
|
1607
1768
|
case 'i':
|
|
1608
|
-
return SIVAN;
|
|
1769
|
+
return months.SIVAN;
|
|
1609
1770
|
|
|
1610
1771
|
case 'h':
|
|
1611
|
-
return SHVAT
|
|
1772
|
+
return months.SHVAT;
|
|
1612
1773
|
}
|
|
1613
1774
|
|
|
1614
1775
|
case 't':
|
|
1615
1776
|
switch (c[1]) {
|
|
1616
1777
|
case 'a':
|
|
1617
|
-
return TAMUZ;
|
|
1778
|
+
return months.TAMUZ;
|
|
1618
1779
|
|
|
1619
1780
|
case 'i':
|
|
1620
|
-
return TISHREI;
|
|
1781
|
+
return months.TISHREI;
|
|
1621
1782
|
|
|
1622
1783
|
case 'e':
|
|
1623
|
-
return TEVET
|
|
1784
|
+
return months.TEVET;
|
|
1624
1785
|
}
|
|
1625
1786
|
|
|
1626
1787
|
break;
|
|
@@ -1628,46 +1789,46 @@ var HDate = /*#__PURE__*/function () {
|
|
|
1628
1789
|
case 'a':
|
|
1629
1790
|
switch (c[1]) {
|
|
1630
1791
|
case 'v':
|
|
1631
|
-
return AV;
|
|
1792
|
+
return months.AV;
|
|
1632
1793
|
|
|
1633
1794
|
case 'd':
|
|
1634
1795
|
if (/(1|[^i]i|a|א)$/i.test(monthName)) {
|
|
1635
|
-
return ADAR_I
|
|
1796
|
+
return months.ADAR_I;
|
|
1636
1797
|
}
|
|
1637
1798
|
|
|
1638
|
-
return ADAR_II
|
|
1799
|
+
return months.ADAR_II;
|
|
1639
1800
|
// else assume sheini
|
|
1640
1801
|
}
|
|
1641
1802
|
|
|
1642
1803
|
break;
|
|
1643
1804
|
|
|
1644
1805
|
case 'ס':
|
|
1645
|
-
return SIVAN;
|
|
1806
|
+
return months.SIVAN;
|
|
1646
1807
|
|
|
1647
1808
|
case 'ט':
|
|
1648
|
-
return TEVET
|
|
1809
|
+
return months.TEVET;
|
|
1649
1810
|
|
|
1650
1811
|
case 'ש':
|
|
1651
|
-
return SHVAT
|
|
1812
|
+
return months.SHVAT;
|
|
1652
1813
|
|
|
1653
1814
|
case 'א':
|
|
1654
1815
|
switch (c[1]) {
|
|
1655
1816
|
case 'ב':
|
|
1656
|
-
return AV;
|
|
1817
|
+
return months.AV;
|
|
1657
1818
|
|
|
1658
1819
|
case 'ד':
|
|
1659
1820
|
if (/(1|[^i]i|a|א)$/i.test(monthName)) {
|
|
1660
|
-
return ADAR_I
|
|
1821
|
+
return months.ADAR_I;
|
|
1661
1822
|
}
|
|
1662
1823
|
|
|
1663
|
-
return ADAR_II
|
|
1824
|
+
return months.ADAR_II;
|
|
1664
1825
|
// else assume sheini
|
|
1665
1826
|
|
|
1666
1827
|
case 'י':
|
|
1667
|
-
return IYYAR;
|
|
1828
|
+
return months.IYYAR;
|
|
1668
1829
|
|
|
1669
1830
|
case 'ל':
|
|
1670
|
-
return ELUL;
|
|
1831
|
+
return months.ELUL;
|
|
1671
1832
|
}
|
|
1672
1833
|
|
|
1673
1834
|
break;
|
|
@@ -1675,10 +1836,10 @@ var HDate = /*#__PURE__*/function () {
|
|
|
1675
1836
|
case 'ת':
|
|
1676
1837
|
switch (c[1]) {
|
|
1677
1838
|
case 'מ':
|
|
1678
|
-
return TAMUZ;
|
|
1839
|
+
return months.TAMUZ;
|
|
1679
1840
|
|
|
1680
1841
|
case 'ש':
|
|
1681
|
-
return TISHREI;
|
|
1842
|
+
return months.TISHREI;
|
|
1682
1843
|
}
|
|
1683
1844
|
|
|
1684
1845
|
break;
|
|
@@ -1733,21 +1894,21 @@ function fix(date) {
|
|
|
1733
1894
|
|
|
1734
1895
|
function fixDate(date) {
|
|
1735
1896
|
if (date.day < 1) {
|
|
1736
|
-
if (date.month == TISHREI) {
|
|
1897
|
+
if (date.month == months.TISHREI) {
|
|
1737
1898
|
date.year -= 1;
|
|
1738
1899
|
}
|
|
1739
1900
|
|
|
1740
|
-
date.day +=
|
|
1901
|
+
date.day += daysInMonth(date.month, date.year);
|
|
1741
1902
|
date.month -= 1;
|
|
1742
1903
|
fix(date);
|
|
1743
1904
|
}
|
|
1744
1905
|
|
|
1745
|
-
if (date.day >
|
|
1746
|
-
if (date.month
|
|
1906
|
+
if (date.day > daysInMonth(date.month, date.year)) {
|
|
1907
|
+
if (date.month === months.ELUL) {
|
|
1747
1908
|
date.year += 1;
|
|
1748
1909
|
}
|
|
1749
1910
|
|
|
1750
|
-
date.day -=
|
|
1911
|
+
date.day -= daysInMonth(date.month, date.year);
|
|
1751
1912
|
date.month += 1;
|
|
1752
1913
|
fix(date);
|
|
1753
1914
|
}
|
|
@@ -1761,16 +1922,16 @@ function fixDate(date) {
|
|
|
1761
1922
|
|
|
1762
1923
|
|
|
1763
1924
|
function fixMonth(date) {
|
|
1764
|
-
if (date.month
|
|
1925
|
+
if (date.month === months.ADAR_II && !date.isLeapYear()) {
|
|
1765
1926
|
date.month -= 1; // to Adar I
|
|
1766
1927
|
|
|
1767
1928
|
fix(date);
|
|
1768
1929
|
} else if (date.month < 1) {
|
|
1769
|
-
date.month +=
|
|
1930
|
+
date.month += monthsInYear(date.year);
|
|
1770
1931
|
date.year -= 1;
|
|
1771
1932
|
fix(date);
|
|
1772
|
-
} else if (date.month >
|
|
1773
|
-
date.month -=
|
|
1933
|
+
} else if (date.month > monthsInYear(date.year)) {
|
|
1934
|
+
date.month -= monthsInYear(date.year);
|
|
1774
1935
|
date.year += 1;
|
|
1775
1936
|
fix(date);
|
|
1776
1937
|
}
|
|
@@ -1817,18 +1978,18 @@ function getYahrzeit_(hyear, gdate) {
|
|
|
1817
1978
|
return undefined;
|
|
1818
1979
|
}
|
|
1819
1980
|
|
|
1820
|
-
if (hDeath.mm == CHESHVAN && hDeath.dd == 30 && !
|
|
1981
|
+
if (hDeath.mm == CHESHVAN && hDeath.dd == 30 && !longCheshvan(hDeath.yy + 1)) {
|
|
1821
1982
|
// If it's Heshvan 30 it depends on the first anniversary;
|
|
1822
1983
|
// if that was not Heshvan 30, use the day before Kislev 1.
|
|
1823
|
-
hDeath =
|
|
1824
|
-
} else if (hDeath.mm == KISLEV && hDeath.dd == 30 &&
|
|
1984
|
+
hDeath = abs2hebrew(hebrew2abs(hyear, KISLEV, 1) - 1);
|
|
1985
|
+
} else if (hDeath.mm == KISLEV && hDeath.dd == 30 && shortKislev(hDeath.yy + 1)) {
|
|
1825
1986
|
// If it's Kislev 30 it depends on the first anniversary;
|
|
1826
1987
|
// if that was not Kislev 30, use the day before Teveth 1.
|
|
1827
|
-
hDeath =
|
|
1988
|
+
hDeath = abs2hebrew(hebrew2abs(hyear, TEVET, 1) - 1);
|
|
1828
1989
|
} else if (hDeath.mm == ADAR_II) {
|
|
1829
1990
|
// If it's Adar II, use the same day in last month of year (Adar or Adar II).
|
|
1830
|
-
hDeath.mm =
|
|
1831
|
-
} else if (hDeath.mm == ADAR_I && hDeath.dd == 30 && !
|
|
1991
|
+
hDeath.mm = monthsInYear(hyear);
|
|
1992
|
+
} else if (hDeath.mm == ADAR_I && hDeath.dd == 30 && !isLeapYear(hyear)) {
|
|
1832
1993
|
// If it's the 30th in Adar I and year is not a leap year
|
|
1833
1994
|
// (so Adar has only 29 days), use the last day in Shevat.
|
|
1834
1995
|
hDeath.dd = 30;
|
|
@@ -1837,10 +1998,10 @@ function getYahrzeit_(hyear, gdate) {
|
|
|
1837
1998
|
// advance day to rosh chodesh if needed
|
|
1838
1999
|
|
|
1839
2000
|
|
|
1840
|
-
if (hDeath.mm == CHESHVAN && hDeath.dd == 30 && !
|
|
2001
|
+
if (hDeath.mm == CHESHVAN && hDeath.dd == 30 && !longCheshvan(hyear)) {
|
|
1841
2002
|
hDeath.mm = KISLEV;
|
|
1842
2003
|
hDeath.dd = 1;
|
|
1843
|
-
} else if (hDeath.mm == KISLEV && hDeath.dd == 30 &&
|
|
2004
|
+
} else if (hDeath.mm == KISLEV && hDeath.dd == 30 && shortKislev(hyear)) {
|
|
1844
2005
|
hDeath.mm = TEVET;
|
|
1845
2006
|
hDeath.dd = 1;
|
|
1846
2007
|
}
|
|
@@ -1863,19 +2024,19 @@ function getBirthdayOrAnniversary_(hyear, gdate) {
|
|
|
1863
2024
|
return undefined;
|
|
1864
2025
|
}
|
|
1865
2026
|
|
|
1866
|
-
var isOrigLeap =
|
|
2027
|
+
var isOrigLeap = isLeapYear(origYear);
|
|
1867
2028
|
var month = orig.getMonth();
|
|
1868
2029
|
var day = orig.getDate();
|
|
1869
2030
|
|
|
1870
2031
|
if (month == ADAR_I && !isOrigLeap || month == ADAR_II && isOrigLeap) {
|
|
1871
|
-
month =
|
|
1872
|
-
} else if (month == CHESHVAN && day == 30 && !
|
|
2032
|
+
month = monthsInYear(hyear);
|
|
2033
|
+
} else if (month == CHESHVAN && day == 30 && !longCheshvan(hyear)) {
|
|
1873
2034
|
month = KISLEV;
|
|
1874
2035
|
day = 1;
|
|
1875
|
-
} else if (month == KISLEV && day == 30 &&
|
|
2036
|
+
} else if (month == KISLEV && day == 30 && shortKislev(hyear)) {
|
|
1876
2037
|
month = TEVET;
|
|
1877
2038
|
day = 1;
|
|
1878
|
-
} else if (month == ADAR_I && day == 30 && isOrigLeap && !
|
|
2039
|
+
} else if (month == ADAR_I && day == 30 && isOrigLeap && !isLeapYear(hyear)) {
|
|
1879
2040
|
month = NISAN;
|
|
1880
2041
|
day = 1;
|
|
1881
2042
|
}
|
|
@@ -1883,7 +2044,7 @@ function getBirthdayOrAnniversary_(hyear, gdate) {
|
|
|
1883
2044
|
return new HDate(day, month, hyear);
|
|
1884
2045
|
}
|
|
1885
2046
|
|
|
1886
|
-
var version="3.
|
|
2047
|
+
var version="3.38.2";
|
|
1887
2048
|
|
|
1888
2049
|
var headers={"plural-forms":"nplurals=2; plural=(n > 1);",language:"he"};var contexts={"":{Adar:["אַדָר"],"Adar I":["אַדָר א׳"],"Adar II":["אַדָר ב׳"],Av:["אָב"],Cheshvan:["חֶשְׁוָן"],Elul:["אֱלוּל"],Iyyar:["אִיָיר"],Kislev:["כִּסְלֵו"],Nisan:["נִיסָן"],"Sh'vat":["שְׁבָט"],Sivan:["סִיוָן"],Tamuz:["תַּמּוּז"],Tevet:["טֵבֵת"],Tishrei:["תִשְׁרֵי"]}};var poHeMin = {headers:headers,contexts:contexts};
|
|
1889
2050
|
|