@hebcal/core 6.9.1 → 6.9.3

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.
Files changed (50) hide show
  1. package/dist/bundle.js +145 -82
  2. package/dist/bundle.js.map +1 -1
  3. package/dist/bundle.min.js +18 -18
  4. package/dist/bundle.min.js.map +1 -1
  5. package/dist/esm/DailyLearning.js +1 -1
  6. package/dist/esm/HebrewDateEvent.js +1 -1
  7. package/dist/esm/HolidayEvent.js +1 -1
  8. package/dist/esm/MevarchimChodeshEvent.js +1 -1
  9. package/dist/esm/ParshaEvent.js +1 -1
  10. package/dist/esm/TimedEvent.d.ts +8 -0
  11. package/dist/esm/TimedEvent.js +9 -1
  12. package/dist/esm/TimedEvent.js.map +1 -1
  13. package/dist/esm/YomKippurKatanEvent.js +1 -1
  14. package/dist/esm/ashkenazi.po.js +1 -1
  15. package/dist/esm/calendar.js +1 -1
  16. package/dist/esm/candles.js +1 -1
  17. package/dist/esm/cities.json.js +1 -1
  18. package/dist/esm/event.js +1 -1
  19. package/dist/esm/getStartAndEnd.js +1 -1
  20. package/dist/esm/hallel.js +1 -1
  21. package/dist/esm/he-x-NoNikud.po.js +1 -1
  22. package/dist/esm/he.po.js +1 -1
  23. package/dist/esm/hebcal.js +1 -1
  24. package/dist/esm/holidays.js +1 -1
  25. package/dist/esm/index.js +1 -1
  26. package/dist/esm/isAssurBemlacha.js +1 -1
  27. package/dist/esm/isAveilut.js +1 -1
  28. package/dist/esm/isFastDay.js +1 -1
  29. package/dist/esm/locale.js +1 -1
  30. package/dist/esm/location.js +1 -1
  31. package/dist/esm/modern.js +1 -1
  32. package/dist/esm/molad.js +1 -1
  33. package/dist/esm/moladBase.js +1 -1
  34. package/dist/esm/moladDate.js +1 -1
  35. package/dist/esm/omer.js +1 -1
  36. package/dist/esm/parshaName.js +1 -1
  37. package/dist/esm/parshaYear.js +1 -1
  38. package/dist/esm/pkgVersion.d.ts +1 -1
  39. package/dist/esm/pkgVersion.js +2 -2
  40. package/dist/esm/pkgVersion.js.map +1 -1
  41. package/dist/esm/reformatTimeStr.js +1 -1
  42. package/dist/esm/sedra.js +1 -1
  43. package/dist/esm/sefira.json.js +1 -1
  44. package/dist/esm/staticHolidays.js +1 -1
  45. package/dist/esm/string.js +1 -1
  46. package/dist/esm/tachanun.js +1 -1
  47. package/dist/esm/zmanim.d.ts +18 -1
  48. package/dist/esm/zmanim.js +86 -55
  49. package/dist/esm/zmanim.js.map +1 -1
  50. package/package.json +9 -8
