@hebcal/core 5.0.0-rc1 → 5.0.0-rc3

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 v5.0.0-rc1 */
1
+ /*! @hebcal/core v5.0.0-rc3 */
2
2
  'use strict';
3
3
 
4
4
  const GERESH = '׳';
@@ -373,7 +373,7 @@ const ABS_2SEP1752 = 639785;
373
373
  /**
374
374
  * Gregorian date helper functions.
375
375
  */
376
- var greg;
376
+ exports.greg = void 0;
377
377
  (function (greg) {
378
378
  /**
379
379
  * Long names of the Gregorian months (1='January', 12='December')
@@ -505,7 +505,7 @@ var greg;
505
505
  return dt;
506
506
  }
507
507
  greg.abs2greg = abs2greg;
508
- })(greg || (greg = {}));
508
+ })(exports.greg || (exports.greg = {}));
509
509
 
510
510
  /*
511
511
  * More minimal HDate
@@ -815,8 +815,8 @@ function toSimpleHebrewDate(obj) {
815
815
  else if (typeof obj === 'number') {
816
816
  return abs2hebrew(obj);
817
817
  }
818
- else if (greg.isDate(obj)) {
819
- const abs = greg.greg2abs(obj);
818
+ else if (exports.greg.isDate(obj)) {
819
+ const abs = exports.greg.greg2abs(obj);
820
820
  return abs2hebrew(abs);
821
821
  }
822
822
  else {
@@ -861,7 +861,7 @@ function getYahrzeit(hyear, date) {
861
861
  if (typeof hd === 'undefined') {
862
862
  return hd;
863
863
  }
864
- return greg.abs2greg(hebrew2abs(hd.yy, hd.mm, hd.dd));
864
+ return exports.greg.abs2greg(hebrew2abs(hd.yy, hd.mm, hd.dd));
865
865
  }
866
866
  function getYahrzeitHD(hyear, date) {
867
867
  let hDeath = toSimpleHebrewDate(date);
@@ -932,7 +932,7 @@ function getBirthdayOrAnniversary(hyear, date) {
932
932
  if (typeof hd === 'undefined') {
933
933
  return hd;
934
934
  }
935
- return greg.abs2greg(hebrew2abs(hd.yy, hd.mm, hd.dd));
935
+ return exports.greg.abs2greg(hebrew2abs(hd.yy, hd.mm, hd.dd));
936
936
  }
937
937
  function getBirthdayHD(hyear, date) {
938
938
  const orig = toSimpleHebrewDate(date);
@@ -1088,7 +1088,7 @@ class HDate {
1088
1088
  day = new Date();
1089
1089
  }
1090
1090
  // 1 argument
1091
- const abs0 = typeof day === 'number' && !isNaN(day) ? day : greg.isDate(day) ? greg.greg2abs(day) : HDate.isHDate(day) ? {
1091
+ const abs0 = typeof day === 'number' && !isNaN(day) ? day : exports.greg.isDate(day) ? exports.greg.greg2abs(day) : HDate.isHDate(day) ? {
1092
1092
  dd: day.day,
1093
1093
  mm: day.month,
1094
1094
  yy: day.year
@@ -1205,7 +1205,7 @@ class HDate {
1205
1205
  * @return {Date}
1206
1206
  */
1207
1207
  greg() {
1208
- return greg.abs2greg(this.abs());
1208
+ return exports.greg.abs2greg(this.abs());
1209
1209
  }
1210
1210
 
1211
1211
  /**
@@ -3600,7 +3600,7 @@ class Zmanim {
3600
3600
  * hours, minutes, seconds and milliseconds are ignored.
3601
3601
  */
3602
3602
  constructor(gloc, date) {
3603
- const dt = greg.isDate(date) ? date : HDate.isHDate(date) ? date.greg() : throwTypeError(`invalid date: ${date}`);
3603
+ const dt = exports.greg.isDate(date) ? date : HDate.isHDate(date) ? date.greg() : throwTypeError(`invalid date: ${date}`);
3604
3604
  this.date = dt;
3605
3605
  this.gloc = gloc;
3606
3606
  const plainDate = s.PlainDate.from({
@@ -3756,8 +3756,8 @@ class Zmanim {
3756
3756
  */
3757
3757
  sofZmanShmaMGA() {
3758
3758
  // Magen Avraham
3759
- const alot72 = this.sunriseOffset(-72, false);
3760
- const tzeit72 = this.sunsetOffset(72, false);
3759
+ const alot72 = this.sunriseOffset(-72, false, true);
3760
+ const tzeit72 = this.sunsetOffset(72, false, true);
3761
3761
  const temporalHour = (tzeit72 - alot72) / 12; // ms in hour
3762
3762
  return new Date(alot72.getTime() + 3 * temporalHour);
3763
3763
  }
@@ -3767,8 +3767,8 @@ class Zmanim {
3767
3767
  */
3768
3768
  sofZmanTfillaMGA() {
3769
3769
  // Magen Avraham
3770
- const alot72 = this.sunriseOffset(-72, false);
3771
- const tzeit72 = this.sunsetOffset(72, false);
3770
+ const alot72 = this.sunriseOffset(-72, false, true);
3771
+ const tzeit72 = this.sunsetOffset(72, false, true);
3772
3772
  const temporalHour = (tzeit72 - alot72) / 12; // ms in hour
3773
3773
  return new Date(alot72.getTime() + 4 * temporalHour);
3774
3774
  }
@@ -3883,10 +3883,11 @@ class Zmanim {
3883
3883
  * Returns sunrise + `offset` minutes (either positive or negative).
3884
3884
  * @param {number} offset minutes
3885
3885
  * @param {boolean} roundMinute round time to nearest minute (default true)
3886
+ * @param {boolean} seaLevel use sea-level sunrise (default false)
3886
3887
  * @return {Date}
3887
3888
  */
3888
- sunriseOffset(offset, roundMinute = true) {
3889
- const sunrise = this.seaLevelSunrise();
3889
+ sunriseOffset(offset, roundMinute = true, seaLevel = false) {
3890
+ const sunrise = seaLevel ? this.seaLevelSunrise() : this.sunrise();
3890
3891
  if (isNaN(sunrise.getTime())) {
3891
3892
  return sunrise;
3892
3893
  }
@@ -3904,10 +3905,11 @@ class Zmanim {
3904
3905
  * Returns sunset + `offset` minutes (either positive or negative).
3905
3906
  * @param {number} offset minutes
3906
3907
  * @param {boolean} roundMinute round time to nearest minute (default true)
3908
+ * @param {boolean} seaLevel use sea-level sunset (default false)
3907
3909
  * @return {Date}
3908
3910
  */
3909
- sunsetOffset(offset, roundMinute = true) {
3910
- const sunset = this.seaLevelSunset();
3911
+ sunsetOffset(offset, roundMinute = true, seaLevel = false) {
3912
+ const sunset = seaLevel ? this.seaLevelSunset() : this.sunset();
3911
3913
  if (isNaN(sunset.getTime())) {
3912
3914
  return sunset;
3913
3915
  }
@@ -5947,7 +5949,7 @@ class DailyLearning {
5947
5949
  }
5948
5950
  }
5949
5951
 
5950
- const version="5.0.0-rc1";
5952
+ const version="5.0.0-rc3";
5951
5953
 
5952
5954
  const headers$1={"plural-forms":"nplurals=2; plural=(n > 1);"};const contexts$1={"":{Shabbat:["Shabbos"],"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"],"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"],"Alot HaShachar":["Alos HaShachar"],"Kriat Shema, sof zeman":["Krias Shema, sof zman"],"Tefilah, sof zeman":["Tefilah, sof zman"],"Kriat Shema, sof zeman (MGA)":["Krias Shema, sof zman (MGA)"],"Tefilah, sof zeman (MGA)":["Tefilah, sof zman (MGA)"],"Chatzot HaLailah":["Chatzos HaLailah"],"Chatzot hayom":["Chatzos"],"Tzeit HaKochavim":["Tzeis HaKochavim"],"Birkat Hachamah":["Birkas Hachamah"],"Shushan Purim Katan":["Shushan Purim Koton"]}};var poAshkenazi = {headers:headers$1,contexts:contexts$1};
5953
5955
 
@@ -6412,7 +6414,7 @@ function checkCandleOptions(options) {
6412
6414
  */
6413
6415
  function getAbs(d) {
6414
6416
  if (typeof d == 'number') return d;
6415
- if (greg.isDate(d)) return greg.greg2abs(d);
6417
+ if (exports.greg.isDate(d)) return exports.greg.greg2abs(d);
6416
6418
  if (HDate.isHDate(d)) return d.abs();
6417
6419
  throw new TypeError(`Invalid date type: ${d}`);
6418
6420
  }
@@ -6462,17 +6464,17 @@ function getStartAndEnd(options) {
6462
6464
  if (theYear < 100) {
6463
6465
  startGreg.setFullYear(theYear);
6464
6466
  }
6465
- const startAbs = greg.greg2abs(startGreg);
6467
+ const startAbs = exports.greg.greg2abs(startGreg);
6466
6468
  let endAbs;
6467
6469
  if (options.month) {
6468
- endAbs = startAbs + greg.daysInMonth(theMonth, theYear) - 1;
6470
+ endAbs = startAbs + exports.greg.daysInMonth(theMonth, theYear) - 1;
6469
6471
  } else {
6470
6472
  const endYear = theYear + numYears;
6471
6473
  const endGreg = new Date(endYear, 0, 1);
6472
6474
  if (endYear < 100) {
6473
6475
  endGreg.setFullYear(endYear);
6474
6476
  }
6475
- endAbs = greg.greg2abs(endGreg) - 1;
6477
+ endAbs = exports.greg.greg2abs(endGreg) - 1;
6476
6478
  }
6477
6479
  return [startAbs, endAbs];
6478
6480
  }
@@ -6761,7 +6763,7 @@ class HebrewCalendar {
6761
6763
  warnUnrecognizedOptions(options);
6762
6764
  const startAbs = startAndEnd[0];
6763
6765
  const endAbs = startAndEnd[1];
6764
- const startGreg = greg.abs2greg(startAbs);
6766
+ const startGreg = exports.greg.abs2greg(startAbs);
6765
6767
  if (startGreg.getFullYear() < 100) {
6766
6768
  options.candlelighting = false;
6767
6769
  }
package/dist/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- /*! @hebcal/core v5.0.0-rc1 */
1
+ /*! @hebcal/core v5.0.0-rc3 */
2
2
  const GERESH = '׳';
3
3
  const GERSHAYIM = '״';
4
4
  const heb2num = {
@@ -3754,8 +3754,8 @@ class Zmanim {
3754
3754
  */
3755
3755
  sofZmanShmaMGA() {
3756
3756
  // Magen Avraham
3757
- const alot72 = this.sunriseOffset(-72, false);
3758
- const tzeit72 = this.sunsetOffset(72, false);
3757
+ const alot72 = this.sunriseOffset(-72, false, true);
3758
+ const tzeit72 = this.sunsetOffset(72, false, true);
3759
3759
  const temporalHour = (tzeit72 - alot72) / 12; // ms in hour
3760
3760
  return new Date(alot72.getTime() + 3 * temporalHour);
3761
3761
  }
@@ -3765,8 +3765,8 @@ class Zmanim {
3765
3765
  */
3766
3766
  sofZmanTfillaMGA() {
3767
3767
  // Magen Avraham
3768
- const alot72 = this.sunriseOffset(-72, false);
3769
- const tzeit72 = this.sunsetOffset(72, false);
3768
+ const alot72 = this.sunriseOffset(-72, false, true);
3769
+ const tzeit72 = this.sunsetOffset(72, false, true);
3770
3770
  const temporalHour = (tzeit72 - alot72) / 12; // ms in hour
3771
3771
  return new Date(alot72.getTime() + 4 * temporalHour);
3772
3772
  }
@@ -3881,10 +3881,11 @@ class Zmanim {
3881
3881
  * Returns sunrise + `offset` minutes (either positive or negative).
3882
3882
  * @param {number} offset minutes
3883
3883
  * @param {boolean} roundMinute round time to nearest minute (default true)
3884
+ * @param {boolean} seaLevel use sea-level sunrise (default false)
3884
3885
  * @return {Date}
3885
3886
  */
3886
- sunriseOffset(offset, roundMinute = true) {
3887
- const sunrise = this.seaLevelSunrise();
3887
+ sunriseOffset(offset, roundMinute = true, seaLevel = false) {
3888
+ const sunrise = seaLevel ? this.seaLevelSunrise() : this.sunrise();
3888
3889
  if (isNaN(sunrise.getTime())) {
3889
3890
  return sunrise;
3890
3891
  }
@@ -3902,10 +3903,11 @@ class Zmanim {
3902
3903
  * Returns sunset + `offset` minutes (either positive or negative).
3903
3904
  * @param {number} offset minutes
3904
3905
  * @param {boolean} roundMinute round time to nearest minute (default true)
3906
+ * @param {boolean} seaLevel use sea-level sunset (default false)
3905
3907
  * @return {Date}
3906
3908
  */
3907
- sunsetOffset(offset, roundMinute = true) {
3908
- const sunset = this.seaLevelSunset();
3909
+ sunsetOffset(offset, roundMinute = true, seaLevel = false) {
3910
+ const sunset = seaLevel ? this.seaLevelSunset() : this.sunset();
3909
3911
  if (isNaN(sunset.getTime())) {
3910
3912
  return sunset;
3911
3913
  }
@@ -5945,7 +5947,7 @@ class DailyLearning {
5945
5947
  }
5946
5948
  }
5947
5949
 
5948
- const version="5.0.0-rc1";
5950
+ const version="5.0.0-rc3";
5949
5951
 
5950
5952
  const headers$1={"plural-forms":"nplurals=2; plural=(n > 1);"};const contexts$1={"":{Shabbat:["Shabbos"],"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"],"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"],"Alot HaShachar":["Alos HaShachar"],"Kriat Shema, sof zeman":["Krias Shema, sof zman"],"Tefilah, sof zeman":["Tefilah, sof zman"],"Kriat Shema, sof zeman (MGA)":["Krias Shema, sof zman (MGA)"],"Tefilah, sof zeman (MGA)":["Tefilah, sof zman (MGA)"],"Chatzot HaLailah":["Chatzos HaLailah"],"Chatzot hayom":["Chatzos"],"Tzeit HaKochavim":["Tzeis HaKochavim"],"Birkat Hachamah":["Birkas Hachamah"],"Shushan Purim Katan":["Shushan Purim Koton"]}};var poAshkenazi = {headers:headers$1,contexts:contexts$1};
5951
5953
 
@@ -7134,4 +7136,4 @@ function appendHolidayAndRelated(events, ev, options, candlesEv, dow) {
7134
7136
  return candlesEv;
7135
7137
  }
7136
7138
 
7137
- export { AsaraBTevetEvent, CandleLightingEvent, DailyLearning, Event, GeoLocation, HDate, HavdalahEvent, HebrewCalendar, HebrewDateEvent, HolidayEvent, Locale, Location, MevarchimChodeshEvent, Molad, MoladEvent, NOAACalculator, OmerEvent, ParshaEvent, RoshChodeshEvent, RoshHashanaEvent, Sedra, TimedEvent, Zmanim, flags, gematriya, gematriyaStrToNum, months, parshiot, version };
7139
+ export { AsaraBTevetEvent, CandleLightingEvent, DailyLearning, Event, GeoLocation, HDate, HavdalahEvent, HebrewCalendar, HebrewDateEvent, HolidayEvent, Locale, Location, MevarchimChodeshEvent, Molad, MoladEvent, NOAACalculator, OmerEvent, ParshaEvent, RoshChodeshEvent, RoshHashanaEvent, Sedra, TimedEvent, Zmanim, flags, gematriya, gematriyaStrToNum, greg, months, parshiot, version };
package/hebcal.d.ts CHANGED
@@ -806,6 +806,53 @@ declare module '@hebcal/core' {
806
806
  getChalakim(): number;
807
807
  }
808
808
 
809
+ /**
810
+ * Gregorian date helper functions.
811
+ */
812
+ export declare namespace greg {
813
+ /**
814
+ * Long names of the Gregorian months (1='January', 12='December')
815
+ * @readonly
816
+ * @type {string[]}
817
+ */
818
+ const monthNames: string[];
819
+ /**
820
+ * Returns true if the Gregorian year is a leap year
821
+ * @param {number} year Gregorian year
822
+ * @return {boolean}
823
+ */
824
+ function isLeapYear(year: number): boolean;
825
+ /**
826
+ * Number of days in the Gregorian month for given year
827
+ * @param {number} month Gregorian month (1=January, 12=December)
828
+ * @param {number} year Gregorian year
829
+ * @return {number}
830
+ */
831
+ function daysInMonth(month: number, year: number): number;
832
+ /**
833
+ * Returns true if the object is a Javascript Date
834
+ * @param {Object} obj
835
+ * @return {boolean}
836
+ */
837
+ function isDate(obj: any): boolean;
838
+ /**
839
+ * Converts Gregorian date to absolute R.D. (Rata Die) days
840
+ * @param {Date} date Gregorian date
841
+ * @return {number}
842
+ */
843
+ function greg2abs(date: Date): number;
844
+ /**
845
+ * Converts from Rata Die (R.D. number) to Gregorian date.
846
+ * See the footnote on page 384 of ``Calendrical Calculations, Part II:
847
+ * Three Historical Calendars'' by E. M. Reingold, N. Dershowitz, and S. M.
848
+ * Clamen, Software--Practice and Experience, Volume 23, Number 4
849
+ * (April, 1993), pages 383-404 for an explanation.
850
+ * @param {number} abs - R.D. number of days
851
+ * @return {Date}
852
+ */
853
+ function abs2greg(abs: number): Date;
854
+ }
855
+
809
856
  /**
810
857
  * Hebrew months of the year (NISAN=1, TISHREI=7)
811
858
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hebcal/core",
3
- "version": "5.0.0-rc1",
3
+ "version": "5.0.0-rc3",
4
4
  "author": "Michael J. Radwin (https://github.com/mjradwin)",
5
5
  "contributors": [
6
6
  "Eyal Schachter (https://github.com/Scimonster)",
@@ -77,7 +77,7 @@
77
77
  "jsdoc": "^4.0.2",
78
78
  "jsdoc-to-markdown": "^8.0.0",
79
79
  "nyc": "^15.1.0",
80
- "rollup": "^4.5.1",
80
+ "rollup": "^4.5.2",
81
81
  "temporal-polyfill": "^0.1.1",
82
82
  "ttag-cli": "^1.10.9"
83
83
  }