@hebcal/core 3.33.1 → 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.js CHANGED
@@ -1,4 +1,4 @@
1
- /*! @hebcal/core v3.33.1 */
1
+ /*! @hebcal/core v3.33.4 */
2
2
  'use strict';
3
3
 
4
4
  Object.defineProperty(exports, '__esModule', { value: true });
@@ -553,7 +553,7 @@ Locale.useLocale('en');
553
553
  You should have received a copy of the GNU General Public License
554
554
  along with this program. If not, see <http://www.gnu.org/licenses/>.
555
555
  */
556
- const NISAN$2 = 1;
556
+ const NISAN$3 = 1;
557
557
  const IYYAR$1 = 2;
558
558
  const SIVAN$2 = 3;
559
559
  const TAMUZ$1 = 4;
@@ -907,7 +907,7 @@ class HDate {
907
907
  tempabs += HDate.daysInMonth(m, year);
908
908
  }
909
909
 
910
- for (let m = NISAN$2; m < month; m++) {
910
+ for (let m = NISAN$3; m < month; m++) {
911
911
  tempabs += HDate.daysInMonth(m, year);
912
912
  }
913
913
  } else {
@@ -1053,7 +1053,7 @@ class HDate {
1053
1053
  * @example
1054
1054
  * import {HDate, months} from '@hebcal/core';
1055
1055
  * const hd = new HDate(15, months.CHESHVAN, 5769);
1056
- * console.log(ev.renderGematriya()); // 'ט״ו חֶשְׁוָן תשס״ט'
1056
+ * console.log(hd.renderGematriya()); // 'ט״ו חֶשְׁוָן תשס״ט'
1057
1057
  * @return {string}
1058
1058
  */
1059
1059
 
@@ -1453,7 +1453,7 @@ class HDate {
1453
1453
  /* this catches "november" */
1454
1454
  }
1455
1455
 
1456
- return NISAN$2;
1456
+ return NISAN$3;
1457
1457
 
1458
1458
  case 'i':
1459
1459
  return IYYAR$1;
@@ -2827,9 +2827,20 @@ class Location {
2827
2827
 
2828
2828
 
2829
2829
  getShortName() {
2830
- if (!this.name) return this.name;
2831
- const comma = this.name.indexOf(',');
2832
- return comma == -1 ? this.name : this.name.substring(0, comma);
2830
+ const name = this.name;
2831
+ if (!name) return name;
2832
+ const comma = name.indexOf(', ');
2833
+ if (comma === -1) return name;
2834
+
2835
+ if (this.cc === 'US' && name[comma + 2] === 'D') {
2836
+ if (name[comma + 3] === 'C') {
2837
+ return name.substring(0, comma + 4);
2838
+ } else if (name[comma + 3] === '.' && name[comma + 4] === 'C') {
2839
+ return name.substring(0, comma + 6);
2840
+ }
2841
+ }
2842
+
2843
+ return name.substring(0, comma);
2833
2844
  }
2834
2845
  /** @return {string} */
2835
2846
 
@@ -4379,7 +4390,7 @@ const TUE = 2; // const WED = 3;
4379
4390
  const THU = 4;
4380
4391
  const FRI$1 = 5;
4381
4392
  const SAT$1 = 6;
4382
- const NISAN$1 = months.NISAN;
4393
+ const NISAN$2 = months.NISAN;
4383
4394
  const IYYAR = months.IYYAR;
4384
4395
  const SIVAN$1 = months.SIVAN;
4385
4396
  const TAMUZ = months.TAMUZ;
@@ -4456,7 +4467,7 @@ const sedraCache = new SimpleMap();
4456
4467
  * @return {Sedra}
4457
4468
  */
4458
4469
 
4459
- function getSedra(hyear, il) {
4470
+ function getSedra_(hyear, il) {
4460
4471
  const cacheKey = `${hyear}-${il ? 1 : 0}`;
4461
4472
  let sedra = sedraCache.get(cacheKey);
4462
4473
 
@@ -4481,7 +4492,7 @@ const yearCache = Object.create(null);
4481
4492
  * @return {Map<string,Event[]>}
4482
4493
  */
4483
4494
 
4484
- function getHolidaysForYear(year) {
4495
+ function getHolidaysForYear_(year) {
4485
4496
  if (typeof year !== 'number') {
4486
4497
  throw new TypeError(`bad Hebrew year: ${year}`);
4487
4498
  } else if (year < 1 || year > 32658) {
@@ -4495,7 +4506,7 @@ function getHolidaysForYear(year) {
4495
4506
  }
4496
4507
 
4497
4508
  const RH = new HDate(1, TISHREI$1, year);
4498
- const pesach = new HDate(15, NISAN$1, year);
4509
+ const pesach = new HDate(15, NISAN$2, year);
4499
4510
  const h = new SimpleMap(); // eslint-disable-next-line require-jsdoc
4500
4511
 
4501
4512
  function add(...events) {
@@ -4587,27 +4598,27 @@ function getHolidaysForYear(year) {
4587
4598
  add(new HolidayEvent(new HDate(pesachAbs - (pesach.getDay() == SUN ? 28 : 29)), 'Shushan Purim', MINOR_HOLIDAY$1, {
4588
4599
  emoji: '🎭️📜'
4589
4600
  }), 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
4590
- pesach.prev().getDay() == SAT$1 ? pesach.onOrBefore(THU) : new HDate(14, NISAN$1, year), 'Ta\'anit Bechorot', MINOR_FAST$1));
4591
- addEvents(year, [[14, NISAN$1, 'Erev Pesach', EREV$1 | LIGHT_CANDLES$1], // Attributes for Israel and Diaspora are different
4592
- [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, {
4601
+ pesach.prev().getDay() == SAT$1 ? pesach.onOrBefore(THU) : new HDate(14, NISAN$2, year), 'Ta\'anit Bechorot', MINOR_FAST$1));
4602
+ addEvents(year, [[14, NISAN$2, 'Erev Pesach', EREV$1 | LIGHT_CANDLES$1], // Attributes for Israel and Diaspora are different
4603
+ [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, {
4593
4604
  cholHaMoedDay: 1
4594
- }], [17, NISAN$1, 'Pesach III (CH\'\'M)', IL_ONLY$1 | CHOL_HAMOED$1, {
4605
+ }], [17, NISAN$2, 'Pesach III (CH\'\'M)', IL_ONLY$1 | CHOL_HAMOED$1, {
4595
4606
  cholHaMoedDay: 2
4596
- }], [18, NISAN$1, 'Pesach IV (CH\'\'M)', IL_ONLY$1 | CHOL_HAMOED$1, {
4607
+ }], [18, NISAN$2, 'Pesach IV (CH\'\'M)', IL_ONLY$1 | CHOL_HAMOED$1, {
4597
4608
  cholHaMoedDay: 3
4598
- }], [19, NISAN$1, 'Pesach V (CH\'\'M)', IL_ONLY$1 | CHOL_HAMOED$1, {
4609
+ }], [19, NISAN$2, 'Pesach V (CH\'\'M)', IL_ONLY$1 | CHOL_HAMOED$1, {
4599
4610
  cholHaMoedDay: 4
4600
- }], [20, NISAN$1, 'Pesach VI (CH\'\'M)', LIGHT_CANDLES$1 | IL_ONLY$1 | CHOL_HAMOED$1, {
4611
+ }], [20, NISAN$2, 'Pesach VI (CH\'\'M)', LIGHT_CANDLES$1 | IL_ONLY$1 | CHOL_HAMOED$1, {
4601
4612
  cholHaMoedDay: 5
4602
- }], [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, {
4613
+ }], [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, {
4603
4614
  cholHaMoedDay: 1
4604
- }], [18, NISAN$1, 'Pesach IV (CH\'\'M)', CHUL_ONLY$1 | CHOL_HAMOED$1, {
4615
+ }], [18, NISAN$2, 'Pesach IV (CH\'\'M)', CHUL_ONLY$1 | CHOL_HAMOED$1, {
4605
4616
  cholHaMoedDay: 2
4606
- }], [19, NISAN$1, 'Pesach V (CH\'\'M)', CHUL_ONLY$1 | CHOL_HAMOED$1, {
4617
+ }], [19, NISAN$2, 'Pesach V (CH\'\'M)', CHUL_ONLY$1 | CHOL_HAMOED$1, {
4607
4618
  cholHaMoedDay: 3
4608
- }], [20, NISAN$1, 'Pesach VI (CH\'\'M)', LIGHT_CANDLES$1 | CHUL_ONLY$1 | CHOL_HAMOED$1, {
4619
+ }], [20, NISAN$2, 'Pesach VI (CH\'\'M)', LIGHT_CANDLES$1 | CHUL_ONLY$1 | CHOL_HAMOED$1, {
4609
4620
  cholHaMoedDay: 4
4610
- }], [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, {
4621
+ }], [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, {
4611
4622
  emoji: '🔥'
4612
4623
  }], [5, SIVAN$1, 'Erev Shavuot', EREV$1 | LIGHT_CANDLES$1, {
4613
4624
  emoji: '⛰️🌸'
@@ -4637,7 +4648,7 @@ function getHolidaysForYear(year) {
4637
4648
 
4638
4649
  if (year >= 5711) {
4639
4650
  // Yom HaShoah first observed in 1951
4640
- let nisan27dt = new HDate(27, NISAN$1, year);
4651
+ let nisan27dt = new HDate(27, NISAN$2, year);
4641
4652
  /* When the actual date of Yom Hashoah falls on a Friday, the
4642
4653
  * state of Israel observes Yom Hashoah on the preceding
4643
4654
  * Thursday. When it falls on a Sunday, Yom Hashoah is observed
@@ -4646,9 +4657,9 @@ function getHolidaysForYear(year) {
4646
4657
  */
4647
4658
 
4648
4659
  if (nisan27dt.getDay() == FRI$1) {
4649
- nisan27dt = new HDate(26, NISAN$1, year);
4660
+ nisan27dt = new HDate(26, NISAN$2, year);
4650
4661
  } else if (nisan27dt.getDay() == SUN) {
4651
- nisan27dt = new HDate(28, NISAN$1, year);
4662
+ nisan27dt = new HDate(28, NISAN$2, year);
4652
4663
  }
4653
4664
 
4654
4665
  add(new HolidayEvent(nisan27dt, 'Yom HaShoah', MODERN_HOLIDAY$1));
@@ -4683,7 +4694,7 @@ function getHolidaysForYear(year) {
4683
4694
  }
4684
4695
 
4685
4696
  if (year >= 5777) {
4686
- 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));
4697
+ 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));
4687
4698
  }
4688
4699
 
4689
4700
  let tamuz17 = new HDate(17, TAMUZ, year);
@@ -4716,7 +4727,7 @@ function getHolidaysForYear(year) {
4716
4727
  for (let month = 1; month <= monthsInYear; month++) {
4717
4728
  const monthName = HDate.getMonthName(month, year);
4718
4729
 
4719
- if ((month == NISAN$1 ? HDate.daysInMonth(HDate.monthsInYear(year - 1), year - 1) : HDate.daysInMonth(month - 1, year)) == 30) {
4730
+ if ((month == NISAN$2 ? HDate.daysInMonth(HDate.monthsInYear(year - 1), year - 1) : HDate.daysInMonth(month - 1, year)) == 30) {
4720
4731
  add(new RoshChodeshEvent(new HDate(1, month, year), monthName));
4721
4732
  add(new RoshChodeshEvent(new HDate(30, month - 1, year), monthName));
4722
4733
  } else if (month !== TISHREI$1) {
@@ -4732,7 +4743,7 @@ function getHolidaysForYear(year) {
4732
4743
  add(new MevarchimChodeshEvent(new HDate(29, month, year).onOrBefore(SAT$1), nextMonthName));
4733
4744
  }
4734
4745
 
4735
- const sedra = getSedra(year, false);
4746
+ const sedra = getSedra_(year, false);
4736
4747
  const beshalachHd = sedra.find(15);
4737
4748
  add(new HolidayEvent(beshalachHd, 'Shabbat Shirah', SPECIAL_SHABBAT$1));
4738
4749
  yearCache[year] = h;
@@ -4884,7 +4895,8 @@ class MishnaYomiEvent extends Event {
4884
4895
  const cv1 = mishnaYomi[0].v;
4885
4896
 
4886
4897
  if (k1 !== mishnaYomi[1].k) {
4887
- return `${prefix}.${cv1}?lang=bi`;
4898
+ const verse1 = cv1.replace(':', '.');
4899
+ return `${prefix}.${verse1}?lang=bi`;
4888
4900
  }
4889
4901
 
4890
4902
  const cv2 = mishnaYomi[1].v;
@@ -4897,7 +4909,100 @@ class MishnaYomiEvent extends Event {
4897
4909
 
4898
4910
  }
4899
4911
 
4900
- var version="3.33.1";
4912
+ const NISAN$1 = months.NISAN;
4913
+ const CHESHVAN = months.CHESHVAN;
4914
+ const KISLEV = months.KISLEV;
4915
+ const TEVET = months.TEVET;
4916
+ const SHVAT = months.SHVAT;
4917
+ const ADAR_I = months.ADAR_I;
4918
+ const ADAR_II = months.ADAR_II;
4919
+ /**
4920
+ * @private
4921
+ * @param {number} hyear Hebrew year
4922
+ * @param {Date|HDate} gdate Gregorian or Hebrew date of death
4923
+ * @return {HDate} anniversary occurring in hyear
4924
+ */
4925
+
4926
+ function getYahrzeit_(hyear, gdate) {
4927
+ const orig = HDate.isHDate(gdate) ? gdate : new HDate(gdate);
4928
+ let hDeath = {
4929
+ yy: orig.getFullYear(),
4930
+ mm: orig.getMonth(),
4931
+ dd: orig.getDate()
4932
+ };
4933
+
4934
+ if (hyear <= hDeath.yy) {
4935
+ // `Hebrew year ${hyear} occurs on or before original date in ${hDeath.yy}`
4936
+ return undefined;
4937
+ }
4938
+
4939
+ if (hDeath.mm == CHESHVAN && hDeath.dd == 30 && !HDate.longCheshvan(hDeath.yy + 1)) {
4940
+ // If it's Heshvan 30 it depends on the first anniversary;
4941
+ // if that was not Heshvan 30, use the day before Kislev 1.
4942
+ hDeath = HDate.abs2hebrew(HDate.hebrew2abs(hyear, KISLEV, 1) - 1);
4943
+ } else if (hDeath.mm == KISLEV && hDeath.dd == 30 && HDate.shortKislev(hDeath.yy + 1)) {
4944
+ // If it's Kislev 30 it depends on the first anniversary;
4945
+ // if that was not Kislev 30, use the day before Teveth 1.
4946
+ hDeath = HDate.abs2hebrew(HDate.hebrew2abs(hyear, TEVET, 1) - 1);
4947
+ } else if (hDeath.mm == ADAR_II) {
4948
+ // If it's Adar II, use the same day in last month of year (Adar or Adar II).
4949
+ hDeath.mm = HDate.monthsInYear(hyear);
4950
+ } else if (hDeath.mm == ADAR_I && hDeath.dd == 30 && !HDate.isLeapYear(hyear)) {
4951
+ // If it's the 30th in Adar I and year is not a leap year
4952
+ // (so Adar has only 29 days), use the last day in Shevat.
4953
+ hDeath.dd = 30;
4954
+ hDeath.mm = SHVAT;
4955
+ } // In all other cases, use the normal anniversary of the date of death.
4956
+ // advance day to rosh chodesh if needed
4957
+
4958
+
4959
+ if (hDeath.mm == CHESHVAN && hDeath.dd == 30 && !HDate.longCheshvan(hyear)) {
4960
+ hDeath.mm = KISLEV;
4961
+ hDeath.dd = 1;
4962
+ } else if (hDeath.mm == KISLEV && hDeath.dd == 30 && HDate.shortKislev(hyear)) {
4963
+ hDeath.mm = TEVET;
4964
+ hDeath.dd = 1;
4965
+ }
4966
+
4967
+ return new HDate(hDeath.dd, hDeath.mm, hyear);
4968
+ }
4969
+ /**
4970
+ * @private
4971
+ * @param {number} hyear Hebrew year
4972
+ * @param {Date|HDate} gdate Gregorian or Hebrew date of event
4973
+ * @return {HDate} anniversary occurring in `hyear`
4974
+ */
4975
+
4976
+ function getBirthdayOrAnniversary_(hyear, gdate) {
4977
+ const orig = HDate.isHDate(gdate) ? gdate : new HDate(gdate);
4978
+ const origYear = orig.getFullYear();
4979
+
4980
+ if (hyear <= origYear) {
4981
+ // `Hebrew year ${hyear} occurs on or before original date in ${origYear}`
4982
+ return undefined;
4983
+ }
4984
+
4985
+ const isOrigLeap = HDate.isLeapYear(origYear);
4986
+ let month = orig.getMonth();
4987
+ let day = orig.getDate();
4988
+
4989
+ if (month == ADAR_I && !isOrigLeap || month == ADAR_II && isOrigLeap) {
4990
+ month = HDate.monthsInYear(hyear);
4991
+ } else if (month == CHESHVAN && day == 30 && !HDate.longCheshvan(hyear)) {
4992
+ month = KISLEV;
4993
+ day = 1;
4994
+ } else if (month == KISLEV && day == 30 && HDate.shortKislev(hyear)) {
4995
+ month = TEVET;
4996
+ day = 1;
4997
+ } else if (month == ADAR_I && day == 30 && isOrigLeap && !HDate.isLeapYear(hyear)) {
4998
+ month = NISAN$1;
4999
+ day = 1;
5000
+ }
5001
+
5002
+ return new HDate(day, month, hyear);
5003
+ }
5004
+
5005
+ var version="3.33.4";
4901
5006
 
4902
5007
  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};
4903
5008
 
@@ -4954,12 +5059,6 @@ const SIVAN = months.SIVAN; // const TAMUZ = months.TAMUZ;
4954
5059
 
4955
5060
  const ELUL = months.ELUL;
4956
5061
  const TISHREI = months.TISHREI;
4957
- const CHESHVAN = months.CHESHVAN;
4958
- const KISLEV = months.KISLEV;
4959
- const TEVET = months.TEVET;
4960
- const SHVAT = months.SHVAT;
4961
- const ADAR_I = months.ADAR_I;
4962
- const ADAR_II = months.ADAR_II;
4963
5062
  const LIGHT_CANDLES = flags.LIGHT_CANDLES;
4964
5063
  const YOM_TOV_ENDS = flags.YOM_TOV_ENDS;
4965
5064
  const CHUL_ONLY = flags.CHUL_ONLY;
@@ -5288,18 +5387,49 @@ function getMaskFromOptions(options) {
5288
5387
  }
5289
5388
 
5290
5389
  const MASK_LIGHT_CANDLES = LIGHT_CANDLES | LIGHT_CANDLES_TZEIS | CHANUKAH_CANDLES | YOM_TOV_ENDS;
5390
+ const defaultLocation = new Location(0, 0, false, 'UTC');
5391
+ const hour12cc = {
5392
+ US: 1,
5393
+ CA: 1,
5394
+ BR: 1,
5395
+ AU: 1,
5396
+ NZ: 1,
5397
+ DO: 1,
5398
+ PR: 1,
5399
+ GR: 1,
5400
+ IN: 1,
5401
+ KR: 1,
5402
+ NP: 1,
5403
+ ZA: 1
5404
+ };
5405
+ /**
5406
+ * @private
5407
+ * @param {Event} ev
5408
+ * @return {boolean}
5409
+ */
5410
+
5411
+ function observedInIsrael(ev) {
5412
+ return ev.observedInIsrael();
5413
+ }
5414
+ /**
5415
+ * @private
5416
+ * @param {Event} ev
5417
+ * @return {boolean}
5418
+ */
5419
+
5420
+
5421
+ function observedInDiaspora(ev) {
5422
+ return ev.observedInDiaspora();
5423
+ }
5291
5424
  /**
5292
- * @namespace
5293
5425
  * HebrewCalendar is the main interface to the `@hebcal/core` library.
5294
5426
  * This namespace is used to calculate holidays, rosh chodesh, candle lighting & havdalah times,
5295
5427
  * Parashat HaShavua, Daf Yomi, days of the omer, and the molad.
5296
5428
  * Event names can be rendered in several languges using the `locale` option.
5297
5429
  */
5298
5430
 
5299
- const HebrewCalendar = {
5300
- /** @private */
5301
- defaultLocation: new Location(0, 0, false, 'UTC'),
5302
5431
 
5432
+ class HebrewCalendar {
5303
5433
  /**
5304
5434
  * Calculates holidays and other Hebrew calendar events based on {@link HebrewCalendar.Options}.
5305
5435
  *
@@ -5400,11 +5530,11 @@ const HebrewCalendar = {
5400
5530
  * @param {HebrewCalendar.Options} [options={}]
5401
5531
  * @return {Event[]}
5402
5532
  */
5403
- calendar: function (options = {}) {
5533
+ static calendar(options = {}) {
5404
5534
  options = shallowCopy({}, options); // so we can modify freely
5405
5535
 
5406
5536
  checkCandleOptions(options);
5407
- const location = options.location = options.location || this.defaultLocation;
5537
+ const location = options.location = options.location || defaultLocation;
5408
5538
  const il = options.il = options.il || location.il || false;
5409
5539
  options.mask = getMaskFromOptions(options);
5410
5540
 
@@ -5454,7 +5584,7 @@ const HebrewCalendar = {
5454
5584
  holidaysYear = HebrewCalendar.getHolidaysForYear(currentYear);
5455
5585
 
5456
5586
  if (options.sedrot && currentYear >= 3762) {
5457
- sedra = getSedra(currentYear, il);
5587
+ sedra = getSedra_(currentYear, il);
5458
5588
  }
5459
5589
 
5460
5590
  if (options.omer) {
@@ -5529,8 +5659,7 @@ const HebrewCalendar = {
5529
5659
  }
5530
5660
 
5531
5661
  return evts;
5532
- },
5533
-
5662
+ }
5534
5663
  /**
5535
5664
  * Calculates a birthday or anniversary (non-yahrzeit).
5536
5665
  * `hyear` must be after original `gdate` of anniversary.
@@ -5557,35 +5686,11 @@ const HebrewCalendar = {
5557
5686
  * @param {Date|HDate} gdate Gregorian or Hebrew date of event
5558
5687
  * @return {HDate} anniversary occurring in `hyear`
5559
5688
  */
5560
- getBirthdayOrAnniversary: function (hyear, gdate) {
5561
- const orig = HDate.isHDate(gdate) ? gdate : new HDate(gdate);
5562
- const origYear = orig.getFullYear();
5563
-
5564
- if (hyear <= origYear) {
5565
- // `Hebrew year ${hyear} occurs on or before original date in ${origYear}`
5566
- return undefined;
5567
- }
5568
-
5569
- const isOrigLeap = HDate.isLeapYear(origYear);
5570
- let month = orig.getMonth();
5571
- let day = orig.getDate();
5572
-
5573
- if (month == ADAR_I && !isOrigLeap || month == ADAR_II && isOrigLeap) {
5574
- month = HDate.monthsInYear(hyear);
5575
- } else if (month == CHESHVAN && day == 30 && !HDate.longCheshvan(hyear)) {
5576
- month = KISLEV;
5577
- day = 1;
5578
- } else if (month == KISLEV && day == 30 && HDate.shortKislev(hyear)) {
5579
- month = TEVET;
5580
- day = 1;
5581
- } else if (month == ADAR_I && day == 30 && isOrigLeap && !HDate.isLeapYear(hyear)) {
5582
- month = NISAN;
5583
- day = 1;
5584
- }
5585
5689
 
5586
- return new HDate(day, month, hyear);
5587
- },
5588
5690
 
5691
+ static getBirthdayOrAnniversary(hyear, gdate) {
5692
+ return getBirthdayOrAnniversary_(hyear, gdate);
5693
+ }
5589
5694
  /**
5590
5695
  * Calculates yahrzeit.
5591
5696
  * `hyear` must be after original `gdate` of death.
@@ -5620,50 +5725,11 @@ const HebrewCalendar = {
5620
5725
  * @param {Date|HDate} gdate Gregorian or Hebrew date of death
5621
5726
  * @return {HDate} anniversary occurring in hyear
5622
5727
  */
5623
- getYahrzeit: function (hyear, gdate) {
5624
- const orig = HDate.isHDate(gdate) ? gdate : new HDate(gdate);
5625
- let hDeath = {
5626
- yy: orig.getFullYear(),
5627
- mm: orig.getMonth(),
5628
- dd: orig.getDate()
5629
- };
5630
5728
 
5631
- if (hyear <= hDeath.yy) {
5632
- // `Hebrew year ${hyear} occurs on or before original date in ${hDeath.yy}`
5633
- return undefined;
5634
- }
5635
-
5636
- if (hDeath.mm == CHESHVAN && hDeath.dd == 30 && !HDate.longCheshvan(hDeath.yy + 1)) {
5637
- // If it's Heshvan 30 it depends on the first anniversary;
5638
- // if that was not Heshvan 30, use the day before Kislev 1.
5639
- hDeath = HDate.abs2hebrew(HDate.hebrew2abs(hyear, KISLEV, 1) - 1);
5640
- } else if (hDeath.mm == KISLEV && hDeath.dd == 30 && HDate.shortKislev(hDeath.yy + 1)) {
5641
- // If it's Kislev 30 it depends on the first anniversary;
5642
- // if that was not Kislev 30, use the day before Teveth 1.
5643
- hDeath = HDate.abs2hebrew(HDate.hebrew2abs(hyear, TEVET, 1) - 1);
5644
- } else if (hDeath.mm == ADAR_II) {
5645
- // If it's Adar II, use the same day in last month of year (Adar or Adar II).
5646
- hDeath.mm = HDate.monthsInYear(hyear);
5647
- } else if (hDeath.mm == ADAR_I && hDeath.dd == 30 && !HDate.isLeapYear(hyear)) {
5648
- // If it's the 30th in Adar I and year is not a leap year
5649
- // (so Adar has only 29 days), use the last day in Shevat.
5650
- hDeath.dd = 30;
5651
- hDeath.mm = SHVAT;
5652
- } // In all other cases, use the normal anniversary of the date of death.
5653
- // advance day to rosh chodesh if needed
5654
-
5655
-
5656
- if (hDeath.mm == CHESHVAN && hDeath.dd == 30 && !HDate.longCheshvan(hyear)) {
5657
- hDeath.mm = KISLEV;
5658
- hDeath.dd = 1;
5659
- } else if (hDeath.mm == KISLEV && hDeath.dd == 30 && HDate.shortKislev(hyear)) {
5660
- hDeath.mm = TEVET;
5661
- hDeath.dd = 1;
5662
- }
5663
-
5664
- return new HDate(hDeath.dd, hDeath.mm, hyear);
5665
- },
5666
5729
 
5730
+ static getYahrzeit(hyear, gdate) {
5731
+ return getYahrzeit_(hyear, gdate);
5732
+ }
5667
5733
  /**
5668
5734
  * Lower-level holidays interface, which returns a `Map` of `Event`s indexed by
5669
5735
  * `HDate.toString()`. These events must filtered especially for `flags.IL_ONLY`
@@ -5672,65 +5738,58 @@ const HebrewCalendar = {
5672
5738
  * @param {number} year Hebrew year
5673
5739
  * @return {Map<string,Event[]>}
5674
5740
  */
5675
- getHolidaysForYear: getHolidaysForYear,
5676
5741
 
5742
+
5743
+ static getHolidaysForYear(year) {
5744
+ return getHolidaysForYear_(year);
5745
+ }
5677
5746
  /**
5678
5747
  * Returns an array of holidays for the year
5679
5748
  * @param {number} year Hebrew year
5680
5749
  * @param {boolean} il use the Israeli schedule for holidays
5681
5750
  * @return {Event[]}
5682
5751
  */
5683
- getHolidaysForYearArray: function (year, il) {
5684
- const yearMap = HebrewCalendar.getHolidaysForYear(year);
5752
+
5753
+
5754
+ static getHolidaysForYearArray(year, il) {
5755
+ const yearMap = getHolidaysForYear_(year);
5685
5756
  const startAbs = HDate.hebrew2abs(year, TISHREI, 1);
5686
5757
  const endAbs = HDate.hebrew2abs(year + 1, TISHREI, 1) - 1;
5687
- const events = [];
5758
+ let events = [];
5759
+ const myFilter = il ? observedInIsrael : observedInDiaspora;
5688
5760
 
5689
5761
  for (let absDt = startAbs; absDt <= endAbs; absDt++) {
5690
5762
  const hd = new HDate(absDt);
5691
5763
  const holidays = yearMap.get(hd.toString());
5692
5764
 
5693
5765
  if (holidays) {
5694
- const filtered = holidays.filter(ev => il && ev.observedInIsrael() || !il && ev.observedInDiaspora());
5695
- filtered.forEach(ev => events.push(ev));
5766
+ const filtered = holidays.filter(myFilter);
5767
+ events = events.concat(filtered);
5696
5768
  }
5697
5769
  }
5698
5770
 
5699
5771
  return events;
5700
- },
5701
-
5772
+ }
5702
5773
  /**
5703
5774
  * Returns an array of Events on this date (or undefined if no events)
5704
5775
  * @param {HDate|Date|number} date Hebrew Date, Gregorian date, or absolute R.D. day number
5705
5776
  * @param {boolean} [il] use the Israeli schedule for holidays
5706
5777
  * @return {Event[]}
5707
5778
  */
5708
- getHolidaysOnDate: function (date, il) {
5779
+
5780
+
5781
+ static getHolidaysOnDate(date, il) {
5709
5782
  const hd = HDate.isHDate(date) ? date : new HDate(date);
5710
- const yearMap = HebrewCalendar.getHolidaysForYear(hd.getFullYear());
5783
+ const yearMap = getHolidaysForYear_(hd.getFullYear());
5711
5784
  const events = yearMap.get(hd.toString());
5712
5785
 
5713
5786
  if (typeof il === 'undefined' || typeof events === 'undefined') {
5714
5787
  return events;
5715
5788
  }
5716
5789
 
5717
- return events.filter(ev => il && ev.observedInIsrael() || !il && ev.observedInDiaspora());
5718
- },
5719
- hour12cc: {
5720
- US: 1,
5721
- CA: 1,
5722
- BR: 1,
5723
- AU: 1,
5724
- NZ: 1,
5725
- DO: 1,
5726
- PR: 1,
5727
- GR: 1,
5728
- IN: 1,
5729
- KR: 1,
5730
- NP: 1,
5731
- ZA: 1
5732
- },
5733
-
5790
+ const myFilter = il ? observedInIsrael : observedInDiaspora;
5791
+ return events.filter(myFilter);
5792
+ }
5734
5793
  /**
5735
5794
  * Helper function to format a 23-hour (00:00-23:59) time in US format ("8:13pm") or
5736
5795
  * keep as "20:13" for any other locale/country. Uses `HebrewCalendar.Options` to determine
@@ -5740,11 +5799,13 @@ const HebrewCalendar = {
5740
5799
  * @param {HebrewCalendar.Options} options
5741
5800
  * @return {string}
5742
5801
  */
5743
- reformatTimeStr: function (timeStr, suffix, options) {
5802
+
5803
+
5804
+ static reformatTimeStr(timeStr, suffix, options) {
5744
5805
  if (typeof timeStr !== 'string') throw new TypeError(`Bad timeStr: ${timeStr}`);
5745
5806
  const cc = options.location && options.location.cc || (options.il ? 'IL' : 'US');
5746
5807
 
5747
- if (typeof this.hour12cc[cc] === 'undefined') {
5808
+ if (typeof hour12cc[cc] === 'undefined') {
5748
5809
  return timeStr;
5749
5810
  }
5750
5811
 
@@ -5758,13 +5819,13 @@ const HebrewCalendar = {
5758
5819
  }
5759
5820
 
5760
5821
  return `${hour}:${hm[1]}${suffix}`;
5761
- },
5762
-
5822
+ }
5763
5823
  /** @return {string} */
5764
- version: function () {
5765
- return version;
5766
- },
5767
5824
 
5825
+
5826
+ static version() {
5827
+ return version;
5828
+ }
5768
5829
  /**
5769
5830
  * Convenience function to create an instance of `Sedra` or reuse a previously
5770
5831
  * created and cached instance.
@@ -5773,8 +5834,13 @@ const HebrewCalendar = {
5773
5834
  * @param {boolean} il
5774
5835
  * @return {Sedra}
5775
5836
  */
5776
- getSedra: getSedra
5777
- };
5837
+
5838
+
5839
+ static getSedra(hyear, il) {
5840
+ return getSedra_(hyear, il);
5841
+ }
5842
+
5843
+ }
5778
5844
  /**
5779
5845
  * Appends the Event `ev` to the `events` array. Also may add related
5780
5846
  * timed events like candle-lighting or fast start/end