package/dist/bundle.js CHANGED
@@ -1,11 +1,11 @@
1
- /*! @hebcal/core v6.9.1, distributed under GPLv2 https://www.gnu.org/licenses/gpl-2.0.txt */
1
+ /*! @hebcal/core v6.9.3, distributed under GPLv2 https://www.gnu.org/licenses/gpl-2.0.txt */
2
2
  var hebcal = (function (exports) {
3
3
  'use strict';
4
4
 
5
5
  /** DO NOT EDIT THIS AUTO-GENERATED FILE! */
6
- const version = '6.9.1';
6
+ const version = '6.9.3';
7
7
 
8
- /*! @hebcal/hdate v0.22.7, distributed under GPLv2 https://www.gnu.org/licenses/gpl-2.0.txt */
8
+ /*! @hebcal/hdate v0.22.8, distributed under GPLv2 https://www.gnu.org/licenses/gpl-2.0.txt */
9
9
  /** @private */
10
10
  const lengths = [0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
11
11
  /** @private */
@@ -189,7 +189,7 @@ function abs2greg(abs) {
189
189
  return dt;
190
190
  }
191
191
 
192
- /*! @hebcal/hdate v0.22.7, distributed under GPLv2 https://www.gnu.org/licenses/gpl-2.0.txt */
192
+ /*! @hebcal/hdate v0.22.8, distributed under GPLv2 https://www.gnu.org/licenses/gpl-2.0.txt */
193
193
  /* eslint-disable @typescript-eslint/no-namespace */
194
194
  /**
195
195
  * Gregorian date helper functions.
@@ -219,7 +219,7 @@ exports.greg.greg2abs = greg2abs;
219
219
  exports.greg.isDate = isDate;
220
220
  exports.greg.isLeapYear = isGregLeapYear;
221
221
 
222
- /*! @hebcal/hdate v0.22.7, distributed under GPLv2 https://www.gnu.org/licenses/gpl-2.0.txt */
222
+ /*! @hebcal/hdate v0.22.8, distributed under GPLv2 https://www.gnu.org/licenses/gpl-2.0.txt */
223
223
  /**
224
224
  * Removes niqqud from Hebrew string
225
225
  * @example
@@ -235,7 +235,7 @@ function hebrewStripNikkud(str) {
235
235
  return a.replace(/[\u0590-\u05bd]/g, '').replace(/[\u05bf-\u05c7]/g, '');
236
236
  }
237
237
 
238
- /*! @hebcal/hdate v0.22.7, distributed under GPLv2 https://www.gnu.org/licenses/gpl-2.0.txt */
238
+ /*! @hebcal/hdate v0.22.8, distributed under GPLv2 https://www.gnu.org/licenses/gpl-2.0.txt */
239
239
  /*
240
240
  * More minimal HDate
241
241
  */
@@ -743,7 +743,7 @@ function monthFromName(monthName) {
743
743
  throw new RangeError(`bad monthName: ${monthName}`);
744
744
  }
745
745
 
746
- /*! @hebcal/hdate v0.22.7, distributed under GPLv2 https://www.gnu.org/licenses/gpl-2.0.txt */
746
+ /*! @hebcal/hdate v0.22.8, distributed under GPLv2 https://www.gnu.org/licenses/gpl-2.0.txt */
747
747
  const NISAN$4 = months.NISAN;
748
748
  const CHESHVAN$1 = months.CHESHVAN;
749
749
  const KISLEV$1 = months.KISLEV;
@@ -964,7 +964,7 @@ function getBirthdayHD(hyear, date) {
964
964
  return { yy: hyear, mm: month, dd: day };
965
965
  }
966
966
 
967
- /*! @hebcal/hdate v0.22.7, distributed under GPLv2 https://www.gnu.org/licenses/gpl-2.0.txt */
967
+ /*! @hebcal/hdate v0.22.8, distributed under GPLv2 https://www.gnu.org/licenses/gpl-2.0.txt */
968
968
  const GERESH = '׳';
969
969
  const GERSHAYIM = '״';
970
970
  const heb2num = {
@@ -1083,7 +1083,7 @@ function gematriyaStrToNum(str) {
1083
1083
  return num;
1084
1084
  }
1085
1085
 
1086
- /*! @hebcal/hdate v0.22.7, distributed under GPLv2 https://www.gnu.org/licenses/gpl-2.0.txt */
1086
+ /*! @hebcal/hdate v0.22.8, distributed under GPLv2 https://www.gnu.org/licenses/gpl-2.0.txt */
1087
1087
  /**
1088
1088
  * Formats a number with leading zeros so the resulting string is 4 digits long.
1089
1089
  * Similar to `string.padStart(4, '0')` but will also format
@@ -1123,7 +1123,7 @@ function pad2(num) {
1123
1123
  return String(num);
1124
1124
  }
1125
1125
 
1126
- /*! @hebcal/hdate v0.22.7, distributed under GPLv2 https://www.gnu.org/licenses/gpl-2.0.txt */
1126
+ /*! @hebcal/hdate v0.22.8, distributed under GPLv2 https://www.gnu.org/licenses/gpl-2.0.txt */
1127
1127
  const _formatters = new Map();
1128
1128
  /**
1129
1129
  * @private
@@ -1204,13 +1204,13 @@ function isoDateString(dt) {
1204
1204
  pad2(dt.getDate()));
1205
1205
  }
1206
1206
 
1207
- /*! @hebcal/hdate v0.22.7, distributed under GPLv2 https://www.gnu.org/licenses/gpl-2.0.txt */
1207
+ /*! @hebcal/hdate v0.22.8, distributed under GPLv2 https://www.gnu.org/licenses/gpl-2.0.txt */
1208
1208
  var poAshkenazi$1 = { "headers": { "plural-forms": "nplurals=2; plural=(n > 1);", "language": "und-x-ashkenaz" }, "contexts": { "": { "Tevet": ["Teves"] } } };
1209
1209
 
1210
- /*! @hebcal/hdate v0.22.7, distributed under GPLv2 https://www.gnu.org/licenses/gpl-2.0.txt */
1210
+ /*! @hebcal/hdate v0.22.8, distributed under GPLv2 https://www.gnu.org/licenses/gpl-2.0.txt */
1211
1211
  var poHe$1 = { "headers": { "plural-forms": "nplurals=2; plural=(n > 1);", "language": "he" }, "contexts": { "": { "Adar": ["אֲדָר"], "Adar I": ["אֲדָר א׳"], "Adar II": ["אֲדָר ב׳"], "Av": ["אָב"], "Cheshvan": ["חֶשְׁוָן"], "Elul": ["אֱלוּל"], "Iyyar": ["אִיָּיר"], "Kislev": ["כִּסְלֵו"], "Nisan": ["נִיסָן"], "Sh'vat": ["שְׁבָט"], "Sivan": ["סִיוָן"], "Tamuz": ["תַּמּוּז"], "Tammuz": ["תַּמּוּז"], "Tevet": ["טֵבֵת"], "Tishrei": ["תִּשְׁרֵי"] } } };
1212
1212
 
1213
- /*! @hebcal/hdate v0.22.7, distributed under GPLv2 https://www.gnu.org/licenses/gpl-2.0.txt */
1213
+ /*! @hebcal/hdate v0.22.8, distributed under GPLv2 https://www.gnu.org/licenses/gpl-2.0.txt */
1214
1214
  const noopLocale = {
1215
1215
  headers: { 'plural-forms': 'nplurals=2; plural=(n!=1);' },
1216
1216
  contexts: { '': {} },
@@ -1494,7 +1494,7 @@ Locale.addLocale('he', poHe$1);
1494
1494
  const poHeNoNikud$1 = Locale.copyLocaleNoNikud(poHe$1);
1495
1495
  Locale.addLocale('he-x-NoNikud', poHeNoNikud$1);
1496
1496
 
1497
- /*! @hebcal/hdate v0.22.7, distributed under GPLv2 https://www.gnu.org/licenses/gpl-2.0.txt */
1497
+ /*! @hebcal/hdate v0.22.8, distributed under GPLv2 https://www.gnu.org/licenses/gpl-2.0.txt */
1498
1498
  /*
1499
1499
  Hebcal - A Jewish Calendar Generator
1500
1500
  Copyright (c) 1994-2020 Danny Sadinoff
@@ -2163,7 +2163,10 @@ class HDate {
2163
2163
  * HDate.dayOnOrBefore(6, 733359 + 6); // 733361 (Saturday 15 November 2008)
2164
2164
  */
2165
2165
  static dayOnOrBefore(dayOfWeek, absdate) {
2166
- return absdate - ((absdate - dayOfWeek) % 7);
2166
+ // Use a floored modulo: R.D. numbers are negative before the common
2167
+ // era, and JavaScript's `%` truncates toward zero, which would return
2168
+ // a day *after* absdate for those negative inputs.
2169
+ return absdate - mod(absdate - dayOfWeek, 7);
2167
2170
  }
2168
2171
  /**
2169
2172
  * Tests if the object is an instance of `HDate`
@@ -2326,7 +2329,7 @@ function onOrBefore(day, t, offset) {
2326
2329
  return new HDate(HDate.dayOnOrBefore(day, t.abs() + offset));
2327
2330
  }
2328
2331
 
2329
- /*! @hebcal/hdate v0.22.7, distributed under GPLv2 https://www.gnu.org/licenses/gpl-2.0.txt */
2332
+ /*! @hebcal/hdate v0.22.8, distributed under GPLv2 https://www.gnu.org/licenses/gpl-2.0.txt */
2330
2333
  /**
2331
2334
  * Calculates yahrzeit, the anniversary of a death, and returns it as an
2332
2335
  * {@link HDate}.
@@ -8057,12 +8060,36 @@ class NOAACalculator {
8057
8060
  * @return {Temporal.ZonedDateTime | null} The Date.
8058
8061
  */
8059
8062
  getDateFromTime(time, isSunrise) {
8060
- if (isNaN(time)) {
8063
+ const epochMillis = this.getEpochMillisFromTime(time, isSunrise);
8064
+ if (isNaN(epochMillis)) {
8061
8065
  return null;
8062
8066
  }
8067
+ return Temporal.Instant.fromEpochMilliseconds(epochMillis).toZonedDateTimeISO(this.geoLocation.getTimeZone());
8068
+ }
8069
+ /**
8070
+ * The instant that {@link getDateFromTime} describes, as milliseconds since
8071
+ * the epoch, without building a `Temporal.ZonedDateTime`.
8072
+ *
8073
+ * Constructing a `ZonedDateTime` costs roughly 750ns because the IANA zone
8074
+ * has to be resolved, and that dominates this calculation. Callers that only
8075
+ * want an instant — a `Date`, or the difference between two times — can skip
8076
+ * it. Deriving the instant arithmetically also avoids a `PlainTime`
8077
+ * allocation and turns the day rollover into a subtraction rather than a
8078
+ * ~610ns `PlainDate.add({days})`.
8079
+ *
8080
+ * @param {number} time
8081
+ * The time in the format 18.75 for 6:45:00 PM, as returned by
8082
+ * {@link getUTCSunrise} / {@link getUTCSunset}, i.e. already
8083
+ * normalized to `[0, 24)`.
8084
+ * @param {boolean} isSunrise true if the time is sunrise, and false if it is sunset
8085
+ * @return {number} milliseconds since the epoch, or `NaN` if `time` is `NaN`
8086
+ */
8087
+ getEpochMillisFromTime(time, isSunrise) {
8088
+ if (isNaN(time)) {
8089
+ return NaN;
8090
+ }
8063
8091
  let calculatedTime = time;
8064
- let cal = this.getAdjustedDate();
8065
- // let cal = new Temporal.PlainDate(adj.year, adj.month, adj.day);
8092
+ const cal = this.getAdjustedDate();
8066
8093
  const hours = Math.trunc(calculatedTime); // retain only the hours
8067
8094
  calculatedTime -= hours;
8068
8095
  const minutes = Math.trunc((calculatedTime *= 60)); // retain only the minutes
@@ -8072,19 +8099,24 @@ class NOAACalculator {
8072
8099
  // Check if a date transition has occurred, or is about to occur - this indicates the date of the event is
8073
8100
  // actually not the target date, but the day prior or after
8074
8101
  const localTimeHours = Math.trunc(this.geoLocation.getLongitude() / 15);
8102
+ let dayOffset = 0;
8075
8103
  if (isSunrise && localTimeHours + hours > 18) {
8076
- cal = cal.add({ days: -1 });
8077
- // cal = cal.minus({days: 1});
8104
+ dayOffset = -1;
8078
8105
  }
8079
8106
  else if (!isSunrise && localTimeHours + hours < 6) {
8080
- cal = cal.add({ days: 1 });
8107
+ dayOffset = 1;
8108
+ }
8109
+ const year = cal.year;
8110
+ let millis = Date.UTC(year, cal.month - 1, cal.day, hours, minutes, seconds, Math.trunc(calculatedTime * 1000));
8111
+ if (year >= 0 && year < 100) {
8112
+ // Date.UTC() maps years 0-99 onto 1900-1999; setUTCFullYear() does not.
8113
+ // Worth the branch (about 3ns): @hebcal/core computes candle-lighting
8114
+ // times for early historical years rather than suppressing them.
8115
+ const d = new Date(millis);
8116
+ d.setUTCFullYear(year);
8117
+ millis = d.getTime();
8081
8118
  }
8082
- return cal
8083
- .toZonedDateTime({
8084
- timeZone: 'UTC',
8085
- plainTime: new Temporal.PlainTime(hours, minutes, seconds, Math.trunc(calculatedTime * 1000)),
8086
- })
8087
- .withTimeZone(this.geoLocation.getTimeZone());
8119
+ return millis + dayOffset * 86400000;
8088
8120
  }
8089
8121
  /**
8090
8122
  * Return the <a href="http://en.wikipedia.org/wiki/Julian_day">Julian day</a> from a Java Calendar
@@ -9724,13 +9756,17 @@ class MoladEvent extends Event {
9724
9756
  }
9725
9757
 
9726
9758
  /**
9759
+ * Converts an instant to a `Date`, discarding milliseconds.
9760
+ *
9761
+ * Zmanim are read out to the minute, and every accessor here reduces to an
9762
+ * instant, so we ask `@hebcal/noaa` for epoch milliseconds rather than a
9763
+ * `Temporal.ZonedDateTime`. Resolving the IANA zone to build a
9764
+ * `ZonedDateTime` costs roughly 750ns and nothing downstream uses it, which
9765
+ * made it the single most expensive step in a sunrise/sunset calculation.
9727
9766
  * @private
9728
9767
  */
9729
- function zdtToDate(zdt) {
9730
- if (zdt === null) {
9731
- return new Date(NaN);
9732
- }
9733
- const res = new Date(zdt.epochMilliseconds);
9768
+ function millisToDate(millis) {
9769
+ const res = new Date(millis);
9734
9770
  res.setMilliseconds(0);
9735
9771
  return res;
9736
9772
  }
@@ -9747,6 +9783,20 @@ const GEOMETRIC_ZENITH = 90;
9747
9783
  * @see Zmanim.sunsetBaalHatanya
9748
9784
  */
9749
9785
  const ZENITH_1_POINT_583 = GEOMETRIC_ZENITH + 1.583;
9786
+ /**
9787
+ * The zenith of civil twilight; the sun is 6° below the horizon.
9788
+ * Matches `NOAACalculator.CIVIL_ZENITH`.
9789
+ */
9790
+ const CIVIL_ZENITH = GEOMETRIC_ZENITH + 6;
9791
+ /**
9792
+ * Length of one temporal (halachic) hour in milliseconds, i.e. one twelfth of
9793
+ * the day. Mirrors `NOAACalculator.getTemporalHour()`, including its floor, so
9794
+ * that results stay identical to the `ZonedDateTime` code path.
9795
+ * @private
9796
+ */
9797
+ function temporalHourMillis(startOfDay, endOfDay) {
9798
+ return Math.floor((endOfDay - startOfDay) / 12);
9799
+ }
9750
9800
  /**
9751
9801
  * Calculate halachic times (zmanim / זְמַנִּים) for a given day and location.
9752
9802
  * Calculations are available for tzeit / tzais (nightfall),
@@ -9789,11 +9839,10 @@ class Zmanim {
9789
9839
  constructor(gloc, date, useElevation) {
9790
9840
  this.hdate = new HDate(date);
9791
9841
  const dt = isDate(date) ? date : this.hdate.greg();
9792
- this.plainDate = Temporal.PlainDate.from({
9793
- year: dt.getFullYear(),
9794
- month: dt.getMonth() + 1,
9795
- day: dt.getDate(),
9796
- });
9842
+ // The constructor is ~1.8x cheaper than PlainDate.from(), which has to
9843
+ // walk a property bag and apply overflow handling. The fields come from a
9844
+ // real Date, so they are always in range and never need constraining.
9845
+ this.plainDate = new Temporal.PlainDate(dt.getFullYear(), dt.getMonth() + 1, dt.getDate());
9797
9846
  this.gloc = gloc;
9798
9847
  this.noaa = new NOAACalculator(gloc, this.plainDate);
9799
9848
  this.useElevation = Boolean(useElevation);
@@ -9827,46 +9876,64 @@ class Zmanim {
9827
9876
  */
9828
9877
  timeAtAngle(angle, rising) {
9829
9878
  const offsetZenith = GEOMETRIC_ZENITH + angle;
9830
- const zdt = rising
9831
- ? this.noaa.getSunriseOffsetByDegrees(offsetZenith)
9832
- : this.noaa.getSunsetOffsetByDegrees(offsetZenith);
9833
- return zdtToDate(zdt);
9879
+ return millisToDate(rising
9880
+ ? this.sunriseMillis(offsetZenith, true)
9881
+ : this.sunsetMillis(offsetZenith, true));
9882
+ }
9883
+ /**
9884
+ * Sunrise for a given zenith as epoch milliseconds, mirroring what
9885
+ * `NOAACalculator.getSunrise()` / `getSeaLevelSunrise()` /
9886
+ * `getSunriseOffsetByDegrees()` compute, minus the `ZonedDateTime`.
9887
+ *
9888
+ * Note that noaa's degree-based accessors pass `adjustForElevation = true`
9889
+ * as well; the adjustment is a no-op unless the zenith is exactly
9890
+ * {@link GEOMETRIC_ZENITH}, which is why degree-based zmanim are unaffected
9891
+ * by elevation.
9892
+ * @private
9893
+ */
9894
+ sunriseMillis(zenith, useElevation) {
9895
+ const utc = useElevation
9896
+ ? this.noaa.getUTCSunrise0(zenith)
9897
+ : this.noaa.getUTCSeaLevelSunrise(zenith);
9898
+ return this.noaa.getEpochMillisFromTime(utc, true);
9899
+ }
9900
+ /**
9901
+ * Sunset counterpart of {@link sunriseMillis}.
9902
+ * @private
9903
+ */
9904
+ sunsetMillis(zenith, useElevation) {
9905
+ const utc = useElevation
9906
+ ? this.noaa.getUTCSunset0(zenith)
9907
+ : this.noaa.getUTCSeaLevelSunset(zenith);
9908
+ return this.noaa.getEpochMillisFromTime(utc, false);
9834
9909
  }
9835
9910
  /**
9836
9911
  * Upper edge of the Sun appears over the eastern horizon in the morning (0.833° above horizon)
9837
9912
  * If elevation is enabled, this function will include elevation in the calculation.
9838
9913
  */
9839
9914
  sunrise() {
9840
- const zdt = this.useElevation
9841
- ? this.noaa.getSunrise()
9842
- : this.noaa.getSeaLevelSunrise();
9843
- return zdtToDate(zdt);
9915
+ return millisToDate(this.sunriseMillis(GEOMETRIC_ZENITH, this.useElevation));
9844
9916
  }
9845
9917
  /**
9846
9918
  * Upper edge of the Sun appears over the eastern horizon in the morning (0.833° above horizon).
9847
9919
  * This function does not support elevation adjustment.
9848
9920
  */
9849
9921
  seaLevelSunrise() {
9850
- const zdt = this.noaa.getSeaLevelSunrise();
9851
- return zdtToDate(zdt);
9922
+ return millisToDate(this.sunriseMillis(GEOMETRIC_ZENITH, false));
9852
9923
  }
9853
9924
  /**
9854
9925
  * When the upper edge of the Sun disappears below the horizon (0.833° below horizon).
9855
9926
  * If elevation is enabled, this function will include elevation in the calculation.
9856
9927
  */
9857
9928
  sunset() {
9858
- const zdt = this.useElevation
9859
- ? this.noaa.getSunset()
9860
- : this.noaa.getSeaLevelSunset();
9861
- return zdtToDate(zdt);
9929
+ return millisToDate(this.sunsetMillis(GEOMETRIC_ZENITH, this.useElevation));
9862
9930
  }
9863
9931
  /**
9864
9932
  * When the upper edge of the Sun disappears below the horizon (0.833° below horizon).
9865
9933
  * This function does not support elevation adjustment.
9866
9934
  */
9867
9935
  seaLevelSunset() {
9868
- const zdt = this.noaa.getSeaLevelSunset();
9869
- return zdtToDate(zdt);
9936
+ return millisToDate(this.sunsetMillis(GEOMETRIC_ZENITH, false));
9870
9937
  }
9871
9938
  /**
9872
9939
  * Civil dawn; Sun is 6° below the horizon in the morning.
@@ -9874,8 +9941,7 @@ class Zmanim {
9874
9941
  * the result is not impacted by elevation.
9875
9942
  */
9876
9943
  dawn() {
9877
- const zdt = this.noaa.getBeginCivilTwilight();
9878
- return zdtToDate(zdt);
9944
+ return millisToDate(this.sunriseMillis(CIVIL_ZENITH, true));
9879
9945
  }
9880
9946
  /**
9881
9947
  * Civil dusk; Sun is 6° below the horizon in the evening.
@@ -9883,8 +9949,7 @@ class Zmanim {
9883
9949
  * the result is not impacted by elevation.
9884
9950
  */
9885
9951
  dusk() {
9886
- const zdt = this.noaa.getEndCivilTwilight();
9887
- return zdtToDate(zdt);
9952
+ return millisToDate(this.sunsetMillis(CIVIL_ZENITH, true));
9888
9953
  }
9889
9954
  /**
9890
9955
  * Returns sunset for the previous day.
@@ -9912,10 +9977,10 @@ class Zmanim {
9912
9977
  * `useElevation` setting.
9913
9978
  */
9914
9979
  chatzot() {
9915
- const startOfDay = this.noaa.getSeaLevelSunrise();
9916
- const endOfDay = this.noaa.getSeaLevelSunset();
9917
- const zdt = this.noaa.getSunTransit(startOfDay, endOfDay);
9918
- return zdtToDate(zdt);
9980
+ const startOfDay = this.sunriseMillis(GEOMETRIC_ZENITH, false);
9981
+ const endOfDay = this.sunsetMillis(GEOMETRIC_ZENITH, false);
9982
+ // NOAACalculator.getSunTransit(): sunrise plus 6 temporal hours
9983
+ return millisToDate(startOfDay + temporalHourMillis(startOfDay, endOfDay) * 6);
9919
9984
  }
9920
9985
  /**
9921
9986
  * Midnight – Chatzot; Sunset plus 6 halachic hours.
@@ -9969,25 +10034,18 @@ class Zmanim {
9969
10034
  misheyakirMachmir() {
9970
10035
  return this.timeAtAngle(10.2, true);
9971
10036
  }
9972
- getShaahZmanisBasedZmanZdt(startOfDay, endOfDay, hours) {
9973
- const temporalHour = this.noaa.getTemporalHour(startOfDay, endOfDay);
9974
- const offset = Math.trunc(temporalHour * hours);
9975
- const zdt = NOAACalculator.getTimeOffset(startOfDay, offset);
9976
- return zdt;
10037
+ getShaahZmanisBasedZmanMillis(startOfDay, endOfDay, hours) {
10038
+ const offset = Math.trunc(temporalHourMillis(startOfDay, endOfDay) * hours);
10039
+ return startOfDay + offset;
9977
10040
  }
9978
10041
  /**
9979
10042
  * Utility method for using elevation-aware sunrise/sunset
9980
10043
  * @param hours number of _shaos zmaniyos_ (solar hours) after sunrise
9981
10044
  */
9982
10045
  getShaahZmanisBasedZman(hours) {
9983
- const startOfDay = this.useElevation
9984
- ? this.noaa.getSunrise()
9985
- : this.noaa.getSeaLevelSunrise();
9986
- const endOfDay = this.useElevation
9987
- ? this.noaa.getSunset()
9988
- : this.noaa.getSeaLevelSunset();
9989
- const zdt = this.getShaahZmanisBasedZmanZdt(startOfDay, endOfDay, hours);
9990
- return zdtToDate(zdt);
10046
+ const startOfDay = this.sunriseMillis(GEOMETRIC_ZENITH, this.useElevation);
10047
+ const endOfDay = this.sunsetMillis(GEOMETRIC_ZENITH, this.useElevation);
10048
+ return millisToDate(this.getShaahZmanisBasedZmanMillis(startOfDay, endOfDay, hours));
9991
10049
  }
9992
10050
  /**
9993
10051
  * Latest Shema (Gra); Sunrise plus 3 halachic hours, according to the Gra.
@@ -10485,7 +10543,7 @@ class Zmanim {
10485
10543
  * where it does not set, `null` will be returned.
10486
10544
  */
10487
10545
  getSunriseBaalHatanya() {
10488
- return this.noaa.getSunriseOffsetByDegrees(ZENITH_1_POINT_583);
10546
+ return this.sunriseMillis(ZENITH_1_POINT_583, true);
10489
10547
  }
10490
10548
  /**
10491
10549
  * A method that returns the [Baal Hatanya](https://en.wikipedia.org/wiki/Shneur_Zalman_of_Liadi)'s
@@ -10508,7 +10566,7 @@ class Zmanim {
10508
10566
  * rise, and one where it does not set, `null` will be returned.
10509
10567
  */
10510
10568
  getSunsetBaalHatanya() {
10511
- return this.noaa.getSunsetOffsetByDegrees(ZENITH_1_POINT_583);
10569
+ return this.sunsetMillis(ZENITH_1_POINT_583, true);
10512
10570
  }
10513
10571
  /**
10514
10572
  * Returns the [Baal Hatanya](https://en.wikipedia.org/wiki/Shneur_Zalman_of_Liadi)'s _alos_
@@ -10530,8 +10588,7 @@ class Zmanim {
10530
10588
  return this.timeAtAngle(16.9, true);
10531
10589
  }
10532
10590
  getShaahZmanisBaalHatanya(hours) {
10533
- const zdt = this.getShaahZmanisBasedZmanZdt(this.getSunriseBaalHatanya(), this.getSunsetBaalHatanya(), hours);
10534
- return zdtToDate(zdt);
10591
+ return millisToDate(this.getShaahZmanisBasedZmanMillis(this.getSunriseBaalHatanya(), this.getSunsetBaalHatanya(), hours));
10535
10592
  }
10536
10593
  /**
10537
10594
  * This method returns the latest _zman krias shema_ (time to recite Shema in the morning). This time is 3
@@ -10624,9 +10681,15 @@ class Zmanim {
10624
10681
  return 'XX:XX'; // Invalid Date
10625
10682
  }
10626
10683
  const time = timeFormat.format(dt);
10627
- const hm = time.split(':');
10628
- if (hm[0] === '24') {
10629
- return '00:' + hm[1];
10684
+ // Rewrite the h24 midnight ("24:15") that some locales produce. Checking
10685
+ // the two leading characters avoids the throwaway array that split(':')
10686
+ // allocated on every event; this runs once per timed event, and the
10687
+ // Intl.format() call above is already the expensive part.
10688
+ if (time.charCodeAt(0) === 0x32 && // '2'
10689
+ time.charCodeAt(1) === 0x34 && // '4'
10690
+ time.charCodeAt(2) === 0x3a // ':'
10691
+ ) {
10692
+ return '00' + time.substring(2);
10630
10693
  }
10631
10694
  return time;
10632
10695
  }