@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.
@@ -1,4 +1,4 @@
1
- /*! @hebcal/core v3.33.2 */
1
+ /*! @hebcal/core v3.33.5 */
2
2
  var hebcal = (function (exports) {
3
3
  'use strict';
4
4
 
@@ -202,6 +202,21 @@ function _createClass(Constructor, protoProps, staticProps) {
202
202
  return Constructor;
203
203
  }
204
204
 
205
+ function _defineProperty(obj, key, value) {
206
+ if (key in obj) {
207
+ Object.defineProperty(obj, key, {
208
+ value: value,
209
+ enumerable: true,
210
+ configurable: true,
211
+ writable: true
212
+ });
213
+ } else {
214
+ obj[key] = value;
215
+ }
216
+
217
+ return obj;
218
+ }
219
+
205
220
  /*
206
221
  Hebcal - A Jewish Calendar Generator
207
222
  Copyright (c) 1994-2020 Danny Sadinoff
@@ -245,148 +260,172 @@ function quotient(x, y) {
245
260
  }
246
261
  /**
247
262
  * Gregorian date helper functions.
248
- * @namespace
249
263
  */
250
264
 
251
265
 
252
- var greg = {
253
- /**
254
- * Long names of the Gregorian months (1='January', 12='December')
255
- * @readonly
256
- * @type {string[]}
257
- */
258
- monthNames: ['', 'January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'],
266
+ var greg = /*#__PURE__*/function () {
267
+ function greg() {
268
+ _classCallCheck(this, greg);
269
+ }
259
270
 
260
- /**
261
- * Returns true if the Gregorian year is a leap year
262
- * @param {number} year Gregorian year
263
- * @return {boolean}
264
- */
265
- isLeapYear: function isLeapYear(year) {
266
- return !(year % 4) && (!!(year % 100) || !(year % 400));
267
- },
271
+ _createClass(greg, null, [{
272
+ key: "isLeapYear",
273
+ value:
274
+ /**
275
+ * Long names of the Gregorian months (1='January', 12='December')
276
+ * @readonly
277
+ * @type {string[]}
278
+ */
268
279
 
269
- /**
270
- * Number of days in the Gregorian month for given year
271
- * @param {number} month Gregorian month (1=January, 12=December)
272
- * @param {number} year Gregorian year
273
- * @return {number}
274
- */
275
- daysInMonth: function daysInMonth(month, year) {
276
- // 1 based months
277
- return monthLengths[+this.isLeapYear(year)][month];
278
- },
280
+ /**
281
+ * Returns true if the Gregorian year is a leap year
282
+ * @param {number} year Gregorian year
283
+ * @return {boolean}
284
+ */
285
+ function isLeapYear(year) {
286
+ return !(year % 4) && (!!(year % 100) || !(year % 400));
287
+ }
288
+ /**
289
+ * Number of days in the Gregorian month for given year
290
+ * @param {number} month Gregorian month (1=January, 12=December)
291
+ * @param {number} year Gregorian year
292
+ * @return {number}
293
+ */
279
294
 
280
- /**
281
- * Returns true if the object is a Javascript Date
282
- * @param {Object} obj
283
- * @return {boolean}
284
- */
285
- isDate: function isDate(obj) {
286
- return _typeof(obj) === 'object' && Date.prototype === obj.__proto__;
287
- },
295
+ }, {
296
+ key: "daysInMonth",
297
+ value: function daysInMonth(month, year) {
298
+ // 1 based months
299
+ return monthLengths[+this.isLeapYear(year)][month];
300
+ }
301
+ /**
302
+ * Returns true if the object is a Javascript Date
303
+ * @param {Object} obj
304
+ * @return {boolean}
305
+ */
288
306
 
289
- /**
290
- * Returns number of days since January 1 of that year
291
- * @param {Date} date Gregorian date
292
- * @return {number}
293
- */
294
- dayOfYear: function dayOfYear(date) {
295
- if (!this.isDate(date)) {
296
- throw new TypeError('Argument to greg.dayOfYear not a Date');
307
+ }, {
308
+ key: "isDate",
309
+ value: function isDate(obj) {
310
+ return _typeof(obj) === 'object' && Date.prototype === obj.__proto__;
297
311
  }
312
+ /**
313
+ * Returns number of days since January 1 of that year
314
+ * @param {Date} date Gregorian date
315
+ * @return {number}
316
+ */
317
+
318
+ }, {
319
+ key: "dayOfYear",
320
+ value: function dayOfYear(date) {
321
+ if (!this.isDate(date)) {
322
+ throw new TypeError('Argument to greg.dayOfYear not a Date');
323
+ }
298
324
 
299
- var doy = date.getDate() + 31 * date.getMonth();
325
+ var doy = date.getDate() + 31 * date.getMonth();
300
326
 
301
- if (date.getMonth() > 1) {
302
- // FEB
303
- doy -= Math.floor((4 * (date.getMonth() + 1) + 23) / 10);
327
+ if (date.getMonth() > 1) {
328
+ // FEB
329
+ doy -= Math.floor((4 * (date.getMonth() + 1) + 23) / 10);
304
330
 
305
- if (this.isLeapYear(date.getFullYear())) {
306
- doy++;
331
+ if (this.isLeapYear(date.getFullYear())) {
332
+ doy++;
333
+ }
307
334
  }
335
+
336
+ return doy;
308
337
  }
338
+ /**
339
+ * Converts Gregorian date to absolute R.D. (Rata Die) days
340
+ * @param {Date} date Gregorian date
341
+ * @return {number}
342
+ */
309
343
 
310
- return doy;
311
- },
344
+ }, {
345
+ key: "greg2abs",
346
+ value: function greg2abs(date) {
347
+ if (!this.isDate(date)) {
348
+ throw new TypeError('Argument to greg.greg2abs not a Date');
349
+ }
312
350
 
313
- /**
314
- * Converts Gregorian date to absolute R.D. (Rata Die) days
315
- * @param {Date} date Gregorian date
316
- * @return {number}
317
- */
318
- greg2abs: function greg2abs(date) {
319
- if (!this.isDate(date)) {
320
- throw new TypeError('Argument to greg.greg2abs not a Date');
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
321
357
  }
358
+ /**
359
+ * @private
360
+ * @param {number} theDate - R.D. number of days
361
+ * @return {number}
362
+ */
322
363
 
323
- var year = date.getFullYear() - 1;
324
- return this.dayOfYear(date) + // days this year
325
- 365 * year + ( // + days in prior years
326
- Math.floor(year / 4) - // + Julian Leap years
327
- Math.floor(year / 100) + // - century years
328
- Math.floor(year / 400)); // + Gregorian leap years
329
- },
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
+ */
330
385
 
331
- /**
332
- * @private
333
- * @param {number} theDate - R.D. number of days
334
- * @return {number}
335
- */
336
- yearFromFixed: function yearFromFixed(theDate) {
337
- var l0 = theDate - 1;
338
- var n400 = quotient(l0, 146097);
339
- var d1 = mod(l0, 146097);
340
- var n100 = quotient(d1, 36524);
341
- var d2 = mod(d1, 36524);
342
- var n4 = quotient(d2, 1461);
343
- var d3 = mod(d2, 1461);
344
- var n1 = quotient(d3, 365);
345
- var year = 400 * n400 + 100 * n100 + 4 * n4 + n1;
346
- return n100 != 4 && n1 != 4 ? year + 1 : year;
347
- },
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;
391
+ }
392
+ /**
393
+ * Converts from Rata Die (R.D. number) to Gregorian date.
394
+ * See the footnote on page 384 of ``Calendrical Calculations, Part II:
395
+ * Three Historical Calendars'' by E. M. Reingold, N. Dershowitz, and S. M.
396
+ * Clamen, Software--Practice and Experience, Volume 23, Number 4
397
+ * (April, 1993), pages 383-404 for an explanation.
398
+ * @param {number} theDate - R.D. number of days
399
+ * @return {Date}
400
+ */
348
401
 
349
- /**
350
- * @private
351
- * @param {number} year
352
- * @param {number} month
353
- * @param {number} day
354
- * @return {number}
355
- */
356
- toFixed: function toFixed(year, month, day) {
357
- var py = year - 1;
358
- 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;
359
- },
402
+ }, {
403
+ key: "abs2greg",
404
+ value: function abs2greg(theDate) {
405
+ if (typeof theDate !== 'number') {
406
+ throw new TypeError('Argument to greg.abs2greg not a Number');
407
+ }
360
408
 
361
- /**
362
- * Converts from Rata Die (R.D. number) to Gregorian date.
363
- * See the footnote on page 384 of ``Calendrical Calculations, Part II:
364
- * Three Historical Calendars'' by E. M. Reingold, N. Dershowitz, and S. M.
365
- * Clamen, Software--Practice and Experience, Volume 23, Number 4
366
- * (April, 1993), pages 383-404 for an explanation.
367
- * @param {number} theDate - R.D. number of days
368
- * @return {Date}
369
- */
370
- abs2greg: function abs2greg(theDate) {
371
- if (typeof theDate !== 'number') {
372
- throw new TypeError('Argument to greg.abs2greg not a Number');
373
- }
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);
374
416
 
375
- theDate = Math.trunc(theDate);
376
- var year = this.yearFromFixed(theDate);
377
- var priorDays = theDate - this.toFixed(year, 1, 1);
378
- var correction = theDate < this.toFixed(year, 3, 1) ? 0 : this.isLeapYear(year) ? 1 : 2;
379
- var month = quotient(12 * (priorDays + correction) + 373, 367);
380
- var day = theDate - this.toFixed(year, month, 1) + 1;
381
- var dt = new Date(year, month - 1, day);
417
+ if (year < 100 && year >= 0) {
418
+ dt.setFullYear(year);
419
+ }
382
420
 
383
- if (year < 100 && year >= 0) {
384
- dt.setFullYear(year);
421
+ return dt;
385
422
  }
423
+ }]);
386
424
 
387
- return dt;
388
- }
389
- };
425
+ return greg;
426
+ }();
427
+
428
+ _defineProperty(greg, "monthNames", ['', 'January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December']);
390
429
 
391
430
  var noopLocale = {
392
431
  headers: {
@@ -409,177 +448,206 @@ var alias = {
409
448
  * * `ashkenazi` - Ashkenazi transliterations (e.g. "Shabbos")
410
449
  * * `he` - Hebrew (e.g. "שַׁבָּת")
411
450
  * * `he-x-NoNikud` - Hebrew without nikud (e.g. "שבת")
412
- * @namespace
413
451
  */
414
452
 
415
- var Locale = {
416
- /** @private */
417
- locales: Object.create(null),
453
+ var Locale = /*#__PURE__*/function () {
454
+ function Locale() {
455
+ _classCallCheck(this, Locale);
456
+ }
418
457
 
419
- /** @private */
420
- activeLocale: null,
458
+ _createClass(Locale, null, [{
459
+ key: "lookupTranslation",
460
+ value:
461
+ /** @private */
421
462
 
422
- /** @private */
423
- activeName: null,
463
+ /** @private */
424
464
 
425
- /**
426
- * Returns translation only if `locale` offers a non-empty translation for `id`.
427
- * Otherwise, returns `undefined`.
428
- * @param {string} id Message ID to translate
429
- * @param {string} [locale] Optional locale name (i.e: `'he'`, `'fr'`). Defaults to active locale.
430
- * @return {string}
431
- */
432
- lookupTranslation: function lookupTranslation(id, locale) {
433
- var locale0 = locale && locale.toLowerCase();
434
- var loc = typeof locale == 'string' && this.locales[locale0] || this.activeLocale;
435
- var array = loc[id];
465
+ /** @private */
466
+
467
+ /**
468
+ * Returns translation only if `locale` offers a non-empty translation for `id`.
469
+ * Otherwise, returns `undefined`.
470
+ * @param {string} id Message ID to translate
471
+ * @param {string} [locale] Optional locale name (i.e: `'he'`, `'fr'`). Defaults to active locale.
472
+ * @return {string}
473
+ */
474
+ function lookupTranslation(id, locale) {
475
+ var locale0 = locale && locale.toLowerCase();
476
+ var loc = typeof locale == 'string' && this.locales[locale0] || this.activeLocale;
477
+ var array = loc[id];
478
+
479
+ if (array && array.length && array[0].length) {
480
+ return array[0];
481
+ }
436
482
 
437
- if (array && array.length && array[0].length) {
438
- return array[0];
483
+ return undefined;
439
484
  }
485
+ /**
486
+ * By default, if no translation was found, returns `id`.
487
+ * @param {string} id Message ID to translate
488
+ * @param {string} [locale] Optional locale name (i.e: `'he'`, `'fr'`). Defaults to active locale.
489
+ * @return {string}
490
+ */
440
491
 
441
- return undefined;
442
- },
492
+ }, {
493
+ key: "gettext",
494
+ value: function gettext(id, locale) {
495
+ var text = this.lookupTranslation(id, locale);
443
496
 
444
- /**
445
- * By default, if no translation was found, returns `id`.
446
- * @param {string} id Message ID to translate
447
- * @param {string} [locale] Optional locale name (i.e: `'he'`, `'fr'`). Defaults to active locale.
448
- * @return {string}
449
- */
450
- gettext: function gettext(id, locale) {
451
- var text = this.lookupTranslation(id, locale);
497
+ if (typeof text == 'undefined') {
498
+ return id;
499
+ }
452
500
 
453
- if (typeof text == 'undefined') {
454
- return id;
501
+ return text;
455
502
  }
503
+ /**
504
+ * Register locale translations.
505
+ * @param {string} locale Locale name (i.e.: `'he'`, `'fr'`)
506
+ * @param {LocaleDate} data parsed data from a `.po` file.
507
+ */
456
508
 
457
- return text;
458
- },
509
+ }, {
510
+ key: "addLocale",
511
+ value: function addLocale(locale, data) {
512
+ if (_typeof(data.contexts) !== 'object' || _typeof(data.contexts['']) !== 'object') {
513
+ throw new TypeError("Locale '".concat(locale, "' invalid compact format"));
514
+ }
459
515
 
460
- /**
461
- * Register locale translations.
462
- * @param {string} locale Locale name (i.e.: `'he'`, `'fr'`)
463
- * @param {LocaleDate} data parsed data from a `.po` file.
464
- */
465
- addLocale: function addLocale(locale, data) {
466
- if (_typeof(data.contexts) !== 'object' || _typeof(data.contexts['']) !== 'object') {
467
- throw new TypeError("Locale '".concat(locale, "' invalid compact format"));
516
+ this.locales[locale.toLowerCase()] = data.contexts[''];
468
517
  }
518
+ /**
519
+ * Activates a locale. Throws an error if the locale has not been previously added.
520
+ * After setting the locale to be used, all strings marked for translations
521
+ * will be represented by the corresponding translation in the specified locale.
522
+ * @param {string} locale Locale name (i.e: `'he'`, `'fr'`)
523
+ * @return {LocaleData}
524
+ */
469
525
 
470
- this.locales[locale.toLowerCase()] = data.contexts[''];
471
- },
526
+ }, {
527
+ key: "useLocale",
528
+ value: function useLocale(locale) {
529
+ var locale0 = locale.toLowerCase();
530
+ var obj = this.locales[locale0];
472
531
 
473
- /**
474
- * Activates a locale. Throws an error if the locale has not been previously added.
475
- * After setting the locale to be used, all strings marked for translations
476
- * will be represented by the corresponding translation in the specified locale.
477
- * @param {string} locale Locale name (i.e: `'he'`, `'fr'`)
478
- * @return {LocaleData}
479
- */
480
- useLocale: function useLocale(locale) {
481
- var locale0 = locale.toLowerCase();
482
- var obj = this.locales[locale0];
532
+ if (!obj) {
533
+ throw new RangeError("Locale '".concat(locale, "' not found"));
534
+ }
483
535
 
484
- if (!obj) {
485
- throw new RangeError("Locale '".concat(locale, "' not found"));
536
+ this.activeName = alias[locale0] || locale0;
537
+ this.activeLocale = obj;
538
+ return this.activeLocale;
486
539
  }
540
+ /**
541
+ * Returns the name of the active locale (i.e. 'he', 'ashkenazi', 'fr')
542
+ * @return {string}
543
+ */
487
544
 
488
- this.activeName = alias[locale0] || locale0;
489
- this.activeLocale = obj;
490
- return this.activeLocale;
491
- },
545
+ }, {
546
+ key: "getLocaleName",
547
+ value: function getLocaleName() {
548
+ return this.activeName;
549
+ }
550
+ /**
551
+ * Returns the names of registered locales
552
+ * @return {string[]}
553
+ */
492
554
 
493
- /**
494
- * Returns the name of the active locale (i.e. 'he', 'ashkenazi', 'fr')
495
- * @return {string}
496
- */
497
- getLocaleName: function getLocaleName() {
498
- return this.activeName;
499
- },
555
+ }, {
556
+ key: "getLocaleNames",
557
+ value: function getLocaleNames() {
558
+ return Object.keys(this.locales).sort();
559
+ }
560
+ /**
561
+ * @param {number} n
562
+ * @param {string} [locale] Optional locale name (i.e: `'he'`, `'fr'`). Defaults to active locale.
563
+ * @return {string}
564
+ */
500
565
 
501
- /**
502
- * Returns the names of registered locales
503
- * @return {string[]}
504
- */
505
- getLocaleNames: function getLocaleNames() {
506
- return Object.keys(this.locales).sort();
507
- },
566
+ }, {
567
+ key: "ordinal",
568
+ value: function ordinal(n, locale) {
569
+ var locale1 = locale && locale.toLowerCase();
570
+ var locale0 = locale1 || this.activeName;
508
571
 
509
- /**
510
- * @param {number} n
511
- * @param {string} [locale] Optional locale name (i.e: `'he'`, `'fr'`). Defaults to active locale.
512
- * @return {string}
513
- */
514
- ordinal: function ordinal(n, locale) {
515
- var locale1 = locale && locale.toLowerCase();
516
- var locale0 = locale1 || this.activeName;
517
-
518
- if (!locale0) {
519
- return this.getEnOrdinal(n);
520
- }
521
-
522
- switch (locale0) {
523
- case 'en':
524
- case 's':
525
- case 'a':
526
- case 'ashkenazi':
527
- case 'ashkenazi_litvish':
528
- case 'ashkenazi_poylish':
529
- case 'ashkenazi_standard':
572
+ if (!locale0) {
530
573
  return this.getEnOrdinal(n);
574
+ }
575
+
576
+ switch (locale0) {
577
+ case 'en':
578
+ case 's':
579
+ case 'a':
580
+ case 'ashkenazi':
581
+ case 'ashkenazi_litvish':
582
+ case 'ashkenazi_poylish':
583
+ case 'ashkenazi_standard':
584
+ return this.getEnOrdinal(n);
531
585
 
532
- case 'es':
533
- return n + 'º';
586
+ case 'es':
587
+ return n + 'º';
534
588
 
535
- case 'h':
536
- case 'he':
537
- case 'he-x-nonikud':
538
- return String(n);
589
+ case 'h':
590
+ case 'he':
591
+ case 'he-x-nonikud':
592
+ return String(n);
539
593
 
540
- default:
541
- return n + '.';
594
+ default:
595
+ return n + '.';
596
+ }
542
597
  }
543
- },
598
+ /**
599
+ * @private
600
+ * @param {number} n
601
+ * @return {string}
602
+ */
544
603
 
545
- /**
546
- * @private
547
- * @param {number} n
548
- * @return {string}
549
- */
550
- getEnOrdinal: function getEnOrdinal(n) {
551
- var s = ['th', 'st', 'nd', 'rd'];
552
- var v = n % 100;
553
- return n + (s[(v - 20) % 10] || s[v] || s[0]);
554
- },
604
+ }, {
605
+ key: "getEnOrdinal",
606
+ value: function getEnOrdinal(n) {
607
+ var s = ['th', 'st', 'nd', 'rd'];
608
+ var v = n % 100;
609
+ return n + (s[(v - 20) % 10] || s[v] || s[0]);
610
+ }
611
+ /**
612
+ * Removes nekudot from Hebrew string
613
+ * @param {string} str
614
+ * @return {string}
615
+ */
616
+
617
+ }, {
618
+ key: "hebrewStripNikkud",
619
+ value: function hebrewStripNikkud(str) {
620
+ return str.replace(/[\u0590-\u05bd]/g, '').replace(/[\u05bf-\u05c7]/g, '');
621
+ }
622
+ }]);
623
+
624
+ return Locale;
625
+ }();
626
+
627
+ _defineProperty(Locale, "locales", Object.create(null));
628
+
629
+ _defineProperty(Locale, "activeLocale", null);
630
+
631
+ _defineProperty(Locale, "activeName", null);
555
632
 
556
- /**
557
- * Removes nekudot from Hebrew string
558
- * @param {string} str
559
- * @return {string}
560
- */
561
- hebrewStripNikkud: function hebrewStripNikkud(str) {
562
- return str.replace(/[\u0590-\u05bd]/g, '').replace(/[\u05bf-\u05c7]/g, '');
563
- }
564
- };
565
633
  Locale.addLocale('en', noopLocale);
566
634
  Locale.addLocale('s', noopLocale);
567
635
  Locale.addLocale('', noopLocale);
568
636
  Locale.useLocale('en');
569
637
 
570
- var NISAN = 1;
638
+ var NISAN$1 = 1;
571
639
  var IYYAR = 2;
572
640
  var SIVAN = 3;
573
641
  var TAMUZ = 4;
574
642
  var AV = 5;
575
643
  var ELUL = 6;
576
644
  var TISHREI = 7;
577
- var CHESHVAN = 8;
578
- var KISLEV = 9;
579
- var TEVET = 10;
580
- var SHVAT = 11;
581
- var ADAR_I = 12;
582
- var ADAR_II = 13;
645
+ var CHESHVAN$1 = 8;
646
+ var KISLEV$1 = 9;
647
+ var TEVET$1 = 10;
648
+ var SHVAT$1 = 11;
649
+ var ADAR_I$1 = 12;
650
+ var ADAR_II$1 = 13;
583
651
  /**
584
652
  * Hebrew months of the year (NISAN=1, TISHREI=7)
585
653
  * @readonly
@@ -984,7 +1052,7 @@ var HDate = /*#__PURE__*/function () {
984
1052
  * @example
985
1053
  * import {HDate, months} from '@hebcal/core';
986
1054
  * const hd = new HDate(15, months.CHESHVAN, 5769);
987
- * console.log(ev.renderGematriya()); // 'ט״ו חֶשְׁוָן תשס״ט'
1055
+ * console.log(hd.renderGematriya()); // 'ט״ו חֶשְׁוָן תשס״ט'
988
1056
  * @return {string}
989
1057
  */
990
1058
  function renderGematriya() {
@@ -1240,7 +1308,7 @@ var HDate = /*#__PURE__*/function () {
1240
1308
  tempabs += HDate.daysInMonth(m, year);
1241
1309
  }
1242
1310
 
1243
- for (var _m = NISAN; _m < month; _m++) {
1311
+ for (var _m = NISAN$1; _m < month; _m++) {
1244
1312
  tempabs += HDate.daysInMonth(_m, year);
1245
1313
  }
1246
1314
  } else {
@@ -1372,7 +1440,7 @@ var HDate = /*#__PURE__*/function () {
1372
1440
  }, {
1373
1441
  key: "daysInMonth",
1374
1442
  value: function daysInMonth(month, year) {
1375
- 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)) {
1443
+ 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)) {
1376
1444
  return 29;
1377
1445
  } else {
1378
1446
  return 30;
@@ -1518,7 +1586,7 @@ var HDate = /*#__PURE__*/function () {
1518
1586
  /* this catches "november" */
1519
1587
  }
1520
1588
 
1521
- return NISAN;
1589
+ return NISAN$1;
1522
1590
 
1523
1591
  case 'i':
1524
1592
  return IYYAR;
@@ -1528,11 +1596,11 @@ var HDate = /*#__PURE__*/function () {
1528
1596
 
1529
1597
  case 'c':
1530
1598
  case 'ח':
1531
- return CHESHVAN;
1599
+ return CHESHVAN$1;
1532
1600
 
1533
1601
  case 'k':
1534
1602
  case 'כ':
1535
- return KISLEV;
1603
+ return KISLEV$1;
1536
1604
 
1537
1605
  case 's':
1538
1606
  switch (c[1]) {
@@ -1540,7 +1608,7 @@ var HDate = /*#__PURE__*/function () {
1540
1608
  return SIVAN;
1541
1609
 
1542
1610
  case 'h':
1543
- return SHVAT;
1611
+ return SHVAT$1;
1544
1612
  }
1545
1613
 
1546
1614
  case 't':
@@ -1552,7 +1620,7 @@ var HDate = /*#__PURE__*/function () {
1552
1620
  return TISHREI;
1553
1621
 
1554
1622
  case 'e':
1555
- return TEVET;
1623
+ return TEVET$1;
1556
1624
  }
1557
1625
 
1558
1626
  break;
@@ -1564,10 +1632,10 @@ var HDate = /*#__PURE__*/function () {
1564
1632
 
1565
1633
  case 'd':
1566
1634
  if (/(1|[^i]i|a|א)$/i.test(monthName)) {
1567
- return ADAR_I;
1635
+ return ADAR_I$1;
1568
1636
  }
1569
1637
 
1570
- return ADAR_II;
1638
+ return ADAR_II$1;
1571
1639
  // else assume sheini
1572
1640
  }
1573
1641
 
@@ -1577,10 +1645,10 @@ var HDate = /*#__PURE__*/function () {
1577
1645
  return SIVAN;
1578
1646
 
1579
1647
  case 'ט':
1580
- return TEVET;
1648
+ return TEVET$1;
1581
1649
 
1582
1650
  case 'ש':
1583
- return SHVAT;
1651
+ return SHVAT$1;
1584
1652
 
1585
1653
  case 'א':
1586
1654
  switch (c[1]) {
@@ -1589,10 +1657,10 @@ var HDate = /*#__PURE__*/function () {
1589
1657
 
1590
1658
  case 'ד':
1591
1659
  if (/(1|[^i]i|a|א)$/i.test(monthName)) {
1592
- return ADAR_I;
1660
+ return ADAR_I$1;
1593
1661
  }
1594
1662
 
1595
- return ADAR_II;
1663
+ return ADAR_II$1;
1596
1664
  // else assume sheini
1597
1665
 
1598
1666
  case 'י':
@@ -1693,7 +1761,7 @@ function fixDate(date) {
1693
1761
 
1694
1762
 
1695
1763
  function fixMonth(date) {
1696
- if (date.month == ADAR_II && !date.isLeapYear()) {
1764
+ if (date.month == ADAR_II$1 && !date.isLeapYear()) {
1697
1765
  date.month -= 1; // to Adar I
1698
1766
 
1699
1767
  fix(date);
@@ -1722,7 +1790,100 @@ function _onOrBefore(day, t, offset) {
1722
1790
  return new HDate(HDate.dayOnOrBefore(day, t.abs() + offset));
1723
1791
  }
1724
1792
 
1725
- var version="3.33.2";
1793
+ var NISAN = months.NISAN;
1794
+ var CHESHVAN = months.CHESHVAN;
1795
+ var KISLEV = months.KISLEV;
1796
+ var TEVET = months.TEVET;
1797
+ var SHVAT = months.SHVAT;
1798
+ var ADAR_I = months.ADAR_I;
1799
+ var ADAR_II = months.ADAR_II;
1800
+ /**
1801
+ * @private
1802
+ * @param {number} hyear Hebrew year
1803
+ * @param {Date|HDate} gdate Gregorian or Hebrew date of death
1804
+ * @return {HDate} anniversary occurring in hyear
1805
+ */
1806
+
1807
+ function getYahrzeit_(hyear, gdate) {
1808
+ var orig = HDate.isHDate(gdate) ? gdate : new HDate(gdate);
1809
+ var hDeath = {
1810
+ yy: orig.getFullYear(),
1811
+ mm: orig.getMonth(),
1812
+ dd: orig.getDate()
1813
+ };
1814
+
1815
+ if (hyear <= hDeath.yy) {
1816
+ // `Hebrew year ${hyear} occurs on or before original date in ${hDeath.yy}`
1817
+ return undefined;
1818
+ }
1819
+
1820
+ if (hDeath.mm == CHESHVAN && hDeath.dd == 30 && !HDate.longCheshvan(hDeath.yy + 1)) {
1821
+ // If it's Heshvan 30 it depends on the first anniversary;
1822
+ // if that was not Heshvan 30, use the day before Kislev 1.
1823
+ hDeath = HDate.abs2hebrew(HDate.hebrew2abs(hyear, KISLEV, 1) - 1);
1824
+ } else if (hDeath.mm == KISLEV && hDeath.dd == 30 && HDate.shortKislev(hDeath.yy + 1)) {
1825
+ // If it's Kislev 30 it depends on the first anniversary;
1826
+ // if that was not Kislev 30, use the day before Teveth 1.
1827
+ hDeath = HDate.abs2hebrew(HDate.hebrew2abs(hyear, TEVET, 1) - 1);
1828
+ } else if (hDeath.mm == ADAR_II) {
1829
+ // If it's Adar II, use the same day in last month of year (Adar or Adar II).
1830
+ hDeath.mm = HDate.monthsInYear(hyear);
1831
+ } else if (hDeath.mm == ADAR_I && hDeath.dd == 30 && !HDate.isLeapYear(hyear)) {
1832
+ // If it's the 30th in Adar I and year is not a leap year
1833
+ // (so Adar has only 29 days), use the last day in Shevat.
1834
+ hDeath.dd = 30;
1835
+ hDeath.mm = SHVAT;
1836
+ } // In all other cases, use the normal anniversary of the date of death.
1837
+ // advance day to rosh chodesh if needed
1838
+
1839
+
1840
+ if (hDeath.mm == CHESHVAN && hDeath.dd == 30 && !HDate.longCheshvan(hyear)) {
1841
+ hDeath.mm = KISLEV;
1842
+ hDeath.dd = 1;
1843
+ } else if (hDeath.mm == KISLEV && hDeath.dd == 30 && HDate.shortKislev(hyear)) {
1844
+ hDeath.mm = TEVET;
1845
+ hDeath.dd = 1;
1846
+ }
1847
+
1848
+ return new HDate(hDeath.dd, hDeath.mm, hyear);
1849
+ }
1850
+ /**
1851
+ * @private
1852
+ * @param {number} hyear Hebrew year
1853
+ * @param {Date|HDate} gdate Gregorian or Hebrew date of event
1854
+ * @return {HDate} anniversary occurring in `hyear`
1855
+ */
1856
+
1857
+ function getBirthdayOrAnniversary_(hyear, gdate) {
1858
+ var orig = HDate.isHDate(gdate) ? gdate : new HDate(gdate);
1859
+ var origYear = orig.getFullYear();
1860
+
1861
+ if (hyear <= origYear) {
1862
+ // `Hebrew year ${hyear} occurs on or before original date in ${origYear}`
1863
+ return undefined;
1864
+ }
1865
+
1866
+ var isOrigLeap = HDate.isLeapYear(origYear);
1867
+ var month = orig.getMonth();
1868
+ var day = orig.getDate();
1869
+
1870
+ if (month == ADAR_I && !isOrigLeap || month == ADAR_II && isOrigLeap) {
1871
+ month = HDate.monthsInYear(hyear);
1872
+ } else if (month == CHESHVAN && day == 30 && !HDate.longCheshvan(hyear)) {
1873
+ month = KISLEV;
1874
+ day = 1;
1875
+ } else if (month == KISLEV && day == 30 && HDate.shortKislev(hyear)) {
1876
+ month = TEVET;
1877
+ day = 1;
1878
+ } else if (month == ADAR_I && day == 30 && isOrigLeap && !HDate.isLeapYear(hyear)) {
1879
+ month = NISAN;
1880
+ day = 1;
1881
+ }
1882
+
1883
+ return new HDate(day, month, hyear);
1884
+ }
1885
+
1886
+ var version="3.33.5";
1726
1887
 
1727
1888
  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};
1728
1889
 
@@ -1732,6 +1893,8 @@ Locale.addLocale('h', poHeMin);
1732
1893
  exports.HDate = HDate;
1733
1894
  exports.Locale = Locale;
1734
1895
  exports.gematriya = gematriya;
1896
+ exports.getBirthdayOrAnniversary = getBirthdayOrAnniversary_;
1897
+ exports.getYahrzeit = getYahrzeit_;
1735
1898
  exports.greg = greg;
1736
1899
  exports.months = months;
1737
1900
  exports.version = version;