@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/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- /*! @hebcal/core v3.33.3 */
1
+ /*! @hebcal/core v3.33.4 */
2
2
  /*
3
3
  Hebcal - A Jewish Calendar Generator
4
4
  Copyright (c) 1994-2020 Danny Sadinoff
@@ -549,7 +549,7 @@ 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$2 = 1;
552
+ const NISAN$3 = 1;
553
553
  const IYYAR$1 = 2;
554
554
  const SIVAN$2 = 3;
555
555
  const TAMUZ$1 = 4;
@@ -903,7 +903,7 @@ class HDate {
903
903
  tempabs += HDate.daysInMonth(m, year);
904
904
  }
905
905
 
906
- for (let m = NISAN$2; m < month; m++) {
906
+ for (let m = NISAN$3; 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
 
@@ -1449,7 +1449,7 @@ class HDate {
1449
1449
  /* this catches "november" */
1450
1450
  }
1451
1451
 
1452
- return NISAN$2;
1452
+ return NISAN$3;
1453
1453
 
1454
1454
  case 'i':
1455
1455
  return IYYAR$1;
@@ -4386,7 +4386,7 @@ const TUE = 2; // const WED = 3;
4386
4386
  const THU = 4;
4387
4387
  const FRI$1 = 5;
4388
4388
  const SAT$1 = 6;
4389
- const NISAN$1 = months.NISAN;
4389
+ const NISAN$2 = months.NISAN;
4390
4390
  const IYYAR = months.IYYAR;
4391
4391
  const SIVAN$1 = months.SIVAN;
4392
4392
  const TAMUZ = months.TAMUZ;
@@ -4463,7 +4463,7 @@ const sedraCache = new SimpleMap();
4463
4463
  * @return {Sedra}
4464
4464
  */
4465
4465
 
