@hebcal/core 3.33.2 → 3.33.5
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 +343 -354
- package/dist/bundle.js +869 -745
- package/dist/bundle.min.js +2 -2
- package/dist/hdate-bundle.js +429 -266
- package/dist/hdate-bundle.min.js +2 -2
- package/dist/hdate.js +193 -83
- package/dist/hdate.mjs +192 -84
- package/dist/index.js +319 -219
- package/dist/index.mjs +301 -221
- package/hebcal.d.ts +116 -115
- package/package.json +11 -19
package/dist/hdate.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! @hebcal/core v3.33.
|
|
1
|
+
/*! @hebcal/core v3.33.5 */
|
|
2
2
|
const GERESH = '׳';
|
|
3
3
|
const GERSHAYIM = '״';
|
|
4
4
|
/**
|
|
@@ -207,53 +207,55 @@ function quotient(x, y) {
|
|
|
207
207
|
}
|
|
208
208
|
/**
|
|
209
209
|
* Gregorian date helper functions.
|
|
210
|
-
* @namespace
|
|
211
210
|
*/
|
|
212
211
|
|
|
213
212
|
|
|
214
|
-
|
|
213
|
+
class greg {
|
|
215
214
|
/**
|
|
216
215
|
* Long names of the Gregorian months (1='January', 12='December')
|
|
217
216
|
* @readonly
|
|
218
217
|
* @type {string[]}
|
|
219
218
|
*/
|
|
220
|
-
monthNames
|
|
221
|
-
|
|
219
|
+
static monthNames = ['', 'January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'];
|
|
222
220
|
/**
|
|
223
221
|
* Returns true if the Gregorian year is a leap year
|
|
224
222
|
* @param {number} year Gregorian year
|
|
225
223
|
* @return {boolean}
|
|
226
224
|
*/
|
|
227
|
-
isLeapYear: function (year) {
|
|
228
|
-
return !(year % 4) && (!!(year % 100) || !(year % 400));
|
|
229
|
-
},
|
|
230
225
|
|
|
226
|
+
static isLeapYear(year) {
|
|
227
|
+
return !(year % 4) && (!!(year % 100) || !(year % 400));
|
|
228
|
+
}
|
|
231
229
|
/**
|
|
232
230
|
* Number of days in the Gregorian month for given year
|
|
233
231
|
* @param {number} month Gregorian month (1=January, 12=December)
|
|
234
232
|
* @param {number} year Gregorian year
|
|
235
233
|
* @return {number}
|
|
236
234
|
*/
|
|
237
|
-
|
|
235
|
+
|
|
236
|
+
|
|
237
|
+
static daysInMonth(month, year) {
|
|
238
238
|
// 1 based months
|
|
239
239
|
return monthLengths[+this.isLeapYear(year)][month];
|
|
240
|
-
}
|
|
241
|
-
|
|
240
|
+
}
|
|
242
241
|
/**
|
|
243
242
|
* Returns true if the object is a Javascript Date
|
|
244
243
|
* @param {Object} obj
|
|
245
244
|
* @return {boolean}
|
|
246
245
|
*/
|
|
247
|
-
isDate: function (obj) {
|
|
248
|
-
return typeof obj === 'object' && Date.prototype === obj.__proto__;
|
|
249
|
-
},
|
|
250
246
|
|
|
247
|
+
|
|
248
|
+
static isDate(obj) {
|
|
249
|
+
return typeof obj === 'object' && Date.prototype === obj.__proto__;
|
|
250
|
+
}
|
|
251
251
|
/**
|
|
252
252
|
* Returns number of days since January 1 of that year
|
|
253
253
|
* @param {Date} date Gregorian date
|
|
254
254
|
* @return {number}
|
|
255
255
|
*/
|
|
256
|
-
|
|
256
|
+
|
|
257
|
+
|
|
258
|
+
static dayOfYear(date) {
|
|
257
259
|
if (!this.isDate(date)) {
|
|
258
260
|
throw new TypeError('Argument to greg.dayOfYear not a Date');
|
|
259
261
|
}
|
|
@@ -270,14 +272,15 @@ const greg = {
|
|
|
270
272
|
}
|
|
271
273
|
|
|
272
274
|
return doy;
|
|
273
|
-
}
|
|
274
|
-
|
|
275
|
+
}
|
|
275
276
|
/**
|
|
276
277
|
* Converts Gregorian date to absolute R.D. (Rata Die) days
|
|
277
278
|
* @param {Date} date Gregorian date
|
|
278
279
|
* @return {number}
|
|
279
280
|
*/
|
|
280
|
-
|
|
281
|
+
|
|
282
|
+
|
|
283
|
+
static greg2abs(date) {
|
|
281
284
|
if (!this.isDate(date)) {
|
|
282
285
|
throw new TypeError('Argument to greg.greg2abs not a Date');
|
|
283
286
|
}
|
|
@@ -288,14 +291,15 @@ const greg = {
|
|
|
288
291
|
Math.floor(year / 4) - // + Julian Leap years
|
|
289
292
|
Math.floor(year / 100) + // - century years
|
|
290
293
|
Math.floor(year / 400)); // + Gregorian leap years
|
|
291
|
-
}
|
|
292
|
-
|
|
294
|
+
}
|
|
293
295
|
/**
|
|
294
296
|
* @private
|
|
295
297
|
* @param {number} theDate - R.D. number of days
|
|
296
298
|
* @return {number}
|
|
297
299
|
*/
|
|
298
|
-
|
|
300
|
+
|
|
301
|
+
|
|
302
|
+
static yearFromFixed(theDate) {
|
|
299
303
|
const l0 = theDate - 1;
|
|
300
304
|
const n400 = quotient(l0, 146097);
|
|
301
305
|
const d1 = mod(l0, 146097);
|
|
@@ -306,8 +310,7 @@ const greg = {
|
|
|
306
310
|
const n1 = quotient(d3, 365);
|
|
307
311
|
const year = 400 * n400 + 100 * n100 + 4 * n4 + n1;
|
|
308
312
|
return n100 != 4 && n1 != 4 ? year + 1 : year;
|
|
309
|
-
}
|
|
310
|
-
|
|
313
|
+
}
|
|
311
314
|
/**
|
|
312
315
|
* @private
|
|
313
316
|
* @param {number} year
|
|
@@ -315,11 +318,12 @@ const greg = {
|
|
|
315
318
|
* @param {number} day
|
|
316
319
|
* @return {number}
|
|
317
320
|
*/
|
|
318
|
-
|
|
321
|
+
|
|
322
|
+
|
|
323
|
+
static toFixed(year, month, day) {
|
|
319
324
|
const py = year - 1;
|
|
320
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;
|
|
321
|
-
}
|
|
322
|
-
|
|
326
|
+
}
|
|
323
327
|
/**
|
|
324
328
|
* Converts from Rata Die (R.D. number) to Gregorian date.
|
|
325
329
|
* See the footnote on page 384 of ``Calendrical Calculations, Part II:
|
|
@@ -329,7 +333,9 @@ const greg = {
|
|
|
329
333
|
* @param {number} theDate - R.D. number of days
|
|
330
334
|
* @return {Date}
|
|
331
335
|
*/
|
|
332
|
-
|
|
336
|
+
|
|
337
|
+
|
|
338
|
+
static abs2greg(theDate) {
|
|
333
339
|
if (typeof theDate !== 'number') {
|
|
334
340
|
throw new TypeError('Argument to greg.abs2greg not a Number');
|
|
335
341
|
}
|
|
@@ -348,7 +354,8 @@ const greg = {
|
|
|
348
354
|
|
|
349
355
|
return dt;
|
|
350
356
|
}
|
|
351
|
-
|
|
357
|
+
|
|
358
|
+
}
|
|
352
359
|
|
|
353
360
|
const noopLocale = {
|
|
354
361
|
headers: {
|
|
@@ -371,19 +378,17 @@ const alias = {
|
|
|
371
378
|
* * `ashkenazi` - Ashkenazi transliterations (e.g. "Shabbos")
|
|
372
379
|
* * `he` - Hebrew (e.g. "שַׁבָּת")
|
|
373
380
|
* * `he-x-NoNikud` - Hebrew without nikud (e.g. "שבת")
|
|
374
|
-
* @namespace
|
|
375
381
|
*/
|
|
376
382
|
|
|
377
|
-
|
|
383
|
+
class Locale {
|
|
378
384
|
/** @private */
|
|
379
|
-
locales
|
|
380
|
-
|
|
385
|
+
static locales = Object.create(null);
|
|
381
386
|
/** @private */
|
|
382
|
-
activeLocale: null,
|
|
383
387
|
|
|
388
|
+
static activeLocale = null;
|
|
384
389
|
/** @private */
|
|
385
|
-
activeName: null,
|
|
386
390
|
|
|
391
|
+
static activeName = null;
|
|
387
392
|
/**
|
|
388
393
|
* Returns translation only if `locale` offers a non-empty translation for `id`.
|
|
389
394
|
* Otherwise, returns `undefined`.
|
|
@@ -391,7 +396,8 @@ const Locale = {
|
|
|
391
396
|
* @param {string} [locale] Optional locale name (i.e: `'he'`, `'fr'`). Defaults to active locale.
|
|
392
397
|
* @return {string}
|
|
393
398
|
*/
|
|
394
|
-
|
|
399
|
+
|
|
400
|
+
static lookupTranslation(id, locale) {
|
|
395
401
|
const locale0 = locale && locale.toLowerCase();
|
|
396
402
|
const loc = typeof locale == 'string' && this.locales[locale0] || this.activeLocale;
|
|
397
403
|
const array = loc[id];
|
|
@@ -401,15 +407,16 @@ const Locale = {
|
|
|
401
407
|
}
|
|
402
408
|
|
|
403
409
|
return undefined;
|
|
404
|
-
}
|
|
405
|
-
|
|
410
|
+
}
|
|
406
411
|
/**
|
|
407
412
|
* By default, if no translation was found, returns `id`.
|
|
408
413
|
* @param {string} id Message ID to translate
|
|
409
414
|
* @param {string} [locale] Optional locale name (i.e: `'he'`, `'fr'`). Defaults to active locale.
|
|
410
415
|
* @return {string}
|
|
411
416
|
*/
|
|
412
|
-
|
|
417
|
+
|
|
418
|
+
|
|
419
|
+
static gettext(id, locale) {
|
|
413
420
|
const text = this.lookupTranslation(id, locale);
|
|
414
421
|
|
|
415
422
|
if (typeof text == 'undefined') {
|
|
@@ -417,21 +424,21 @@ const Locale = {
|
|
|
417
424
|
}
|
|
418
425
|
|
|
419
426
|
return text;
|
|
420
|
-
}
|
|
421
|
-
|
|
427
|
+
}
|
|
422
428
|
/**
|
|
423
429
|
* Register locale translations.
|
|
424
430
|
* @param {string} locale Locale name (i.e.: `'he'`, `'fr'`)
|
|
425
431
|
* @param {LocaleDate} data parsed data from a `.po` file.
|
|
426
432
|
*/
|
|
427
|
-
|
|
433
|
+
|
|
434
|
+
|
|
435
|
+
static addLocale(locale, data) {
|
|
428
436
|
if (typeof data.contexts !== 'object' || typeof data.contexts[''] !== 'object') {
|
|
429
437
|
throw new TypeError(`Locale '${locale}' invalid compact format`);
|
|
430
438
|
}
|
|
431
439
|
|
|
432
440
|
this.locales[locale.toLowerCase()] = data.contexts[''];
|
|
433
|
-
}
|
|
434
|
-
|
|
441
|
+
}
|
|
435
442
|
/**
|
|
436
443
|
* Activates a locale. Throws an error if the locale has not been previously added.
|
|
437
444
|
* After setting the locale to be used, all strings marked for translations
|
|
@@ -439,7 +446,9 @@ const Locale = {
|
|
|
439
446
|
* @param {string} locale Locale name (i.e: `'he'`, `'fr'`)
|
|
440
447
|
* @return {LocaleData}
|
|
441
448
|
*/
|
|
442
|
-
|
|
449
|
+
|
|
450
|
+
|
|
451
|
+
static useLocale(locale) {
|
|
443
452
|
const locale0 = locale.toLowerCase();
|
|
444
453
|
const obj = this.locales[locale0];
|
|
445
454
|
|
|
@@ -450,30 +459,33 @@ const Locale = {
|
|
|
450
459
|
this.activeName = alias[locale0] || locale0;
|
|
451
460
|
this.activeLocale = obj;
|
|
452
461
|
return this.activeLocale;
|
|
453
|
-
}
|
|
454
|
-
|
|
462
|
+
}
|
|
455
463
|
/**
|
|
456
464
|
* Returns the name of the active locale (i.e. 'he', 'ashkenazi', 'fr')
|
|
457
465
|
* @return {string}
|
|
458
466
|
*/
|
|
459
|
-
getLocaleName: function getLocaleName() {
|
|
460
|
-
return this.activeName;
|
|
461
|
-
},
|
|
462
467
|
|
|
468
|
+
|
|
469
|
+
static getLocaleName() {
|
|
470
|
+
return this.activeName;
|
|
471
|
+
}
|
|
463
472
|
/**
|
|
464
473
|
* Returns the names of registered locales
|
|
465
474
|
* @return {string[]}
|
|
466
475
|
*/
|
|
467
|
-
getLocaleNames: function getLocaleNames() {
|
|
468
|
-
return Object.keys(this.locales).sort();
|
|
469
|
-
},
|
|
470
476
|
|
|
477
|
+
|
|
478
|
+
static getLocaleNames() {
|
|
479
|
+
return Object.keys(this.locales).sort();
|
|
480
|
+
}
|
|
471
481
|
/**
|
|
472
482
|
* @param {number} n
|
|
473
483
|
* @param {string} [locale] Optional locale name (i.e: `'he'`, `'fr'`). Defaults to active locale.
|
|
474
484
|
* @return {string}
|
|
475
485
|
*/
|
|
476
|
-
|
|
486
|
+
|
|
487
|
+
|
|
488
|
+
static ordinal(n, locale) {
|
|
477
489
|
const locale1 = locale && locale.toLowerCase();
|
|
478
490
|
const locale0 = locale1 || this.activeName;
|
|
479
491
|
|
|
@@ -502,28 +514,31 @@ const Locale = {
|
|
|
502
514
|
default:
|
|
503
515
|
return n + '.';
|
|
504
516
|
}
|
|
505
|
-
}
|
|
506
|
-
|
|
517
|
+
}
|
|
507
518
|
/**
|
|
508
519
|
* @private
|
|
509
520
|
* @param {number} n
|
|
510
521
|
* @return {string}
|
|
511
522
|
*/
|
|
512
|
-
|
|
523
|
+
|
|
524
|
+
|
|
525
|
+
static getEnOrdinal(n) {
|
|
513
526
|
const s = ['th', 'st', 'nd', 'rd'];
|
|
514
527
|
const v = n % 100;
|
|
515
528
|
return n + (s[(v - 20) % 10] || s[v] || s[0]);
|
|
516
|
-
}
|
|
517
|
-
|
|
529
|
+
}
|
|
518
530
|
/**
|
|
519
531
|
* Removes nekudot from Hebrew string
|
|
520
532
|
* @param {string} str
|
|
521
533
|
* @return {string}
|
|
522
534
|
*/
|
|
523
|
-
|
|
535
|
+
|
|
536
|
+
|
|
537
|
+
static hebrewStripNikkud(str) {
|
|
524
538
|
return str.replace(/[\u0590-\u05bd]/g, '').replace(/[\u05bf-\u05c7]/g, '');
|
|
525
539
|
}
|
|
526
|
-
|
|
540
|
+
|
|
541
|
+
}
|
|
527
542
|
Locale.addLocale('en', noopLocale);
|
|
528
543
|
Locale.addLocale('s', noopLocale);
|
|
529
544
|
Locale.addLocale('', noopLocale);
|
|
@@ -549,19 +564,19 @@ Locale.useLocale('en');
|
|
|
549
564
|
You should have received a copy of the GNU General Public License
|
|
550
565
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
551
566
|
*/
|
|
552
|
-
const NISAN = 1;
|
|
567
|
+
const NISAN$1 = 1;
|
|
553
568
|
const IYYAR = 2;
|
|
554
569
|
const SIVAN = 3;
|
|
555
570
|
const TAMUZ = 4;
|
|
556
571
|
const AV = 5;
|
|
557
572
|
const ELUL = 6;
|
|
558
573
|
const TISHREI = 7;
|
|
559
|
-
const CHESHVAN = 8;
|
|
560
|
-
const KISLEV = 9;
|
|
561
|
-
const TEVET = 10;
|
|
562
|
-
const SHVAT = 11;
|
|
563
|
-
const ADAR_I = 12;
|
|
564
|
-
const ADAR_II = 13;
|
|
574
|
+
const CHESHVAN$1 = 8;
|
|
575
|
+
const KISLEV$1 = 9;
|
|
576
|
+
const TEVET$1 = 10;
|
|
577
|
+
const SHVAT$1 = 11;
|
|
578
|
+
const ADAR_I$1 = 12;
|
|
579
|
+
const ADAR_II$1 = 13;
|
|
565
580
|
/**
|
|
566
581
|
* Hebrew months of the year (NISAN=1, TISHREI=7)
|
|
567
582
|
* @readonly
|
|
@@ -903,7 +918,7 @@ class HDate {
|
|
|
903
918
|
tempabs += HDate.daysInMonth(m, year);
|
|
904
919
|
}
|
|
905
920
|
|
|
906
|
-
for (let m = NISAN; m < month; m++) {
|
|
921
|
+
for (let m = NISAN$1; m < month; m++) {
|
|
907
922
|
tempabs += HDate.daysInMonth(m, year);
|
|
908
923
|
}
|
|
909
924
|
} else {
|
|
@@ -1049,7 +1064,7 @@ class HDate {
|
|
|
1049
1064
|
* @example
|
|
1050
1065
|
* import {HDate, months} from '@hebcal/core';
|
|
1051
1066
|
* const hd = new HDate(15, months.CHESHVAN, 5769);
|
|
1052
|
-
* console.log(
|
|
1067
|
+
* console.log(hd.renderGematriya()); // 'ט״ו חֶשְׁוָן תשס״ט'
|
|
1053
1068
|
* @return {string}
|
|
1054
1069
|
*/
|
|
1055
1070
|
|
|
@@ -1311,7 +1326,7 @@ class HDate {
|
|
|
1311
1326
|
|
|
1312
1327
|
|
|
1313
1328
|
static daysInMonth(month, year) {
|
|
1314
|
-
if (month == IYYAR || month == TAMUZ || month == ELUL || month == TEVET || month == ADAR_II || month == ADAR_I && !HDate.isLeapYear(year) || month == CHESHVAN && !HDate.longCheshvan(year) || month == KISLEV && HDate.shortKislev(year)) {
|
|
1329
|
+
if (month == IYYAR || month == TAMUZ || month == ELUL || month == TEVET$1 || month == ADAR_II$1 || month == ADAR_I$1 && !HDate.isLeapYear(year) || month == CHESHVAN$1 && !HDate.longCheshvan(year) || month == KISLEV$1 && HDate.shortKislev(year)) {
|
|
1315
1330
|
return 29;
|
|
1316
1331
|
} else {
|
|
1317
1332
|
return 30;
|
|
@@ -1449,7 +1464,7 @@ class HDate {
|
|
|
1449
1464
|
/* this catches "november" */
|
|
1450
1465
|
}
|
|
1451
1466
|
|
|
1452
|
-
return NISAN;
|
|
1467
|
+
return NISAN$1;
|
|
1453
1468
|
|
|
1454
1469
|
case 'i':
|
|
1455
1470
|
return IYYAR;
|
|
@@ -1459,11 +1474,11 @@ class HDate {
|
|
|
1459
1474
|
|
|
1460
1475
|
case 'c':
|
|
1461
1476
|
case 'ח':
|
|
1462
|
-
return CHESHVAN;
|
|
1477
|
+
return CHESHVAN$1;
|
|
1463
1478
|
|
|
1464
1479
|
case 'k':
|
|
1465
1480
|
case 'כ':
|
|
1466
|
-
return KISLEV;
|
|
1481
|
+
return KISLEV$1;
|
|
1467
1482
|
|
|
1468
1483
|
case 's':
|
|
1469
1484
|
switch (c[1]) {
|
|
@@ -1471,7 +1486,7 @@ class HDate {
|
|
|
1471
1486
|
return SIVAN;
|
|
1472
1487
|
|
|
1473
1488
|
case 'h':
|
|
1474
|
-
return SHVAT;
|
|
1489
|
+
return SHVAT$1;
|
|
1475
1490
|
}
|
|
1476
1491
|
|
|
1477
1492
|
case 't':
|
|
@@ -1483,7 +1498,7 @@ class HDate {
|
|
|
1483
1498
|
return TISHREI;
|
|
1484
1499
|
|
|
1485
1500
|
case 'e':
|
|
1486
|
-
return TEVET;
|
|
1501
|
+
return TEVET$1;
|
|
1487
1502
|
}
|
|
1488
1503
|
|
|
1489
1504
|
break;
|
|
@@ -1495,10 +1510,10 @@ class HDate {
|
|
|
1495
1510
|
|
|
1496
1511
|
case 'd':
|
|
1497
1512
|
if (/(1|[^i]i|a|א)$/i.test(monthName)) {
|
|
1498
|
-
return ADAR_I;
|
|
1513
|
+
return ADAR_I$1;
|
|
1499
1514
|
}
|
|
1500
1515
|
|
|
1501
|
-
return ADAR_II;
|
|
1516
|
+
return ADAR_II$1;
|
|
1502
1517
|
// else assume sheini
|
|
1503
1518
|
}
|
|
1504
1519
|
|
|
@@ -1508,10 +1523,10 @@ class HDate {
|
|
|
1508
1523
|
return SIVAN;
|
|
1509
1524
|
|
|
1510
1525
|
case 'ט':
|
|
1511
|
-
return TEVET;
|
|
1526
|
+
return TEVET$1;
|
|
1512
1527
|
|
|
1513
1528
|
case 'ש':
|
|
1514
|
-
return SHVAT;
|
|
1529
|
+
return SHVAT$1;
|
|
1515
1530
|
|
|
1516
1531
|
case 'א':
|
|
1517
1532
|
switch (c[1]) {
|
|
@@ -1520,10 +1535,10 @@ class HDate {
|
|
|
1520
1535
|
|
|
1521
1536
|
case 'ד':
|
|
1522
1537
|
if (/(1|[^i]i|a|א)$/i.test(monthName)) {
|
|
1523
|
-
return ADAR_I;
|
|
1538
|
+
return ADAR_I$1;
|
|
1524
1539
|
}
|
|
1525
1540
|
|
|
1526
|
-
return ADAR_II;
|
|
1541
|
+
return ADAR_II$1;
|
|
1527
1542
|
// else assume sheini
|
|
1528
1543
|
|
|
1529
1544
|
case 'י':
|
|
@@ -1620,7 +1635,7 @@ function fixDate(date) {
|
|
|
1620
1635
|
|
|
1621
1636
|
|
|
1622
1637
|
function fixMonth(date) {
|
|
1623
|
-
if (date.month == ADAR_II && !date.isLeapYear()) {
|
|
1638
|
+
if (date.month == ADAR_II$1 && !date.isLeapYear()) {
|
|
1624
1639
|
date.month -= 1; // to Adar I
|
|
1625
1640
|
|
|
1626
1641
|
fix(date);
|
|
@@ -1649,11 +1664,104 @@ function onOrBefore(day, t, offset) {
|
|
|
1649
1664
|
return new HDate(HDate.dayOnOrBefore(day, t.abs() + offset));
|
|
1650
1665
|
}
|
|
1651
1666
|
|
|
1652
|
-
|
|
1667
|
+
const NISAN = months.NISAN;
|
|
1668
|
+
const CHESHVAN = months.CHESHVAN;
|
|
1669
|
+
const KISLEV = months.KISLEV;
|
|
1670
|
+
const TEVET = months.TEVET;
|
|
1671
|
+
const SHVAT = months.SHVAT;
|
|
1672
|
+
const ADAR_I = months.ADAR_I;
|
|
1673
|
+
const ADAR_II = months.ADAR_II;
|
|
1674
|
+
/**
|
|
1675
|
+
* @private
|
|
1676
|
+
* @param {number} hyear Hebrew year
|
|
1677
|
+
* @param {Date|HDate} gdate Gregorian or Hebrew date of death
|
|
1678
|
+
* @return {HDate} anniversary occurring in hyear
|
|
1679
|
+
*/
|
|
1680
|
+
|
|
1681
|
+
function getYahrzeit_(hyear, gdate) {
|
|
1682
|
+
const orig = HDate.isHDate(gdate) ? gdate : new HDate(gdate);
|
|
1683
|
+
let hDeath = {
|
|
1684
|
+
yy: orig.getFullYear(),
|
|
1685
|
+
mm: orig.getMonth(),
|
|
1686
|
+
dd: orig.getDate()
|
|
1687
|
+
};
|
|
1688
|
+
|
|
1689
|
+
if (hyear <= hDeath.yy) {
|
|
1690
|
+
// `Hebrew year ${hyear} occurs on or before original date in ${hDeath.yy}`
|
|
1691
|
+
return undefined;
|
|
1692
|
+
}
|
|
1693
|
+
|
|
1694
|
+
if (hDeath.mm == CHESHVAN && hDeath.dd == 30 && !HDate.longCheshvan(hDeath.yy + 1)) {
|
|
1695
|
+
// If it's Heshvan 30 it depends on the first anniversary;
|
|
1696
|
+
// if that was not Heshvan 30, use the day before Kislev 1.
|
|
1697
|
+
hDeath = HDate.abs2hebrew(HDate.hebrew2abs(hyear, KISLEV, 1) - 1);
|
|
1698
|
+
} else if (hDeath.mm == KISLEV && hDeath.dd == 30 && HDate.shortKislev(hDeath.yy + 1)) {
|
|
1699
|
+
// If it's Kislev 30 it depends on the first anniversary;
|
|
1700
|
+
// if that was not Kislev 30, use the day before Teveth 1.
|
|
1701
|
+
hDeath = HDate.abs2hebrew(HDate.hebrew2abs(hyear, TEVET, 1) - 1);
|
|
1702
|
+
} else if (hDeath.mm == ADAR_II) {
|
|
1703
|
+
// If it's Adar II, use the same day in last month of year (Adar or Adar II).
|
|
1704
|
+
hDeath.mm = HDate.monthsInYear(hyear);
|
|
1705
|
+
} else if (hDeath.mm == ADAR_I && hDeath.dd == 30 && !HDate.isLeapYear(hyear)) {
|
|
1706
|
+
// If it's the 30th in Adar I and year is not a leap year
|
|
1707
|
+
// (so Adar has only 29 days), use the last day in Shevat.
|
|
1708
|
+
hDeath.dd = 30;
|
|
1709
|
+
hDeath.mm = SHVAT;
|
|
1710
|
+
} // In all other cases, use the normal anniversary of the date of death.
|
|
1711
|
+
// advance day to rosh chodesh if needed
|
|
1712
|
+
|
|
1713
|
+
|
|
1714
|
+
if (hDeath.mm == CHESHVAN && hDeath.dd == 30 && !HDate.longCheshvan(hyear)) {
|
|
1715
|
+
hDeath.mm = KISLEV;
|
|
1716
|
+
hDeath.dd = 1;
|
|
1717
|
+
} else if (hDeath.mm == KISLEV && hDeath.dd == 30 && HDate.shortKislev(hyear)) {
|
|
1718
|
+
hDeath.mm = TEVET;
|
|
1719
|
+
hDeath.dd = 1;
|
|
1720
|
+
}
|
|
1721
|
+
|
|
1722
|
+
return new HDate(hDeath.dd, hDeath.mm, hyear);
|
|
1723
|
+
}
|
|
1724
|
+
/**
|
|
1725
|
+
* @private
|
|
1726
|
+
* @param {number} hyear Hebrew year
|
|
1727
|
+
* @param {Date|HDate} gdate Gregorian or Hebrew date of event
|
|
1728
|
+
* @return {HDate} anniversary occurring in `hyear`
|
|
1729
|
+
*/
|
|
1730
|
+
|
|
1731
|
+
function getBirthdayOrAnniversary_(hyear, gdate) {
|
|
1732
|
+
const orig = HDate.isHDate(gdate) ? gdate : new HDate(gdate);
|
|
1733
|
+
const origYear = orig.getFullYear();
|
|
1734
|
+
|
|
1735
|
+
if (hyear <= origYear) {
|
|
1736
|
+
// `Hebrew year ${hyear} occurs on or before original date in ${origYear}`
|
|
1737
|
+
return undefined;
|
|
1738
|
+
}
|
|
1739
|
+
|
|
1740
|
+
const isOrigLeap = HDate.isLeapYear(origYear);
|
|
1741
|
+
let month = orig.getMonth();
|
|
1742
|
+
let day = orig.getDate();
|
|
1743
|
+
|
|
1744
|
+
if (month == ADAR_I && !isOrigLeap || month == ADAR_II && isOrigLeap) {
|
|
1745
|
+
month = HDate.monthsInYear(hyear);
|
|
1746
|
+
} else if (month == CHESHVAN && day == 30 && !HDate.longCheshvan(hyear)) {
|
|
1747
|
+
month = KISLEV;
|
|
1748
|
+
day = 1;
|
|
1749
|
+
} else if (month == KISLEV && day == 30 && HDate.shortKislev(hyear)) {
|
|
1750
|
+
month = TEVET;
|
|
1751
|
+
day = 1;
|
|
1752
|
+
} else if (month == ADAR_I && day == 30 && isOrigLeap && !HDate.isLeapYear(hyear)) {
|
|
1753
|
+
month = NISAN;
|
|
1754
|
+
day = 1;
|
|
1755
|
+
}
|
|
1756
|
+
|
|
1757
|
+
return new HDate(day, month, hyear);
|
|
1758
|
+
}
|
|
1759
|
+
|
|
1760
|
+
var version="3.33.5";
|
|
1653
1761
|
|
|
1654
1762
|
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};
|
|
1655
1763
|
|
|
1656
1764
|
Locale.addLocale('he', poHeMin);
|
|
1657
1765
|
Locale.addLocale('h', poHeMin);
|
|
1658
1766
|
|
|
1659
|
-
export { HDate, Locale, gematriya, greg, months, version };
|
|
1767
|
+
export { HDate, Locale, gematriya, getBirthdayOrAnniversary_ as getBirthdayOrAnniversary, getYahrzeit_ as getYahrzeit, greg, months, version };
|