@hebcal/core 3.33.3 → 3.33.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/hdate.mjs CHANGED
@@ -1,4 +1,4 @@
1
- /*! @hebcal/core v3.33.3 */
1
+ /*! @hebcal/core v3.33.4 */
2
2
  const GERESH = '׳';
3
3
  const GERSHAYIM = '״';
4
4
  /**
@@ -549,19 +549,19 @@ Locale.useLocale('en');
549
549
  You should have received a copy of the GNU General Public License
550
550
  along with this program. If not, see <http://www.gnu.org/licenses/>.
551
551
  */
552
- const NISAN = 1;
552
+ const NISAN$1 = 1;
553
553
  const IYYAR = 2;
554
554
  const SIVAN = 3;
555
555
  const TAMUZ = 4;
556
556
  const AV = 5;
557
557
  const ELUL = 6;
558
558
  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;
559
+ const CHESHVAN$1 = 8;
560
+ const KISLEV$1 = 9;
561
+ const TEVET$1 = 10;
562
+ const SHVAT$1 = 11;
563
+ const ADAR_I$1 = 12;
564
+ const ADAR_II$1 = 13;
565
565
  /**
566
566
  * Hebrew months of the year (NISAN=1, TISHREI=7)
567
567
  * @readonly
@@ -903,7 +903,7 @@ class HDate {
903
903
  tempabs += HDate.daysInMonth(m, year);
904
904
  }
905
905
 
906
- for (let m = NISAN; m < month; m++) {
906
+ for (let m = NISAN$1; m < month; m++) {
907
907
  tempabs += HDate.daysInMonth(m, year);
908
908
  }
909
909
  } else {
@@ -1049,7 +1049,7 @@ class HDate {
1049
1049
  * @example
1050
1050
  * import {HDate, months} from '@hebcal/core';
1051
1051
  * const hd = new HDate(15, months.CHESHVAN, 5769);
1052
- * console.log(ev.renderGematriya()); // 'ט״ו חֶשְׁוָן תשס״ט'
1052
+ * console.log(hd.renderGematriya()); // 'ט״ו חֶשְׁוָן תשס״ט'
1053
1053
  * @return {string}
1054
1054
  */
1055
1055
 