4466
- function getSedra(hyear, il) {
4466
+ function getSedra_(hyear, il) {
4467
4467
  const cacheKey = `${hyear}-${il ? 1 : 0}`;
4468
4468
  let sedra = sedraCache.get(cacheKey);
4469
4469
 
@@ -4488,7 +4488,7 @@ const yearCache = Object.create(null);
4488
4488
  * @return {Map<string,Event[]>}
4489
4489
  */
4490
4490
 
4491
- function getHolidaysForYear(year) {
4491
+ function getHolidaysForYear_(year) {
4492
4492
  if (typeof year !== 'number') {
4493
4493
  throw new TypeError(`bad Hebrew year: ${year}`);
4494
4494
  } else if (year < 1 || year > 32658) {
@@ -4502,7 +4502,7 @@ function getHolidaysForYear(year) {
4502
4502
  }
4503
4503
 
4504
4504
  const RH = new HDate(1, TISHREI$1, year);
4505
- const pesach = new HDate(15, NISAN$1, year);
4505
+ const pesach = new HDate(15, NISAN$2, year);
4506
4506
  const h = new SimpleMap(); // eslint-disable-next-line require-jsdoc
4507
4507
 
4508
4508
  function add(...events) {
@@ -4594,27 +4594,27 @@ function getHolidaysForYear(year) {
4594
4594
  add(new HolidayEvent(new HDate(pesachAbs - (pesach.getDay() == SUN ? 28 : 29)), 'Shushan Purim', MINOR_HOLIDAY$1, {
4595
4595
  emoji: '🎭️📜'
4596
4596
  }), new HolidayEvent(new HDate(HDate.dayOnOrBefore(SAT$1, pesachAbs - 14) - 7), 'Shabbat Parah', SPECIAL_SHABBAT$1), new HolidayEvent(new HDate(HDate.dayOnOrBefore(SAT$1, pesachAbs - 14)), 'Shabbat HaChodesh', SPECIAL_SHABBAT$1), new HolidayEvent(new HDate(HDate.dayOnOrBefore(SAT$1, pesachAbs - 1)), 'Shabbat HaGadol', SPECIAL_SHABBAT$1), new HolidayEvent( // if the fast falls on Shabbat, move to Thursday
4597
- pesach.prev().getDay() == SAT$1 ? pesach.onOrBefore(THU) : new HDate(14, NISAN$1, year), 'Ta\'anit Bechorot', MINOR_FAST$1));
4598
- addEvents(year, [[14, NISAN$1, 'Erev Pesach', EREV$1 | LIGHT_CANDLES$1], // Attributes for Israel and Diaspora are different
4599
- [15, NISAN$1, 'Pesach I', CHAG | YOM_TOV_ENDS$1 | IL_ONLY$1], [16, NISAN$1, 'Pesach II (CH\'\'M)', IL_ONLY$1 | CHOL_HAMOED$1, {
4597
+ pesach.prev().getDay() == SAT$1 ? pesach.onOrBefore(THU) : new HDate(14, NISAN$2, year), 'Ta\'anit Bechorot', MINOR_FAST$1));
4598
+ addEvents(year, [[14, NISAN$2, 'Erev Pesach', EREV$1 | LIGHT_CANDLES$1], // Attributes for Israel and Diaspora are different
4599
+ [15, NISAN$2, 'Pesach I', CHAG | YOM_TOV_ENDS$1 | IL_ONLY$1], [16, NISAN$2, 'Pesach II (CH\'\'M)', IL_ONLY$1 | CHOL_HAMOED$1, {
4600
4600
  cholHaMoedDay: 1
4601
- }], [17, NISAN$1, 'Pesach III (CH\'\'M)', IL_ONLY$1 | CHOL_HAMOED$1, {
4601
+ }], [17, NISAN$2, 'Pesach III (CH\'\'M)', IL_ONLY$1 | CHOL_HAMOED$1, {
4602
4602
  cholHaMoedDay: 2
4603
- }], [18, NISAN$1, 'Pesach IV (CH\'\'M)', IL_ONLY$1 | CHOL_HAMOED$1, {
4603
+ }], [18, NISAN$2, 'Pesach IV (CH\'\'M)', IL_ONLY$1 | CHOL_HAMOED$1, {
4604
4604
  cholHaMoedDay: 3
4605
- }], [19, NISAN$1, 'Pesach V (CH\'\'M)', IL_ONLY$1 | CHOL_HAMOED$1, {
4605
+ }], [19, NISAN$2, 'Pesach V (CH\'\'M)', IL_ONLY$1 | CHOL_HAMOED$1, {
4606
4606
  cholHaMoedDay: 4
4607
- }], [20, NISAN$1, 'Pesach VI (CH\'\'M)', LIGHT_CANDLES$1 | IL_ONLY$1 | CHOL_HAMOED$1, {
4607
+ }], [20, NISAN$2, 'Pesach VI (CH\'\'M)', LIGHT_CANDLES$1 | IL_ONLY$1 | CHOL_HAMOED$1, {
4608
4608
  cholHaMoedDay: 5
4609
- }], [21, NISAN$1, 'Pesach VII', CHAG | YOM_TOV_ENDS$1 | IL_ONLY$1], [15, NISAN$1, 'Pesach I', CHAG | LIGHT_CANDLES_TZEIS$1 | CHUL_ONLY$1], [16, NISAN$1, 'Pesach II', CHAG | YOM_TOV_ENDS$1 | CHUL_ONLY$1], [17, NISAN$1, 'Pesach III (CH\'\'M)', CHUL_ONLY$1 | CHOL_HAMOED$1, {
4609
+ }], [21, NISAN$2, 'Pesach VII', CHAG | YOM_TOV_ENDS$1 | IL_ONLY$1], [15, NISAN$2, 'Pesach I', CHAG | LIGHT_CANDLES_TZEIS$1 | CHUL_ONLY$1], [16, NISAN$2, 'Pesach II', CHAG | YOM_TOV_ENDS$1 | CHUL_ONLY$1], [17, NISAN$2, 'Pesach III (CH\'\'M)', CHUL_ONLY$1 | CHOL_HAMOED$1, {
4610
4610
  cholHaMoedDay: 1
4611
- }], [18, NISAN$1, 'Pesach IV (CH\'\'M)', CHUL_ONLY$1 | CHOL_HAMOED$1, {
4611
+ }], [18, NISAN$2, 'Pesach IV (CH\'\'M)', CHUL_ONLY$1 | CHOL_HAMOED$1, {
4612
4612
  cholHaMoedDay: 2
4613
- }], [19, NISAN$1, 'Pesach V (CH\'\'M)', CHUL_ONLY$1 | CHOL_HAMOED$1, {
4613
+ }], [19, NISAN$2, 'Pesach V (CH\'\'M)', CHUL_ONLY$1 | CHOL_HAMOED$1, {
4614
4614
  cholHaMoedDay: 3
4615
- }], [20, NISAN$1, 'Pesach VI (CH\'\'M)', LIGHT_CANDLES$1 | CHUL_ONLY$1 | CHOL_HAMOED$1, {
4615
+ }], [20, NISAN$2, 'Pesach VI (CH\'\'M)', LIGHT_CANDLES$1 | CHUL_ONLY$1 | CHOL_HAMOED$1, {
4616
4616
  cholHaMoedDay: 4
4617
- }], [21, NISAN$1, 'Pesach VII', CHAG | LIGHT_CANDLES_TZEIS$1 | CHUL_ONLY$1], [22, NISAN$1, 'Pesach VIII', CHAG | YOM_TOV_ENDS$1 | CHUL_ONLY$1], [14, IYYAR, 'Pesach Sheni', MINOR_HOLIDAY$1], [18, IYYAR, 'Lag BaOmer', MINOR_HOLIDAY$1, {
4617
+ }], [21, NISAN$2, 'Pesach VII', CHAG | LIGHT_CANDLES_TZEIS$1 | CHUL_ONLY$1], [22, NISAN$2, 'Pesach VIII', CHAG | YOM_TOV_ENDS$1 | CHUL_ONLY$1], [14, IYYAR, 'Pesach Sheni', MINOR_HOLIDAY$1], [18, IYYAR, 'Lag BaOmer', MINOR_HOLIDAY$1, {
4618
4618
  emoji: '🔥'
4619
4619
  }], [5, SIVAN$1, 'Erev Shavuot', EREV$1 | LIGHT_CANDLES$1, {
4620
4620
  emoji: '⛰️🌸'
@@ -4644,7 +4644,7 @@ function getHolidaysForYear(year) {
4644
4644
 
4645
4645
  if (year >= 5711) {
4646
4646
  // Yom HaShoah first observed in 1951
4647
- let nisan27dt = new HDate(27, NISAN$1, year);
4647
+ let nisan27dt = new HDate(27, NISAN$2, year);
4648
4648
  /* When the actual date of Yom Hashoah falls on a Friday, the
4649
4649
  * state of Israel observes Yom Hashoah on the preceding
4650
4650
  * Thursday. When it falls on a Sunday, Yom Hashoah is observed
@@ -4653,9 +4653,9 @@ function getHolidaysForYear(year) {
4653
4653
  */
4654
4654
 
4655
4655
  if (nisan27dt.getDay() == FRI$1) {
4656
- nisan27dt = new HDate(26, NISAN$1, year);
4656
+ nisan27dt = new HDate(26, NISAN$2, year);
4657
4657
  } else if (nisan27dt.getDay() == SUN) {
4658
- nisan27dt = new HDate(28, NISAN$1, year);
4658
+ nisan27dt = new HDate(28, NISAN$2, year);
4659
4659
  }
4660
4660
 
4661
4661
  add(new HolidayEvent(nisan27dt, 'Yom HaShoah', MODERN_HOLIDAY$1));
@@ -4690,7 +4690,7 @@ function getHolidaysForYear(year) {
4690
4690
  }
4691
4691
 
4692
4692
  if (year >= 5777) {
4693
- add(new HolidayEvent(new HDate(7, CHESHVAN$1, year), 'Yom HaAliyah School Observance', MODERN_HOLIDAY$1, emojiIsraelFlag), new HolidayEvent(new HDate(10, NISAN$1, year), 'Yom HaAliyah', MODERN_HOLIDAY$1, emojiIsraelFlag));
4693
+ add(new HolidayEvent(new HDate(7, CHESHVAN$1, year), 'Yom HaAliyah School Observance', MODERN_HOLIDAY$1, emojiIsraelFlag), new HolidayEvent(new HDate(10, NISAN$2, year), 'Yom HaAliyah', MODERN_HOLIDAY$1, emojiIsraelFlag));
4694
4694
  }
4695
4695
 
4696
4696
  let tamuz17 = new HDate(17, TAMUZ, year);
@@ -4723,7 +4723,7 @@ function getHolidaysForYear(year) {
4723
4723
  for (let month = 1; month <= monthsInYear; month++) {
4724
4724
  const monthName = HDate.getMonthName(month, year);
4725
4725
 
4726
- if ((month == NISAN$1 ? HDate.daysInMonth(HDate.monthsInYear(year - 1), year - 1) : HDate.daysInMonth(month - 1, year)) == 30) {
4726
+ if ((month == NISAN$2 ? HDate.daysInMonth(HDate.monthsInYear(year - 1), year - 1) : HDate.daysInMonth(month - 1, year)) == 30) {
4727
4727
  add(new RoshChodeshEvent(new HDate(1, month, year), monthName));
4728
4728
  add(new RoshChodeshEvent(new HDate(30, month - 1, year), monthName));
4729
4729
  } else if (month !== TISHREI$1) {
@@ -4739,7 +4739,7 @@ function getHolidaysForYear(year) {
4739
4739
  add(new MevarchimChodeshEvent(new HDate(29, month, year).onOrBefore(SAT$1), nextMonthName));
4740
4740
  }
4741
4741
 
4742
- const sedra = getSedra(year, false);
4742
+ const sedra = getSedra_(year, false);
4743
4743
  const beshalachHd = sedra.find(15);
4744
4744
  add(new HolidayEvent(beshalachHd, 'Shabbat Shirah', SPECIAL_SHABBAT$1));
4745
4745
  yearCache[year] = h;
@@ -4905,7 +4905,100 @@ class MishnaYomiEvent extends Event {
4905
4905
 
4906
4906
  }
4907
4907
 
4908
- var version="3.33.3";
4908
+ const NISAN$1 = months.NISAN;
4909
+ const CHESHVAN = months.CHESHVAN;
4910
+ const KISLEV = months.KISLEV;
4911
+ const TEVET = months.TEVET;
4912
+ const SHVAT = months.SHVAT;
4913
+ const ADAR_I = months.ADAR_I;
4914
+ const ADAR_II = months.ADAR_II;
4915
+ /**
4916
+ * @private
4917
+ * @param {number} hyear Hebrew year
4918
+ * @param {Date|HDate} gdate Gregorian or Hebrew date of death
4919
+ * @return {HDate} anniversary occurring in hyear
4920
+ */
4921
+
4922
+ function getYahrzeit_(hyear, gdate) {
4923
+ const orig = HDate.isHDate(gdate) ? gdate : new HDate(gdate);
4924
+ let hDeath = {
4925
+ yy: orig.getFullYear(),
4926
+ mm: orig.getMonth(),
4927
+ dd: orig.getDate()
4928
+ };
4929
+
4930
+ if (hyear <= hDeath.yy) {
4931
+ // `Hebrew year ${hyear} occurs on or before original date in ${hDeath.yy}`
4932
+ return undefined;
4933
+ }
4934
+
4935
+ if (hDeath.mm == CHESHVAN && hDeath.dd == 30 && !HDate.longCheshvan(hDeath.yy + 1)) {
4936
+ // If it's Heshvan 30 it depends on the first anniversary;
4937
+ // if that was not Heshvan 30, use the day before Kislev 1.
4938
+ hDeath = HDate.abs2hebrew(HDate.hebrew2abs(hyear, KISLEV, 1) - 1);
4939
+ } else if (hDeath.mm == KISLEV && hDeath.dd == 30 && HDate.shortKislev(hDeath.yy + 1)) {
4940
+ // If it's Kislev 30 it depends on the first anniversary;
4941
+ // if that was not Kislev 30, use the day before Teveth 1.
4942
+ hDeath = HDate.abs2hebrew(HDate.hebrew2abs(hyear, TEVET, 1) - 1);
4943
+ } else if (hDeath.mm == ADAR_II) {
4944
+ // If it's Adar II, use the same day in last month of year (Adar or Adar II).
4945
+ hDeath.mm = HDate.monthsInYear(hyear);
4946
+ } else if (hDeath.mm == ADAR_I && hDeath.dd == 30 && !HDate.isLeapYear(hyear)) {
4947
+ // If it's the 30th in Adar I and year is not a leap year
4948
+ // (so Adar has only 29 days), use the last day in Shevat.
4949
+ hDeath.dd = 30;
4950
+ hDeath.mm = SHVAT;
4951
+ } // In all other cases, use the normal anniversary of the date of death.
4952
+ // advance day to rosh chodesh if needed
4953
+
4954
+
4955
+ if (hDeath.mm == CHESHVAN && hDeath.dd == 30 && !HDate.longCheshvan(hyear)) {
4956
+ hDeath.mm = KISLEV;
4957
+ hDeath.dd = 1;
4958
+ } else if (hDeath.mm == KISLEV && hDeath.dd == 30 && HDate.shortKislev(hyear)) {
4959
+ hDeath.mm = TEVET;
4960
+ hDeath.dd = 1;
4961
+ }
4962
+
4963
+ return new HDate(hDeath.dd, hDeath.mm, hyear);
4964
+ }
4965
+ /**
4966
+ * @private
4967
+ * @param {number} hyear Hebrew year
4968
+ * @param {Date|HDate} gdate Gregorian or Hebrew date of event
4969
+ * @return {HDate} anniversary occurring in `hyear`
4970
+ */
4971
+
4972
+ function getBirthdayOrAnniversary_(hyear, gdate) {
4973
+ const orig = HDate.isHDate(gdate) ? gdate : new HDate(gdate);
4974
+ const origYear = orig.getFullYear();
4975
+
4976
+ if (hyear <= origYear) {
4977
+ // `Hebrew year ${hyear} occurs on or before original date in ${origYear}`
4978
+ return undefined;
4979
+ }
4980
+
4981
+ const isOrigLeap = HDate.isLeapYear(origYear);
4982
+ let month = orig.getMonth();
4983
+ let day = orig.getDate();
4984
+
4985
+ if (month == ADAR_I && !isOrigLeap || month == ADAR_II && isOrigLeap) {
4986
+ month = HDate.monthsInYear(hyear);
4987
+ } else if (month == CHESHVAN && day == 30 && !HDate.longCheshvan(hyear)) {
4988
+ month = KISLEV;
4989
+ day = 1;
4990
+ } else if (month == KISLEV && day == 30 && HDate.shortKislev(hyear)) {
4991
+ month = TEVET;
4992
+ day = 1;
4993
+ } else if (month == ADAR_I && day == 30 && isOrigLeap && !HDate.isLeapYear(hyear)) {
4994
+ month = NISAN$1;
4995
+ day = 1;
4996
+ }
4997
+
4998
+ return new HDate(day, month, hyear);
4999
+ }
5000
+
5001
+ var version="3.33.4";
4909
5002
 
4910
5003
  var headers$1={"plural-forms":"nplurals=2; plural=(n > 1);",language:"en_CA@ashkenazi"};var contexts$1={"":{Berachot:["Berachos"],Shabbat:["Shabbos"],Taanit:["Taanis"],Yevamot:["Yevamos"],Ketubot:["Kesubos"],"Baba Batra":["Baba Basra"],Makkot:["Makkos"],Shevuot:["Shevuos"],Horayot:["Horayos"],Menachot:["Menachos"],Bechorot:["Bechoros"],Keritot:["Kerisos"],Midot:["Midos"],"Achrei Mot":["Achrei Mos"],Bechukotai:["Bechukosai"],"Beha'alotcha":["Beha'aloscha"],Bereshit:["Bereshis"],Chukat:["Chukas"],"Erev Shavuot":["Erev Shavuos"],"Erev Sukkot":["Erev Sukkos"],"Ki Tavo":["Ki Savo"],"Ki Teitzei":["Ki Seitzei"],"Ki Tisa":["Ki Sisa"],Matot:["Matos"],"Purim Katan":["Purim Koton"],Tazria:["Sazria"],"Shabbat Chazon":["Shabbos Chazon"],"Shabbat HaChodesh":["Shabbos HaChodesh"],"Shabbat HaGadol":["Shabbos HaGadol"],"Shabbat Nachamu":["Shabbos Nachamu"],"Shabbat Parah":["Shabbos Parah"],"Shabbat Shekalim":["Shabbos Shekalim"],"Shabbat Shuva":["Shabbos Shuvah"],"Shabbat Zachor":["Shabbos Zachor"],Shavuot:["Shavuos"],"Shavuot I":["Shavuos I"],"Shavuot II":["Shavuos II"],Shemot:["Shemos"],"Shmini Atzeret":["Shmini Atzeres"],"Simchat Torah":["Simchas Torah"],Sukkot:["Sukkos"],"Sukkot I":["Sukkos I"],"Sukkot II":["Sukkos II"],"Sukkot II (CH''M)":["Sukkos II (CH''M)"],"Sukkot III (CH''M)":["Sukkos III (CH''M)"],"Sukkot IV (CH''M)":["Sukkos IV (CH''M)"],"Sukkot V (CH''M)":["Sukkos V (CH''M)"],"Sukkot VI (CH''M)":["Sukkos VI (CH''M)"],"Sukkot VII (Hoshana Raba)":["Sukkos VII (Hoshana Raba)"],"Ta'anit Bechorot":["Ta'anis Bechoros"],"Ta'anit Esther":["Ta'anis Esther"],Toldot:["Toldos"],Vaetchanan:["Vaeschanan"],Yitro:["Yisro"],"Vezot Haberakhah":["Vezos Haberakhah"],Parashat:["Parshas"],"Leil Selichot":["Leil Selichos"],"Shabbat Mevarchim Chodesh":["Shabbos Mevorchim Chodesh"],"Shabbat Shirah":["Shabbos Shirah"],Tevet:["Teves"],"Asara B'Tevet":["Asara B'Teves"],Berakhot:["Berakhos"],Sheviit:["Sheviis"],Terumot:["Terumos"],Maasrot:["Maasros"],Eduyot:["Eduyos"],Avot:["Avos"],Bekhorot:["Bekhoros"],Middot:["Middos"],Oholot:["Oholos"],Tahorot:["Tahoros"],Mikvaot:["Mikvaos"]}};var poAshkenazi = {headers:headers$1,contexts:contexts$1};
4911
5004
 
@@ -4962,12 +5055,6 @@ const SIVAN = months.SIVAN; // const TAMUZ = months.TAMUZ;
4962
5055
 
4963
5056
  const ELUL = months.ELUL;
4964
5057
  const TISHREI = months.TISHREI;
4965
- const CHESHVAN = months.CHESHVAN;
4966
- const KISLEV = months.KISLEV;
4967
- const TEVET = months.TEVET;
4968
- const SHVAT = months.SHVAT;
4969
- const ADAR_I = months.ADAR_I;
4970
- const ADAR_II = months.ADAR_II;
4971
5058
  const LIGHT_CANDLES = flags.LIGHT_CANDLES;
4972
5059
  const YOM_TOV_ENDS = flags.YOM_TOV_ENDS;
4973
5060
  const CHUL_ONLY = flags.CHUL_ONLY;
@@ -5296,18 +5383,49 @@ function getMaskFromOptions(options) {
5296
5383
  }
5297
5384
 
5298
5385
  const MASK_LIGHT_CANDLES = LIGHT_CANDLES | LIGHT_CANDLES_TZEIS | CHANUKAH_CANDLES | YOM_TOV_ENDS;
5386
+ const defaultLocation = new Location(0, 0, false, 'UTC');
5387
+ const hour12cc = {
5388
+ US: 1,
5389
+ CA: 1,
5390
+ BR: 1,
5391
+ AU: 1,
5392
+ NZ: 1,
5393
+ DO: 1,
5394
+ PR: 1,
5395
+ GR: 1,
5396
+ IN: 1,
5397
+ KR: 1,
5398
+ NP: 1,
5399
+ ZA: 1
5400
+ };
5401
+ /**
5402
+ * @private
5403
+ * @param {Event} ev
5404
+ * @return {boolean}
5405
+ */
5406
+
5407
+ function observedInIsrael(ev) {
5408
+ return ev.observedInIsrael();
5409
+ }
5410
+ /**
5411
+ * @private
5412
+ * @param {Event} ev
5413
+ * @return {boolean}
5414
+ */
5415
+
5416
+
5417
+ function observedInDiaspora(ev) {
5418
+ return ev.observedInDiaspora();
5419
+ }
5299
5420
  /**
5300
- * @namespace
5301
5421
  * HebrewCalendar is the main interface to the `@hebcal/core` library.
5302
5422
  * This namespace is used to calculate holidays, rosh chodesh, candle lighting & havdalah times,
5303
5423
  * Parashat HaShavua, Daf Yomi, days of the omer, and the molad.
5304
5424
  * Event names can be rendered in several languges using the `locale` option.
5305
5425
  */
5306
5426
 
5307
- const HebrewCalendar = {
5308
- /** @private */
5309
- defaultLocation: new Location(0, 0, false, 'UTC'),
5310
5427
 
5428
+ class HebrewCalendar {
5311
5429
  /**
5312
5430
  * Calculates holidays and other Hebrew calendar events based on {@link HebrewCalendar.Options}.
5313
5431
  *
@@ -5408,11 +5526,11 @@ const HebrewCalendar = {
5408
5526
  * @param {HebrewCalendar.Options} [options={}]
5409
5527
  * @return {Event[]}
5410
5528
  */
5411
- calendar: function (options = {}) {
5529
+ static calendar(options = {}) {
5412
5530
  options = shallowCopy({}, options); // so we can modify freely
5413
5531
 
5414
5532
  checkCandleOptions(options);
5415
- const location = options.location = options.location || this.defaultLocation;
5533
+ const location = options.location = options.location || defaultLocation;
5416
5534
  const il = options.il = options.il || location.il || false;
5417
5535
  options.mask = getMaskFromOptions(options);
5418
5536
 
@@ -5462,7 +5580,7 @@ const HebrewCalendar = {
5462
5580
  holidaysYear = HebrewCalendar.getHolidaysForYear(currentYear);
5463
5581
 
5464
5582
  if (options.sedrot && currentYear >= 3762) {
5465
- sedra = getSedra(currentYear, il);
5583
+ sedra = getSedra_(currentYear, il);
5466
5584
  }
5467
5585
 
5468
5586
  if (options.omer) {
@@ -5537,8 +5655,7 @@ const HebrewCalendar = {
5537
5655
  }
5538
5656
 
5539
5657
  return evts;
5540
- },
5541
-
5658
+ }
5542
5659
  /**
5543
5660
  * Calculates a birthday or anniversary (non-yahrzeit).
5544
5661
  * `hyear` must be after original `gdate` of anniversary.
@@ -5565,35 +5682,11 @@ const HebrewCalendar = {
5565
5682
  * @param {Date|HDate} gdate Gregorian or Hebrew date of event
5566
5683
  * @return {HDate} anniversary occurring in `hyear`
5567
5684
  */
5568
- getBirthdayOrAnniversary: function (hyear, gdate) {
5569
- const orig = HDate.isHDate(gdate) ? gdate : new HDate(gdate);
5570
- const origYear = orig.getFullYear();
5571
5685
 
5572
- if (hyear <= origYear) {
5573
- // `Hebrew year ${hyear} occurs on or before original date in ${origYear}`
5574
- return undefined;
5575
- }
5576
-
5577
- const isOrigLeap = HDate.isLeapYear(origYear);
5578
- let month = orig.getMonth();
5579
- let day = orig.getDate();
5580
-
5581
- if (month == ADAR_I && !isOrigLeap || month == ADAR_II && isOrigLeap) {
5582
- month = HDate.monthsInYear(hyear);
5583
- } else if (month == CHESHVAN && day == 30 && !HDate.longCheshvan(hyear)) {
5584
- month = KISLEV;
5585
- day = 1;
5586
- } else if (month == KISLEV && day == 30 && HDate.shortKislev(hyear)) {
5587
- month = TEVET;
5588
- day = 1;
5589
- } else if (month == ADAR_I && day == 30 && isOrigLeap && !HDate.isLeapYear(hyear)) {
5590
- month = NISAN;
5591
- day = 1;
5592
- }
5593
-
5594
- return new HDate(day, month, hyear);
5595
- },
5596
5686
 
5687
+ static getBirthdayOrAnniversary(hyear, gdate) {
5688
+ return getBirthdayOrAnniversary_(hyear, gdate);
5689
+ }
5597
5690
  /**
5598
5691
  * Calculates yahrzeit.
5599
5692
  * `hyear` must be after original `gdate` of death.
@@ -5628,50 +5721,11 @@ const HebrewCalendar = {
5628
5721
  * @param {Date|HDate} gdate Gregorian or Hebrew date of death
5629
5722
  * @return {HDate} anniversary occurring in hyear
5630
5723
  */
5631
- getYahrzeit: function (hyear, gdate) {
5632
- const orig = HDate.isHDate(gdate) ? gdate : new HDate(gdate);
5633
- let hDeath = {
5634
- yy: orig.getFullYear(),
5635
- mm: orig.getMonth(),
5636
- dd: orig.getDate()
5637
- };
5638
5724
 
5639
- if (hyear <= hDeath.yy) {
5640
- // `Hebrew year ${hyear} occurs on or before original date in ${hDeath.yy}`
5641
- return undefined;
5642
- }
5643
-
5644
- if (hDeath.mm == CHESHVAN && hDeath.dd == 30 && !HDate.longCheshvan(hDeath.yy + 1)) {
5645
- // If it's Heshvan 30 it depends on the first anniversary;
5646
- // if that was not Heshvan 30, use the day before Kislev 1.
5647
- hDeath = HDate.abs2hebrew(HDate.hebrew2abs(hyear, KISLEV, 1) - 1);
5648
- } else if (hDeath.mm == KISLEV && hDeath.dd == 30 && HDate.shortKislev(hDeath.yy + 1)) {
5649
- // If it's Kislev 30 it depends on the first anniversary;
5650
- // if that was not Kislev 30, use the day before Teveth 1.
5651
- hDeath = HDate.abs2hebrew(HDate.hebrew2abs(hyear, TEVET, 1) - 1);
5652
- } else if (hDeath.mm == ADAR_II) {
5653
- // If it's Adar II, use the same day in last month of year (Adar or Adar II).
5654
- hDeath.mm = HDate.monthsInYear(hyear);
5655
- } else if (hDeath.mm == ADAR_I && hDeath.dd == 30 && !HDate.isLeapYear(hyear)) {
5656
- // If it's the 30th in Adar I and year is not a leap year
5657
- // (so Adar has only 29 days), use the last day in Shevat.
5658
- hDeath.dd = 30;
5659
- hDeath.mm = SHVAT;
5660
- } // In all other cases, use the normal anniversary of the date of death.
5661
- // advance day to rosh chodesh if needed
5662
-
5663
-
5664
- if (hDeath.mm == CHESHVAN && hDeath.dd == 30 && !HDate.longCheshvan(hyear)) {
5665
- hDeath.mm = KISLEV;
5666
- hDeath.dd = 1;
5667
- } else if (hDeath.mm == KISLEV && hDeath.dd == 30 && HDate.shortKislev(hyear)) {
5668
- hDeath.mm = TEVET;
5669
- hDeath.dd = 1;
5670
- }
5671
-
5672
- return new HDate(hDeath.dd, hDeath.mm, hyear);
5673
- },
5674
5725
 
5726
+ static getYahrzeit(hyear, gdate) {
5727
+ return getYahrzeit_(hyear, gdate);
5728
+ }
5675
5729
  /**
5676
5730
  * Lower-level holidays interface, which returns a `Map` of `Event`s indexed by
5677
5731
  * `HDate.toString()`. These events must filtered especially for `flags.IL_ONLY`
@@ -5680,65 +5734,58 @@ const HebrewCalendar = {
5680
5734
  * @param {number} year Hebrew year
5681
5735
  * @return {Map<string,Event[]>}
5682
5736
  */
5683
- getHolidaysForYear: getHolidaysForYear,
5684
5737
 
5738
+
5739
+ static getHolidaysForYear(year) {
5740
+ return getHolidaysForYear_(year);
5741
+ }
5685
5742
  /**
5686
5743
  * Returns an array of holidays for the year
5687
5744
  * @param {number} year Hebrew year
5688
5745
  * @param {boolean} il use the Israeli schedule for holidays
5689
5746
  * @return {Event[]}
5690
5747
  */
5691
- getHolidaysForYearArray: function (year, il) {
5692
- const yearMap = HebrewCalendar.getHolidaysForYear(year);
5748
+
5749
+
5750
+ static getHolidaysForYearArray(year, il) {
5751
+ const yearMap = getHolidaysForYear_(year);
5693
5752
  const startAbs = HDate.hebrew2abs(year, TISHREI, 1);
5694
5753
  const endAbs = HDate.hebrew2abs(year + 1, TISHREI, 1) - 1;
5695
- const events = [];
5754
+ let events = [];
5755
+ const myFilter = il ? observedInIsrael : observedInDiaspora;
5696
5756
 
5697
5757
  for (let absDt = startAbs; absDt <= endAbs; absDt++) {
5698
5758
  const hd = new HDate(absDt);
5699
5759
  const holidays = yearMap.get(hd.toString());
5700
5760
 
5701
5761
  if (holidays) {
5702
- const filtered = holidays.filter(ev => il && ev.observedInIsrael() || !il && ev.observedInDiaspora());
5703
- filtered.forEach(ev => events.push(ev));
5762
+ const filtered = holidays.filter(myFilter);
5763
+ events = events.concat(filtered);
5704
5764
  }
5705
5765
  }
5706
5766
 
5707
5767
  return events;
5708
- },
5709
-
5768
+ }
5710
5769
  /**
5711
5770
  * Returns an array of Events on this date (or undefined if no events)
5712
5771
  * @param {HDate|Date|number} date Hebrew Date, Gregorian date, or absolute R.D. day number
5713
5772
  * @param {boolean} [il] use the Israeli schedule for holidays
5714
5773
  * @return {Event[]}
5715
5774
  */
5716
- getHolidaysOnDate: function (date, il) {
5775
+
5776
+
5777
+ static getHolidaysOnDate(date, il) {
5717
5778
  const hd = HDate.isHDate(date) ? date : new HDate(date);
5718
- const yearMap = HebrewCalendar.getHolidaysForYear(hd.getFullYear());
5779
+ const yearMap = getHolidaysForYear_(hd.getFullYear());
5719
5780
  const events = yearMap.get(hd.toString());
5720
5781
 
5721
5782
  if (typeof il === 'undefined' || typeof events === 'undefined') {
5722
5783
  return events;
5723
5784
  }
5724
5785
 
5725
- return events.filter(ev => il && ev.observedInIsrael() || !il && ev.observedInDiaspora());
5726
- },
5727
- hour12cc: {
5728
- US: 1,
5729
- CA: 1,
5730
- BR: 1,
5731
- AU: 1,
5732
- NZ: 1,
5733
- DO: 1,
5734
- PR: 1,
5735
- GR: 1,
5736
- IN: 1,
5737
- KR: 1,
5738
- NP: 1,
5739
- ZA: 1
5740
- },
5741
-
5786
+ const myFilter = il ? observedInIsrael : observedInDiaspora;
5787
+ return events.filter(myFilter);
5788
+ }
5742
5789
  /**
5743
5790
  * Helper function to format a 23-hour (00:00-23:59) time in US format ("8:13pm") or
5744
5791
  * keep as "20:13" for any other locale/country. Uses `HebrewCalendar.Options` to determine
@@ -5748,11 +5795,13 @@ const HebrewCalendar = {
5748
5795
  * @param {HebrewCalendar.Options} options
5749
5796
  * @return {string}
5750
5797
  */
5751
- reformatTimeStr: function (timeStr, suffix, options) {
5798
+
5799
+
5800
+ static reformatTimeStr(timeStr, suffix, options) {
5752
5801
  if (typeof timeStr !== 'string') throw new TypeError(`Bad timeStr: ${timeStr}`);
5753
5802
  const cc = options.location && options.location.cc || (options.il ? 'IL' : 'US');
5754
5803
 
5755
- if (typeof this.hour12cc[cc] === 'undefined') {
5804
+ if (typeof hour12cc[cc] === 'undefined') {
5756
5805
  return timeStr;
5757
5806
  }
5758
5807
 
@@ -5766,13 +5815,13 @@ const HebrewCalendar = {
5766
5815
  }
5767
5816
 
5768
5817
  return `${hour}:${hm[1]}${suffix}`;
5769
- },
5770
-
5818
+ }
5771
5819
  /** @return {string} */
5772
- version: function () {
5773
- return version;
5774
- },
5775
5820
 
5821
+
5822
+ static version() {
5823
+ return version;
5824
+ }
5776
5825
  /**
5777
5826
  * Convenience function to create an instance of `Sedra` or reuse a previously
5778
5827
  * created and cached instance.
@@ -5781,8 +5830,13 @@ const HebrewCalendar = {
5781
5830
  * @param {boolean} il
5782
5831
  * @return {Sedra}
5783
5832
  */
5784
- getSedra: getSedra
5785
- };
5833
+
5834
+
5835
+ static getSedra(hyear, il) {
5836
+ return getSedra_(hyear, il);
5837
+ }
5838
+
5839
+ }
5786
5840
  /**
5787
5841
  * Appends the Event `ev` to the `events` array. Also may add related
5788
5842
  * timed events like candle-lighting or fast start/end
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hebcal/core",
3
- "version": "3.33.3",
3
+ "version": "3.33.4",
4
4
  "author": "Michael J. Radwin (https://github.com/mjradwin)",
5
5
  "contributors": [
6
6
  "Eyal Schachter (https://github.com/Scimonster)",
@@ -62,22 +62,22 @@
62
62
  "verbose": true
63
63
  },
64
64
  "devDependencies": {
65
- "@babel/core": "^7.17.5",
65
+ "@babel/core": "^7.17.8",
66
66
  "@babel/preset-env": "^7.16.11",
67
- "@babel/register": "^7.17.0",
67
+ "@babel/register": "^7.17.7",
68
68
  "@hebcal/solar-calc": "^1.1.0",
69
- "@rollup/plugin-babel": "^5.3.0",
70
- "@rollup/plugin-commonjs": "^21.0.1",
69
+ "@rollup/plugin-babel": "^5.3.1",
70
+ "@rollup/plugin-commonjs": "^21.0.2",
71
71
  "@rollup/plugin-json": "^4.1.0",
72
72
  "@rollup/plugin-node-resolve": "^13.1.3",
73
- "ava": "^4.0.1",
73
+ "ava": "^4.1.0",
74
74
  "core-js": "^3.21.1",
75
- "eslint": "^8.9.0",
75
+ "eslint": "^8.11.0",
76
76
  "eslint-config-google": "^0.14.0",
77
77
  "jsdoc": "^3.6.10",
78
78
  "jsdoc-to-markdown": "^7.1.1",
79
79
  "nyc": "^15.1.0",
80
- "rollup": "^2.67.3",
80
+ "rollup": "^2.70.1",
81
81
  "rollup-plugin-terser": "^7.0.2",
82
82
  "tsd-jsdoc": "^2.5.0",
83
83
  "ttag-cli": "^1.9.3"