@hebcal/core 3.38.0 → 3.39.0

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,8 +1,12 @@
1
- /*! @hebcal/core v3.38.0 */
2
- /**
1
+ /*! @hebcal/core v3.39.0 */
2
+ /*
3
3
  * More minimal greg routines
4
4
  */
5
+
6
+ /** @private */
5
7
  const lengths = [0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
8
+ /** @private */
9
+
6
10
  const monthLengths = [lengths, lengths.slice()];
7
11
  monthLengths[1][2] = 29;
8
12
  /**
@@ -67,7 +71,7 @@ function isDate(obj) {
67
71
 
68
72
  function dayOfYear(date) {
69
73
  if (!isDate(date)) {
70
- throw new TypeError('Argument to greg.dayOfYear not a Date');
74
+ throw new TypeError(`Argument not a Date: ${date}`);
71
75
  }
72
76
 
73
77
  let doy = date.getDate() + 31 * date.getMonth();
@@ -92,7 +96,7 @@ function dayOfYear(date) {
92
96
 
93
97
  function greg2abs(date) {
94
98
  if (!isDate(date)) {
95
- throw new TypeError('Argument to greg.greg2abs not a Date');
99
+ throw new TypeError(`Argument not a Date: ${date}`);
96
100
  }
97
101
 
98
102
  const year = date.getFullYear() - 1;
@@ -147,7 +151,7 @@ function toFixed(year, month, day) {
147
151
 
148
152
  function abs2greg(abs) {
149
153
  if (typeof abs !== 'number') {
150
- throw new TypeError('Argument to greg.abs2greg not a Number');
154
+ throw new TypeError(`Argument not a Number: ${abs}`);
151
155
  }
152
156
 
153
157
  abs = Math.trunc(abs);
@@ -615,7 +619,7 @@ Locale.addLocale('s', noopLocale);
615
619
  Locale.addLocale('', noopLocale);
616
620
  Locale.useLocale('en');
617
621
 
618
- /**
622
+ /*
619
623
  * More minimal HDate
620
624
  */
621
625
  const NISAN$3 = 1;
@@ -693,6 +697,7 @@ const AVG_HEBYEAR_DAYS = 365.24682220597794;
693
697
  * Converts Hebrew date to R.D. (Rata Die) fixed days.
694
698
  * R.D. 1 is the imaginary date Monday, January 1, 1 on the Gregorian
695
699
  * Calendar.
700
+ * @private
696
701
  * @param {number} year Hebrew year
697
702
  * @param {number} month Hebrew month
698
703
  * @param {number} day Hebrew date (1-30)
@@ -725,25 +730,7 @@ function hebrew2abs(year, month, day) {
725
730
  */
726
731
 
727
732
  function newYear(year) {
728
- return EPOCH + elapsedDays(year) + newYearDelay(year);
729
- }
730
- /**
731
- * @private
732
- * @param {number} year
733
- * @return {number}
734
- */
735
-
736
-
737
- function newYearDelay(year) {
738
- const ny1 = elapsedDays(year);
739
- const ny2 = elapsedDays(year + 1);
740
-
741
- if (ny2 - ny1 === 356) {
742
- return 2;
743
- } else {
744
- const ny0 = elapsedDays(year - 1);
745
- return ny1 - ny0 === 382 ? 1 : 0;
746
- }
733
+ return EPOCH + elapsedDays(year);
747
734
  }
748
735
  /**
749
736
  * Converts absolute R.D. days to Hebrew date
@@ -782,6 +769,7 @@ function abs2hebrew(abs) {
782
769
  }
783
770
  /**
784
771
  * Returns true if Hebrew year is a leap year
772
+ * @private
785
773
  * @param {number} year Hebrew year
786
774
  * @return {boolean}
787
775
  */
@@ -791,6 +779,7 @@ function isLeapYear(year) {
791
779
  }
792
780
  /**
793
781
  * Number of months in this Hebrew year (either 12 or 13 depending on leap year)
782
+ * @private
794
783
  * @param {number} year Hebrew year
795
784
  * @return {number}
796
785
  */
@@ -800,6 +789,7 @@ function monthsInYear(year) {
800
789
  }
801
790
  /**
802
791
  * Number of days in Hebrew month in a given year (29 or 30)
792
+ * @private
803
793
  * @param {number} month Hebrew month (e.g. months.TISHREI)
804
794
  * @param {number} year Hebrew year
805
795
  * @return {number}
@@ -824,13 +814,14 @@ function daysInMonth(month, year) {
824
814
  /**
825
815
  * Returns a transliterated string name of Hebrew month in year,
826
816
  * for example 'Elul' or 'Cheshvan'.
817
+ * @private
827
818
  * @param {number} month Hebrew month (e.g. months.TISHREI)
828
819
  * @param {number} year Hebrew year
829
820
  * @return {string}
830
821
  */
831
822
 
832
823
  function getMonthName(month, year) {
833
- if (typeof month !== 'number' || month < 1 || month > 14) {
824
+ if (typeof month !== 'number' || isNaN(month) || month < 1 || month > 14) {
834
825
  throw new TypeError(`bad month argument ${month}`);
835
826
  }
836
827
 
@@ -839,6 +830,7 @@ function getMonthName(month, year) {
839
830
  /**
840
831
  * Days from sunday prior to start of Hebrew calendar to mean
841
832
  * conjunction of Tishrei in Hebrew YEAR
833
+ * @private
842
834
  * @param {number} year Hebrew year
843
835
  * @return {number}
844
836
  */
@@ -869,7 +861,10 @@ function elapsedDays0(year) {
869
861
  return altDay + (altDay % 7 === 0 || altDay % 7 === 3 || altDay % 7 === 5);
870
862
  }
871
863
  /**
872
- * Number of days in the hebrew YEAR
864
+ * Number of days in the hebrew YEAR.
865
+ * A common Hebrew calendar year can have a length of 353, 354 or 355 days
866
+ * A leap Hebrew calendar year can have a length of 383, 384 or 385 days
867
+ * @private
873
868
  * @param {number} year Hebrew year
874
869
  * @return {number}
875
870
  */
@@ -880,6 +875,7 @@ function daysInYear(year) {
880
875
  }
881
876
  /**
882
877
  * true if Cheshvan is long in Hebrew year
878
+ * @private
883
879
  * @param {number} year Hebrew year
884
880
  * @return {boolean}
885
881
  */
@@ -889,6 +885,7 @@ function longCheshvan(year) {
889
885
  }
890
886
  /**
891
887
  * true if Kislev is short in Hebrew year
888
+ * @private
892
889
  * @param {number} year Hebrew year
893
890
  * @return {boolean}
894
891
  */
@@ -998,19 +995,22 @@ class HDate {
998
995
  * @type {number}
999
996
  */
1000
997
 
1001
- this.year = +year;
998
+ year = parseInt(year, 10);
1002
999
 
1003
- if (isNaN(this.year)) {
1000
+ if (isNaN(year)) {
1004
1001
  throw new TypeError(`HDate called with bad year argument: ${year}`);
1005
1002
  }
1006
1003
 
1004
+ this.year = year;
1007
1005
  this.setMonth(month); // will throw if we can't parse
1008
1006
 
1009
- this.setDate(+day);
1007
+ day = parseInt(day, 10);
1010
1008
 
1011
- if (isNaN(this.day)) {
1009
+ if (isNaN(day)) {
1012
1010
  throw new TypeError(`HDate called with bad day argument: ${day}`);
1013
1011
  }
1012
+
1013
+ this.setDate(day);
1014
1014
  } else {
1015
1015
  // 0 arguments
1016
1016
  if (typeof day === 'undefined') {
@@ -1018,7 +1018,7 @@ class HDate {
1018
1018
  } // 1 argument
1019
1019
 
1020
1020
 
1021
- const abs0 = typeof day === 'number' && !isNaN(day) ? day : greg.isDate(day) ? greg.greg2abs(day) : HDate.isHDate(day) ? {
1021
+ const abs0 = typeof day === 'number' && !isNaN(day) ? day : isDate(day) ? greg2abs(day) : HDate.isHDate(day) ? {
1022
1022
  dd: day.day,
1023
1023
  mm: day.month,
1024
1024
  yy: day.year
@@ -1163,7 +1163,7 @@ class HDate {
1163
1163
 
1164
1164
 
1165
1165
  greg() {
1166
- return greg.abs2greg(this.abs());
1166
+ return abs2greg(this.abs());
1167
1167
  }
1168
1168
  /**
1169
1169
  * Returns R.D. (Rata Die) fixed days.
@@ -1562,7 +1562,15 @@ class HDate {
1562
1562
 
1563
1563
 
1564
1564
  static monthNum(month) {
1565
- return typeof month === 'number' ? month : month.charCodeAt(0) >= 48 && month.charCodeAt(0) <= 57 ?
1565
+ if (typeof month === 'number') {
1566
+ if (isNaN(month) || month > 14) {
1567
+ throw new RangeError(`Invalid month number: ${month}`);
1568
+ }
1569
+
1570
+ return month;
1571
+ }
1572
+
1573
+ return month.charCodeAt(0) >= 48 && month.charCodeAt(0) <= 57 ?
1566
1574
  /* number */
1567
1575
  parseInt(month, 10) : HDate.monthFromName(month);
1568
1576
  }
@@ -1604,7 +1612,14 @@ class HDate {
1604
1612
 
1605
1613
 
1606
1614
  static monthFromName(monthName) {
1607
- if (typeof monthName === 'number') return monthName;
1615
+ if (typeof monthName === 'number') {
1616
+ if (isNaN(monthName) || monthName < 1 || monthName > 14) {
1617
+ throw new RangeError(`Invalid month name: ${monthName}`);
1618
+ }
1619
+
1620
+ return monthName;
1621
+ }
1622
+
1608
1623
  const c = monthName.toLowerCase();
1609
1624
  /*
1610
1625
  the Hebrew months are unique to their second letter
@@ -1836,31 +1851,6 @@ function onOrBefore(day, t, offset) {
1836
1851
  return new HDate(HDate.dayOnOrBefore(day, t.abs() + offset));
1837
1852
  }
1838
1853
 
1839
- const CHAG$1 = 0x000001;
1840
- const LIGHT_CANDLES$2 = 0x000002;
1841
- const YOM_TOV_ENDS$2 = 0x000004;
1842
- const CHUL_ONLY$2 = 0x000008; // chutz l'aretz (Diaspora)
1843
-
1844
- const IL_ONLY$2 = 0x000010; // b'aretz (Israel)
1845
-
1846
- const LIGHT_CANDLES_TZEIS$2 = 0x000020;
1847
- const CHANUKAH_CANDLES$2 = 0x000040;
1848
- const ROSH_CHODESH$1 = 0x000080;
1849
- const MINOR_FAST$2 = 0x000100;
1850
- const SPECIAL_SHABBAT$2 = 0x000200;
1851
- const PARSHA_HASHAVUA$1 = 0x000400;
1852
- const DAF_YOMI$1 = 0x000800;
1853
- const OMER_COUNT$1 = 0x001000;
1854
- const MODERN_HOLIDAY$2 = 0x002000;
1855
- const MAJOR_FAST$2 = 0x004000;
1856
- const SHABBAT_MEVARCHIM$1 = 0x008000;
1857
- const MOLAD = 0x010000;
1858
- const USER_EVENT = 0x020000;
1859
- const HEBREW_DATE = 0x040000;
1860
- const MINOR_HOLIDAY$2 = 0x080000;
1861
- const EREV$2 = 0x100000;
1862
- const CHOL_HAMOED$2 = 0x200000;
1863
- const MISHNA_YOMI = 0x400000;
1864
1854
  /**
1865
1855
  * Holiday flags for Event
1866
1856
  * @readonly
@@ -1869,73 +1859,73 @@ const MISHNA_YOMI = 0x400000;
1869
1859
 
1870
1860
  const flags = {
1871
1861
  /** Chag, yontiff, yom tov */
1872
- CHAG: CHAG$1,
1862
+ CHAG: 0x000001,
1873
1863
 
1874
1864
  /** Light candles 18 minutes before sundown */
1875
- LIGHT_CANDLES: LIGHT_CANDLES$2,
1865
+ LIGHT_CANDLES: 0x000002,
1876
1866
 
1877
1867
  /** End of holiday (end of Yom Tov) */
1878
- YOM_TOV_ENDS: YOM_TOV_ENDS$2,
1868
+ YOM_TOV_ENDS: 0x000004,
1879
1869
 
1880
1870
  /** Observed only in the Diaspora (chutz l'aretz) */
1881
- CHUL_ONLY: CHUL_ONLY$2,
1871
+ CHUL_ONLY: 0x000008,
1882
1872
 
1883
1873
  /** Observed only in Israel */
1884
- IL_ONLY: IL_ONLY$2,
1874
+ IL_ONLY: 0x000010,
1885
1875
 
1886
1876
  /** Light candles in the evening at Tzeit time (3 small stars) */
1887
- LIGHT_CANDLES_TZEIS: LIGHT_CANDLES_TZEIS$2,
1877
+ LIGHT_CANDLES_TZEIS: 0x000020,
1888
1878
 
1889
1879
  /** Candle-lighting for Chanukah */
1890
- CHANUKAH_CANDLES: CHANUKAH_CANDLES$2,
1880
+ CHANUKAH_CANDLES: 0x000040,
1891
1881
 
1892
1882
  /** Rosh Chodesh, beginning of a new Hebrew month */
1893
- ROSH_CHODESH: ROSH_CHODESH$1,
1883
+ ROSH_CHODESH: 0x000080,
1894
1884
 
1895
1885
  /** Minor fasts like Tzom Tammuz, Ta'anit Esther, ... */
1896
- MINOR_FAST: MINOR_FAST$2,
1886
+ MINOR_FAST: 0x000100,
1897
1887
 
1898
1888
  /** Shabbat Shekalim, Zachor, ... */
1899
- SPECIAL_SHABBAT: SPECIAL_SHABBAT$2,
1889
+ SPECIAL_SHABBAT: 0x000200,
1900
1890
 
1901
1891
  /** Weekly sedrot on Saturdays */
1902
- PARSHA_HASHAVUA: PARSHA_HASHAVUA$1,
1892
+ PARSHA_HASHAVUA: 0x000400,
1903
1893
 
1904
1894
  /** Daily page of Talmud */
1905
- DAF_YOMI: DAF_YOMI$1,
1895
+ DAF_YOMI: 0x000800,
1906
1896
 
1907
1897
  /** Days of the Omer */
1908
- OMER_COUNT: OMER_COUNT$1,
1898
+ OMER_COUNT: 0x001000,
1909
1899
 
1910
1900
  /** Yom HaShoah, Yom HaAtzma'ut, ... */
1911
- MODERN_HOLIDAY: MODERN_HOLIDAY$2,
1901
+ MODERN_HOLIDAY: 0x002000,
1912
1902
 
1913
1903
  /** Yom Kippur and Tish'a B'Av */
1914
- MAJOR_FAST: MAJOR_FAST$2,
1904
+ MAJOR_FAST: 0x004000,
1915
1905
 
1916
1906
  /** On the Saturday before Rosh Chodesh */
1917
- SHABBAT_MEVARCHIM: SHABBAT_MEVARCHIM$1,
1907
+ SHABBAT_MEVARCHIM: 0x008000,
1918
1908
 
1919
1909
  /** Molad */
1920
- MOLAD,
1910
+ MOLAD: 0x010000,
1921
1911
 
1922
1912
  /** Yahrzeit or Hebrew Anniversary */
1923
- USER_EVENT,
1913
+ USER_EVENT: 0x020000,
1924
1914
 
1925
1915
  /** Daily Hebrew date ("11th of Sivan, 5780") */
1926
- HEBREW_DATE,
1916
+ HEBREW_DATE: 0x040000,
1927
1917
 
1928
1918
  /** A holiday that's not major, modern, rosh chodesh, or a fast day */
1929
- MINOR_HOLIDAY: MINOR_HOLIDAY$2,
1919
+ MINOR_HOLIDAY: 0x080000,
1930
1920
 
1931
1921
  /** Evening before a major or minor holiday */
1932
- EREV: EREV$2,
1922
+ EREV: 0x100000,
1933
1923
 
1934
1924
  /** Chol haMoed, intermediate days of Pesach or Sukkot */
1935
- CHOL_HAMOED: CHOL_HAMOED$2,
1925
+ CHOL_HAMOED: 0x200000,
1936
1926
 
1937
1927
  /** Mishna Yomi */
1938
- MISHNA_YOMI
1928
+ MISHNA_YOMI: 0x400000
1939
1929
  };
1940
1930
  /** Represents an Event with a title, date, and flags */
1941
1931
 
@@ -2053,7 +2043,7 @@ class Event {
2053
2043
 
2054
2044
 
2055
2045
  observedInIsrael() {
2056
- return !(this.mask & CHUL_ONLY$2);
2046
+ return !(this.mask & flags.CHUL_ONLY);
2057
2047
  }
2058
2048
  /**
2059
2049
  * Is this event observed in the Diaspora?
@@ -2067,7 +2057,24 @@ class Event {
2067
2057
 
2068
2058
 
2069
2059
  observedInDiaspora() {
2070
- return !(this.mask & IL_ONLY$2);
2060
+ return !(this.mask & flags.IL_ONLY);
2061
+ }
2062
+ /**
2063
+ * Is this event observed in Israel/Diaspora?
2064
+ * @example
2065
+ * const ev1 = new Event(new HDate(7, 'Sivan', 5749), 'Shavuot II', flags.CHAG | flags.CHUL_ONLY);
2066
+ * ev1.observedIn(false); // true
2067
+ * ev1.observedIn(true); // false
2068
+ * const ev2 = new Event(new HDate(26, 'Kislev', 5749), 'Chanukah: 3 Candles', 0);
2069
+ * ev2.observedIn(false); // true
2070
+ * ev2.observedIn(true); // true
2071
+ * @param {boolean} il
2072
+ * @return {boolean}
2073
+ */
2074
+
2075
+
2076
+ observedIn(il) {
2077
+ return il ? this.observedInIsrael() : this.observedInDiaspora();
2071
2078
  }
2072
2079
  /**
2073
2080
  * @deprecated
@@ -2618,7 +2625,7 @@ class Zmanim {
2618
2625
  throw new RangeError(`Longitude ${longitude} out of range [-180,180]`);
2619
2626
  }
2620
2627
 
2621
- const dt = greg.isDate(date) ? date : HDate.isHDate(date) ? date.greg() : throwTypeError$2(`invalid date: ${date}`);
2628
+ const dt = isDate(date) ? date : HDate.isHDate(date) ? date.greg() : throwTypeError$2(`invalid date: ${date}`);
2622
2629
  this.date = dt;
2623
2630
  this.solarCalc = new SolarCalc(this.date, latitude, longitude);
2624
2631
  this.sun = this.solarCalc.sun;
@@ -3983,8 +3990,8 @@ function getTodayIsHe(omer) {
3983
3990
 
3984
3991
  /* eslint-disable no-multi-spaces */
3985
3992
  const osdate = new Date(1923, 8, 11);
3986
- const osday = greg.greg2abs(osdate);
3987
- const nsday = greg.greg2abs(new Date(1975, 5, 24));
3993
+ const osday = greg2abs(osdate);
3994
+ const nsday = greg2abs(new Date(1975, 5, 24));
3988
3995
  const shas = [['Berachot', 64], ['Shabbat', 157], ['Eruvin', 105], ['Pesachim', 121], ['Shekalim', 22], ['Yoma', 88], ['Sukkah', 56], ['Beitzah', 40], ['Rosh Hashana', 35], ['Taanit', 31], ['Megillah', 32], ['Moed Katan', 29], ['Chagigah', 27], ['Yevamot', 122], ['Ketubot', 112], ['Nedarim', 91], ['Nazir', 66], ['Sotah', 49], ['Gitin', 90], ['Kiddushin', 82], ['Baba Kamma', 119], ['Baba Metzia', 119], ['Baba Batra', 176], ['Sanhedrin', 113], ['Makkot', 24], ['Shevuot', 49], ['Avodah Zarah', 76], ['Horayot', 14], ['Zevachim', 120], ['Menachot', 110], ['Chullin', 142], ['Bechorot', 61], ['Arachin', 34], ['Temurah', 34], ['Keritot', 28], ['Meilah', 22], ['Kinnim', 4], ['Tamid', 9], ['Midot', 5], ['Niddah', 73]].map(m => {
3989
3996
  return {
3990
3997
  name: m[0],
@@ -4006,7 +4013,7 @@ class DafYomi {
4006
4013
  * @param {Date|HDate|number} gregdate Gregorian date
4007
4014
  */
4008
4015
  constructor(gregdate) {
4009
- const cday = typeof gregdate === 'number' && !isNaN(gregdate) ? gregdate : greg.isDate(gregdate) ? greg.greg2abs(gregdate) : HDate.isHDate(gregdate) ? gregdate.abs() : throwTypeError$1(`non-date given to dafyomi: ${gregdate}`);
4016
+ const cday = typeof gregdate === 'number' && !isNaN(gregdate) ? gregdate : isDate(gregdate) ? greg2abs(gregdate) : HDate.isHDate(gregdate) ? gregdate.abs() : throwTypeError$1(`non-date given to dafyomi: ${gregdate}`);
4010
4017
 
4011
4018
  if (cday < osday) {
4012
4019
  throw new RangeError(`Date ${gregdate} too early; Daf Yomi cycle began on ${osdate}`);
@@ -5261,7 +5268,7 @@ function getHolidaysForYear_(year) {
5261
5268
  var mishnayot = [{k:"Berakhot",v:[5,8,6,7,5,8,5,8,5]},{k:"Peah",v:[6,8,8,11,8,11,8,9]},{k:"Demai",v:[4,5,6,7,11,12,8]},{k:"Kilayim",v:[9,11,7,9,8,9,8,6,10]},{k:"Sheviit",v:[8,10,10,10,9,6,7,11,9,9]},{k:"Terumot",v:[10,6,9,13,9,6,7,12,7,12,10]},{k:"Maasrot",v:[8,8,10,6,8]},{k:"Maaser Sheni",v:[7,10,13,12,15]},{k:"Challah",v:[9,8,10,11]},{k:"Orlah",v:[9,17,9]},{k:"Bikkurim",v:[11,11,12,5]},{k:"Shabbat",v:[11,7,6,2,4,10,4,7,7,6,6,6,7,4,3,8,8,3,6,5,3,6,5,5]},{k:"Eruvin",v:[10,6,9,11,9,10,11,11,4,15]},{k:"Pesachim",v:[7,8,8,9,10,6,13,8,11,9]},{k:"Shekalim",v:[7,5,4,9,6,6,7,8]},{k:"Yoma",v:[8,7,11,6,7,8,5,9]},{k:"Sukkah",v:[11,9,15,10,8]},{k:"Beitzah",v:[10,10,8,7,7]},{k:"Rosh Hashanah",v:[9,9,8,9]},{k:"Taanit",v:[7,10,9,8]},{k:"Megillah",v:[11,6,6,10]},{k:"Moed Katan",v:[10,5,9]},{k:"Chagigah",v:[8,7,8]},{k:"Yevamot",v:[4,10,10,13,6,6,6,6,6,9,7,6,13,9,10,7]},{k:"Ketubot",v:[10,10,9,12,9,7,10,8,9,6,6,4,11]},{k:"Nedarim",v:[4,5,11,8,6,10,9,7,10,8,12]},{k:"Nazir",v:[7,10,7,7,7,11,4,2,5]},{k:"Sotah",v:[9,6,8,5,5,4,8,7,15]},{k:"Gittin",v:[6,7,8,9,9,7,9,10,10]},{k:"Kiddushin",v:[10,10,13,14]},{k:"Bava Kamma",v:[4,6,11,9,7,6,7,7,12,10]},{k:"Bava Metzia",v:[8,11,12,12,11,8,11,9,13,6]},{k:"Bava Batra",v:[6,14,8,9,11,8,4,8,10,8]},{k:"Sanhedrin",v:[6,5,8,5,5,6,11,7,6,6,6]},{k:"Makkot",v:[10,8,16]},{k:"Shevuot",v:[7,5,11,13,5,7,8,6]},{k:"Eduyot",v:[14,10,12,12,7,3,9,7]},{k:"Avodah Zarah",v:[9,7,10,12,12]},{k:"Avot",v:[18,16,18,22,23,11]},{k:"Horayot",v:[5,7,8]},{k:"Zevachim",v:[4,5,6,6,8,7,6,12,7,8,8,6,8,10]},{k:"Menachot",v:[4,5,7,5,9,7,6,7,9,9,9,5,11]},{k:"Chullin",v:[7,10,7,7,5,7,6,6,8,4,2,5]},{k:"Bekhorot",v:[7,9,4,10,6,12,7,10,8]},{k:"Arakhin",v:[4,6,5,4,6,5,5,7,8]},{k:"Temurah",v:[6,3,5,4,6,5,6]},{k:"Keritot",v:[7,6,10,3,8,9]},{k:"Meilah",v:[4,9,8,6,5,6]},{k:"Tamid",v:[4,5,9,3,6,3,4]},{k:"Middot",v:[9,6,8,7,4]},{k:"Kinnim",v:[4,5,6]},{k:"Kelim",v:[9,8,8,4,11,4,6,11,8,8,9,8,8,8,6,8,17,9,10,7,3,10,5,17,9,9,12,10,8,4]},{k:"Oholot",v:[8,7,7,3,7,7,6,6,16,7,9,8,6,7,10,5,5,10]},{k:"Negaim",v:[6,5,8,11,5,8,5,10,3,10,12,7,12,13]},{k:"Parah",v:[4,5,11,4,9,5,12,11,9,6,9,11]},{k:"Tahorot",v:[9,8,8,13,9,10,9,9,9,8]},{k:"Mikvaot",v:[8,10,4,5,6,11,7,5,7,8]},{k:"Niddah",v:[7,7,7,7,9,14,5,4,11,8]},{k:"Makhshirin",v:[6,11,8,10,11,8]},{k:"Zavim",v:[6,4,3,7,12]},{k:"Tevul Yom",v:[5,8,6,7]},{k:"Yadayim",v:[5,4,5,8]},{k:"Oktzin",v:[6,10,12]}];
5262
5269
 
5263
5270
  const cycleStartDate = new Date(1947, 4, 20);
5264
- const mishnaYomiStart = greg.greg2abs(cycleStartDate);
5271
+ const mishnaYomiStart = greg2abs(cycleStartDate);
5265
5272
  const numMishnayot = 4192;
5266
5273
  const numDays = numMishnayot / 2;
5267
5274
  /**
@@ -5323,7 +5330,7 @@ class MishnaYomiIndex {
5323
5330
 
5324
5331
 
5325
5332
  lookup(date) {
5326
- const abs = typeof date === 'number' && !isNaN(date) ? date : greg.isDate(date) ? greg.greg2abs(date) : HDate.isHDate(date) ? date.abs() : throwTypeError(`Invalid date: ${date}`);
5333
+ const abs = typeof date === 'number' && !isNaN(date) ? date : isDate(date) ? greg2abs(date) : HDate.isHDate(date) ? date.abs() : throwTypeError(`Invalid date: ${date}`);
5327
5334
 
5328
5335
  if (abs < mishnaYomiStart) {
5329
5336
  const s = date.toISOString().substring(0, 10);
@@ -5510,7 +5517,7 @@ function getBirthdayOrAnniversary_(hyear, gdate) {
5510
5517
  return new HDate(day, month, hyear);
5511
5518
  }
5512
5519
 
5513
- const version="3.38.0";
5520
+ const version="3.39.0";
5514
5521
 
5515
5522
  const headers$1={"plural-forms":"nplurals=2; plural=(n > 1);",language:"en_CA@ashkenazi"};const 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};
5516
5523
 
@@ -5731,7 +5738,7 @@ function checkCandleOptions(options) {
5731
5738
 
5732
5739
  function getAbs(d) {
5733
5740
  if (typeof d == 'number') return d;
5734
- if (greg.isDate(d)) return greg.greg2abs(d);
5741
+ if (isDate(d)) return greg2abs(d);
5735
5742
  if (HDate.isHDate(d)) return d.abs();
5736
5743
  throw new TypeError(`Invalid date type: ${d}`);
5737
5744
  }
@@ -5793,11 +5800,11 @@ function getStartAndEnd(options) {
5793
5800
  startGreg.setFullYear(theYear);
5794
5801
  }
5795
5802
 
5796
- const startAbs = greg.greg2abs(startGreg);
5803
+ const startAbs = greg2abs(startGreg);
5797
5804
  let endAbs;
5798
5805
 
5799
5806
  if (options.month) {
5800
- endAbs = startAbs + greg.daysInMonth(theMonth, theYear) - 1;
5807
+ endAbs = startAbs + daysInMonth$1(theMonth, theYear) - 1;
5801
5808
  } else {
5802
5809
  const endYear = theYear + numYears;
5803
5810
  const endGreg = new Date(endYear, 0, 1);
@@ -5806,7 +5813,7 @@ function getStartAndEnd(options) {
5806
5813
  endGreg.setFullYear(endYear);
5807
5814
  }
5808
5815
 
5809
- endAbs = greg.greg2abs(endGreg) - 1;
5816
+ endAbs = greg2abs(endGreg) - 1;
5810
5817
  }
5811
5818
 
5812
5819
  return [startAbs, endAbs];
@@ -6071,7 +6078,7 @@ class HebrewCalendar {
6071
6078
  warnUnrecognizedOptions(options);
6072
6079
  const startAbs = startAndEnd[0];
6073
6080
  const endAbs = startAndEnd[1];
6074
- const startGreg = greg.abs2greg(startAbs);
6081
+ const startGreg = abs2greg(startAbs);
6075
6082
 
6076
6083
  if (startGreg.getFullYear() < 100) {
6077
6084
  options.candlelighting = false;
@@ -6089,7 +6096,7 @@ class HebrewCalendar {
6089
6096
 
6090
6097
  if (hyear != currentYear) {
6091
6098
  currentYear = hyear;
6092
- holidaysYear = HebrewCalendar.getHolidaysForYear(currentYear);
6099
+ holidaysYear = getHolidaysForYear_(currentYear);
6093
6100
 
6094
6101
  if (options.sedrot && currentYear >= 3762) {
6095
6102
  sedra = getSedra_(currentYear, il);
@@ -6373,14 +6380,26 @@ class HebrewCalendar {
6373
6380
  */
6374
6381
 
6375
6382
  function appendHolidayAndRelated(events, ev, options, candlesEv, dow) {
6376
- const eFlags = ev.getFlags();
6377
6383
  const il = options.il;
6378
- const observed = il && ev.observedInIsrael() || !il && ev.observedInDiaspora();
6379
- const mask = options.mask;
6380
6384
 
6381
- if (observed && (eFlags & mask || !eFlags && !options.userMask)) {
6382
- const location = options.location;
6385
+ if (!ev.observedIn(il)) {
6386
+ return candlesEv; // holiday isn't observed here; bail out early
6387
+ }
6388
+
6389
+ const eFlags = ev.getFlags();
6390
+ const location = options.location;
6391
+ const isMajorFast = Boolean(eFlags & MAJOR_FAST);
6392
+ const isMinorFast = Boolean(eFlags & MINOR_FAST);
6393
+
6394
+ if (options.candlelighting && (isMajorFast || isMinorFast)) {
6395
+ ev = makeFastStartEnd(ev, location);
6383
6396
 
6397
+ if (ev.startEvent && (isMajorFast || isMinorFast && !options.noMinorFast)) {
6398
+ events.push(ev.startEvent);
6399
+ }
6400
+ }
6401
+
6402
+ if (eFlags & options.mask || !eFlags && !options.userMask) {
6384
6403
  if (options.candlelighting && eFlags & MASK_LIGHT_CANDLES) {
6385
6404
  const hd = ev.getDate();
6386
6405
  candlesEv = makeCandleEvent(ev, hd, dow, location, options);
@@ -6402,22 +6421,14 @@ function appendHolidayAndRelated(events, ev, options, candlesEv, dow) {
6402
6421
  }
6403
6422
 
6404
6423
  if (!options.noHolidays) {
6405
- if (options.candlelighting && eFlags & (MINOR_FAST | MAJOR_FAST)) {
6406
- ev = makeFastStartEnd(ev, location);
6407
- }
6408
-
6409
- if (ev.startEvent) {
6410
- events.push(ev.startEvent);
6411
- }
6412
-
6413
6424
  events.push(ev); // the original event itself
6414
-
6415
- if (ev.endEvent) {
6416
- events.push(ev.endEvent);
6417
- }
6418
6425
  }
6419
6426
  }
6420
6427
 
6428
+ if (ev.endEvent && (isMajorFast || isMinorFast && !options.noMinorFast)) {
6429
+ events.push(ev.endEvent);
6430
+ }
6431
+
6421
6432
  return candlesEv;
6422
6433
  }
6423
6434
 
package/hebcal.d.ts CHANGED
@@ -27,6 +27,7 @@ declare module '@hebcal/core' {
27
27
  getEmoji(): string;
28
28
  observedInIsrael(): boolean;
29
29
  observedInDiaspora(): boolean;
30
+ observedIn(il: boolean): boolean;
30
31
  clone(): Event;
31
32
  }
32
33
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hebcal/core",
3
- "version": "3.38.0",
3
+ "version": "3.39.0",
4
4
  "author": "Michael J. Radwin (https://github.com/mjradwin)",
5
5
  "contributors": [
6
6
  "Eyal Schachter (https://github.com/Scimonster)",
@@ -47,7 +47,7 @@
47
47
  "pretest": "npm run build",
48
48
  "typedef": "npx jsdoc -t node_modules/tsd-jsdoc/dist -r ./src/",
49
49
  "lint": "eslint src",
50
- "coverage-local": "nyc --concurrency 2",
50
+ "coverage-local": "nyc --concurrency 2 ava",
51
51
  "coverage": "nyc --reporter=lcov ava --concurrency 4 && codecov",
52
52
  "test": "ava --concurrency 4"
53
53
  },
@@ -63,25 +63,25 @@
63
63
  "verbose": true
64
64
  },
65
65
  "devDependencies": {
66
- "@babel/core": "^7.17.10",
67
- "@babel/preset-env": "^7.17.10",
66
+ "@babel/core": "^7.18.5",
67
+ "@babel/preset-env": "^7.18.2",
68
68
  "@babel/register": "^7.17.7",
69
69
  "@hebcal/solar-calc": "^1.1.2",
70
70
  "@rollup/plugin-babel": "^5.3.1",
71
71
  "@rollup/plugin-commonjs": "^22.0.0",
72
72
  "@rollup/plugin-json": "^4.1.0",
73
73
  "@rollup/plugin-node-resolve": "^13.3.0",
74
- "ava": "^4.2.0",
74
+ "ava": "^4.3.0",
75
75
  "codecov": "^3.8.3",
76
- "core-js": "^3.22.5",
77
- "eslint": "^8.15.0",
76
+ "core-js": "^3.23.1",
77
+ "eslint": "^8.17.0",
78
78
  "eslint-config-google": "^0.14.0",
79
79
  "jsdoc": "^3.6.10",
80
80
  "jsdoc-to-markdown": "^7.1.1",
81
81
  "nyc": "^15.1.0",
82
- "rollup": "^2.72.1",
82
+ "rollup": "^2.75.6",
83
83
  "rollup-plugin-terser": "^7.0.2",
84
84
  "tsd-jsdoc": "^2.5.0",
85
- "ttag-cli": "^1.9.3"
85
+ "ttag-cli": "^1.9.4"
86
86
  }
87
87
  }