@@ -1311,7 +1311,7 @@ class HDate {
1311
1311
 
1312
1312
 
1313
1313
  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)) {
1314
+ 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
1315
  return 29;
1316
1316
  } else {
1317
1317
  return 30;
@@ -1449,7 +1449,7 @@ class HDate {
1449
1449
  /* this catches "november" */
1450
1450
  }
1451
1451
 
1452
- return NISAN;
1452
+ return NISAN$1;
1453
1453
 
1454
1454
  case 'i':
1455
1455
  return IYYAR;
@@ -1459,11 +1459,11 @@ class HDate {
1459
1459
 
1460
1460
  case 'c':
1461
1461
  case 'ח':
1462
- return CHESHVAN;
1462
+ return CHESHVAN$1;
1463
1463
 
1464
1464
  case 'k':
1465
1465
  case 'כ':
1466
- return KISLEV;
1466
+ return KISLEV$1;
1467
1467
 
1468
1468
  case 's':
1469
1469
  switch (c[1]) {
@@ -1471,7 +1471,7 @@ class HDate {
1471
1471
  return SIVAN;
1472
1472
 
1473
1473
  case 'h':
1474
- return SHVAT;
1474
+ return SHVAT$1;
1475
1475
  }
1476
1476
 
1477
1477
  case 't':
@@ -1483,7 +1483,7 @@ class HDate {
1483
1483
  return TISHREI;
1484
1484
 
1485
1485
  case 'e':
1486
- return TEVET;
1486
+ return TEVET$1;
1487
1487
  }
1488
1488
 
1489
1489
  break;
@@ -1495,10 +1495,10 @@ class HDate {
1495
1495
 
1496
1496
  case 'd':
1497
1497
  if (/(1|[^i]i|a|א)$/i.test(monthName)) {
1498
- return ADAR_I;
1498
+ return ADAR_I$1;
1499
1499
  }
1500
1500
 
1501
- return ADAR_II;
1501
+ return ADAR_II$1;
1502
1502
  // else assume sheini
1503
1503
  }
1504
1504
 
@@ -1508,10 +1508,10 @@ class HDate {
1508
1508
  return SIVAN;
1509
1509
 
1510
1510
  case 'ט':
1511
- return TEVET;
1511
+ return TEVET$1;
1512
1512
 
1513
1513
  case 'ש':
1514
- return SHVAT;
1514
+ return SHVAT$1;
1515
1515
 
1516
1516
  case 'א':
1517
1517
  switch (c[1]) {
@@ -1520,10 +1520,10 @@ class HDate {
1520
1520
 
1521
1521
  case 'ד':
1522
1522
  if (/(1|[^i]i|a|א)$/i.test(monthName)) {
1523
- return ADAR_I;
1523
+ return ADAR_I$1;
1524
1524
  }
1525
1525
 
1526
- return ADAR_II;
1526
+ return ADAR_II$1;
1527
1527
  // else assume sheini
1528
1528
 
1529
1529
  case 'י':
@@ -1620,7 +1620,7 @@ function fixDate(date) {
1620
1620
 
1621
1621
 
1622
1622
  function fixMonth(date) {
1623
- if (date.month == ADAR_II && !date.isLeapYear()) {
1623
+ if (date.month == ADAR_II$1 && !date.isLeapYear()) {
1624
1624
  date.month -= 1; // to Adar I
1625
1625
 
1626
1626
  fix(date);
@@ -1649,11 +1649,104 @@ function onOrBefore(day, t, offset) {
1649
1649
  return new HDate(HDate.dayOnOrBefore(day, t.abs() + offset));
1650
1650
  }
1651
1651
 
1652
- var version="3.33.3";
1652
+ const NISAN = months.NISAN;
1653
+ const CHESHVAN = months.CHESHVAN;
1654
+ const KISLEV = months.KISLEV;
1655
+ const TEVET = months.TEVET;
1656
+ const SHVAT = months.SHVAT;
1657
+ const ADAR_I = months.ADAR_I;
1658
+ const ADAR_II = months.ADAR_II;
1659
+ /**
1660
+ * @private
1661
+ * @param {number} hyear Hebrew year
1662
+ * @param {Date|HDate} gdate Gregorian or Hebrew date of death
1663
+ * @return {HDate} anniversary occurring in hyear
1664
+ */
1665
+
1666
+ function getYahrzeit_(hyear, gdate) {
1667
+ const orig = HDate.isHDate(gdate) ? gdate : new HDate(gdate);
1668
+ let hDeath = {
1669
+ yy: orig.getFullYear(),
1670
+ mm: orig.getMonth(),
1671
+ dd: orig.getDate()
1672
+ };
1673
+
1674
+ if (hyear <= hDeath.yy) {
1675
+ // `Hebrew year ${hyear} occurs on or before original date in ${hDeath.yy}`
1676
+ return undefined;
1677
+ }
1678
+
1679
+ if (hDeath.mm == CHESHVAN && hDeath.dd == 30 && !HDate.longCheshvan(hDeath.yy + 1)) {
1680
+ // If it's Heshvan 30 it depends on the first anniversary;
1681
+ // if that was not Heshvan 30, use the day before Kislev 1.
1682
+ hDeath = HDate.abs2hebrew(HDate.hebrew2abs(hyear, KISLEV, 1) - 1);
1683
+ } else if (hDeath.mm == KISLEV && hDeath.dd == 30 && HDate.shortKislev(hDeath.yy + 1)) {
1684
+ // If it's Kislev 30 it depends on the first anniversary;
1685
+ // if that was not Kislev 30, use the day before Teveth 1.
1686
+ hDeath = HDate.abs2hebrew(HDate.hebrew2abs(hyear, TEVET, 1) - 1);
1687
+ } else if (hDeath.mm == ADAR_II) {
1688
+ // If it's Adar II, use the same day in last month of year (Adar or Adar II).
1689
+ hDeath.mm = HDate.monthsInYear(hyear);
1690
+ } else if (hDeath.mm == ADAR_I && hDeath.dd == 30 && !HDate.isLeapYear(hyear)) {
1691
+ // If it's the 30th in Adar I and year is not a leap year
1692
+ // (so Adar has only 29 days), use the last day in Shevat.
1693
+ hDeath.dd = 30;
1694
+ hDeath.mm = SHVAT;
1695
+ } // In all other cases, use the normal anniversary of the date of death.
1696
+ // advance day to rosh chodesh if needed
1697
+
1698
+
1699
+ if (hDeath.mm == CHESHVAN && hDeath.dd == 30 && !HDate.longCheshvan(hyear)) {
1700
+ hDeath.mm = KISLEV;
1701
+ hDeath.dd = 1;
1702
+ } else if (hDeath.mm == KISLEV && hDeath.dd == 30 && HDate.shortKislev(hyear)) {
1703
+ hDeath.mm = TEVET;
1704
+ hDeath.dd = 1;
1705
+ }
1706
+
1707
+ return new HDate(hDeath.dd, hDeath.mm, hyear);
1708
+ }
1709
+ /**
1710
+ * @private
1711
+ * @param {number} hyear Hebrew year
1712
+ * @param {Date|HDate} gdate Gregorian or Hebrew date of event
1713
+ * @return {HDate} anniversary occurring in `hyear`
1714
+ */
1715
+
1716
+ function getBirthdayOrAnniversary_(hyear, gdate) {
1717
+ const orig = HDate.isHDate(gdate) ? gdate : new HDate(gdate);
1718
+ const origYear = orig.getFullYear();
1719
+
1720
+ if (hyear <= origYear) {
1721
+ // `Hebrew year ${hyear} occurs on or before original date in ${origYear}`
1722
+ return undefined;
1723
+ }
1724
+
1725
+ const isOrigLeap = HDate.isLeapYear(origYear);
1726
+ let month = orig.getMonth();
1727
+ let day = orig.getDate();
1728
+
1729
+ if (month == ADAR_I && !isOrigLeap || month == ADAR_II && isOrigLeap) {
1730
+ month = HDate.monthsInYear(hyear);
1731
+ } else if (month == CHESHVAN && day == 30 && !HDate.longCheshvan(hyear)) {
1732
+ month = KISLEV;
1733
+ day = 1;
1734
+ } else if (month == KISLEV && day == 30 && HDate.shortKislev(hyear)) {
1735
+ month = TEVET;
1736
+ day = 1;
1737
+ } else if (month == ADAR_I && day == 30 && isOrigLeap && !HDate.isLeapYear(hyear)) {
1738
+ month = NISAN;
1739
+ day = 1;
1740
+ }
1741
+
1742
+ return new HDate(day, month, hyear);
1743
+ }
1744
+
1745
+ var version="3.33.4";
1653
1746
 
1654
1747
  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
1748
 
1656
1749
  Locale.addLocale('he', poHeMin);
1657
1750
  Locale.addLocale('h', poHeMin);
1658
1751
 
1659
- export { HDate, Locale, gematriya, greg, months, version };
1752
+ export { HDate, Locale, gematriya, getBirthdayOrAnniversary_ as getBirthdayOrAnniversary, getYahrzeit_ as getYahrzeit, greg, months, version };