@hebcal/core 6.6.0 → 6.8.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.
Files changed (152) hide show
  1. package/README.md +4 -4
  2. package/dist/bundle.js +224 -95
  3. package/dist/bundle.js.map +1 -1
  4. package/dist/bundle.min.js +18 -18
  5. package/dist/bundle.min.js.map +1 -1
  6. package/dist/esm/CalOptions.d.ts +15 -3
  7. package/dist/esm/DailyLearning.js +1 -1
  8. package/dist/esm/HebrewDateEvent.js +1 -1
  9. package/dist/esm/HolidayEvent.d.ts +2 -2
  10. package/dist/esm/HolidayEvent.js +3 -5
  11. package/dist/esm/HolidayEvent.js.map +1 -1
  12. package/dist/esm/MevarchimChodeshEvent.js +1 -1
  13. package/dist/esm/ParshaEvent.js +16 -6
  14. package/dist/esm/ParshaEvent.js.map +1 -1
  15. package/dist/esm/TimedEvent.js +1 -1
  16. package/dist/esm/TimedEvent.js.map +1 -1
  17. package/dist/esm/YomKippurKatanEvent.js +1 -1
  18. package/dist/esm/ashkenazi.po.js +2 -2
  19. package/dist/esm/ashkenazi.po.js.map +1 -1
  20. package/dist/esm/calendar.js +17 -23
  21. package/dist/esm/calendar.js.map +1 -1
  22. package/dist/esm/candles.d.ts +8 -3
  23. package/dist/esm/candles.js +65 -11
  24. package/dist/esm/candles.js.map +1 -1
  25. package/dist/esm/cities.json.js +1 -1
  26. package/dist/esm/event.js +2 -2
  27. package/dist/esm/event.js.map +1 -1
  28. package/dist/esm/getStartAndEnd.js +8 -6
  29. package/dist/esm/getStartAndEnd.js.map +1 -1
  30. package/dist/esm/hallel.js +1 -1
  31. package/dist/esm/he-x-NoNikud.po.js +1 -1
  32. package/dist/esm/he.po.js +1 -1
  33. package/dist/esm/hebcal.js +1 -1
  34. package/dist/esm/holidays.js +6 -5
  35. package/dist/esm/holidays.js.map +1 -1
  36. package/dist/esm/index.js +1 -1
  37. package/dist/esm/isAssurBemlacha.js +1 -1
  38. package/dist/esm/isAveilut.js +1 -1
  39. package/dist/esm/isFastDay.js +1 -1
  40. package/dist/esm/locale.js +1 -1
  41. package/dist/esm/location.js +12 -13
  42. package/dist/esm/location.js.map +1 -1
  43. package/dist/esm/modern.js +1 -1
  44. package/dist/esm/molad.js +5 -5
  45. package/dist/esm/molad.js.map +1 -1
  46. package/dist/esm/moladBase.js +1 -1
  47. package/dist/esm/moladDate.js +1 -1
  48. package/dist/esm/moladDate.js.map +1 -1
  49. package/dist/esm/omer.js +1 -1
  50. package/dist/esm/parshaName.js +1 -1
  51. package/dist/esm/parshaYear.js +1 -1
  52. package/dist/esm/pkgVersion.d.ts +1 -1
  53. package/dist/esm/pkgVersion.js +2 -2
  54. package/dist/esm/pkgVersion.js.map +1 -1
  55. package/dist/esm/reformatTimeStr.js +1 -1
  56. package/dist/esm/reformatTimeStr.js.map +1 -1
  57. package/dist/esm/sedra.d.ts +14 -0
  58. package/dist/esm/sedra.js +70 -13
  59. package/dist/esm/sedra.js.map +1 -1
  60. package/dist/esm/sefira.json.js +1 -1
  61. package/dist/esm/staticHolidays.js +1 -1
  62. package/dist/esm/string.js +1 -1
  63. package/dist/esm/tachanun.js +1 -1
  64. package/dist/esm/tachanun.js.map +1 -1
  65. package/dist/esm/zmanim.js +2 -3
  66. package/dist/esm/zmanim.js.map +1 -1
  67. package/package.json +14 -17
  68. package/po/ashkenazi.po +1 -12
  69. package/dist/eslint.config.d.mts +0 -83
  70. package/dist/eslint.config.mjs +0 -29
  71. package/dist/po2json.d.ts +0 -1
  72. package/dist/po2json.js +0 -40
  73. package/dist/src/CalOptions.d.ts +0 -171
  74. package/dist/src/CalOptions.js +0 -1
  75. package/dist/src/DailyLearning.d.ts +0 -69
  76. package/dist/src/DailyLearning.js +0 -92
  77. package/dist/src/HebrewDateEvent.d.ts +0 -37
  78. package/dist/src/HebrewDateEvent.js +0 -72
  79. package/dist/src/HolidayEvent.d.ts +0 -117
  80. package/dist/src/HolidayEvent.js +0 -236
  81. package/dist/src/MevarchimChodeshEvent.d.ts +0 -26
  82. package/dist/src/MevarchimChodeshEvent.js +0 -52
  83. package/dist/src/ParshaEvent.d.ts +0 -24
  84. package/dist/src/ParshaEvent.js +0 -50
  85. package/dist/src/TimedEvent.d.ts +0 -76
  86. package/dist/src/TimedEvent.js +0 -134
  87. package/dist/src/YomKippurKatanEvent.d.ts +0 -23
  88. package/dist/src/YomKippurKatanEvent.js +0 -40
  89. package/dist/src/ashkenazi.po.d.ts +0 -84
  90. package/dist/src/ashkenazi.po.js +0 -1
  91. package/dist/src/calendar.d.ts +0 -112
  92. package/dist/src/calendar.js +0 -721
  93. package/dist/src/candles.d.ts +0 -57
  94. package/dist/src/candles.js +0 -185
  95. package/dist/src/cities.json +0 -67
  96. package/dist/src/event.d.ts +0 -233
  97. package/dist/src/event.js +0 -295
  98. package/dist/src/getStartAndEnd.d.ts +0 -6
  99. package/dist/src/getStartAndEnd.js +0 -105
  100. package/dist/src/hallel.d.ts +0 -6
  101. package/dist/src/hallel.js +0 -39
  102. package/dist/src/he-x-NoNikud.po.d.ts +0 -28
  103. package/dist/src/he-x-NoNikud.po.js +0 -1
  104. package/dist/src/he.po.d.ts +0 -217
  105. package/dist/src/he.po.js +0 -1
  106. package/dist/src/hebcal.d.ts +0 -338
  107. package/dist/src/hebcal.js +0 -413
  108. package/dist/src/holidays.d.ts +0 -41
  109. package/dist/src/holidays.js +0 -324
  110. package/dist/src/index.d.ts +0 -30
  111. package/dist/src/index.js +0 -29
  112. package/dist/src/isAssurBemlacha.d.ts +0 -29
  113. package/dist/src/isAssurBemlacha.js +0 -82
  114. package/dist/src/isAveilut.d.ts +0 -22
  115. package/dist/src/isAveilut.js +0 -48
  116. package/dist/src/isFastDay.d.ts +0 -21
  117. package/dist/src/isFastDay.js +0 -31
  118. package/dist/src/locale.d.ts +0 -1
  119. package/dist/src/locale.js +0 -11
  120. package/dist/src/location.d.ts +0 -167
  121. package/dist/src/location.js +0 -342
  122. package/dist/src/modern.d.ts +0 -18
  123. package/dist/src/modern.js +0 -59
  124. package/dist/src/molad.d.ts +0 -164
  125. package/dist/src/molad.js +0 -298
  126. package/dist/src/moladBase.d.ts +0 -15
  127. package/dist/src/moladBase.js +0 -78
  128. package/dist/src/moladDate.d.ts +0 -12
  129. package/dist/src/moladDate.js +0 -58
  130. package/dist/src/omer.d.ts +0 -128
  131. package/dist/src/omer.js +0 -385
  132. package/dist/src/parshaName.d.ts +0 -2
  133. package/dist/src/parshaName.js +0 -13
  134. package/dist/src/parshaYear.d.ts +0 -20
  135. package/dist/src/parshaYear.js +0 -35
  136. package/dist/src/pkgVersion.d.ts +0 -2
  137. package/dist/src/pkgVersion.js +0 -2
  138. package/dist/src/reformatTimeStr.d.ts +0 -8
  139. package/dist/src/reformatTimeStr.js +0 -47
  140. package/dist/src/sedra.d.ts +0 -175
  141. package/dist/src/sedra.js +0 -563
  142. package/dist/src/sefira.json +0 -63
  143. package/dist/src/staticHolidays.d.ts +0 -192
  144. package/dist/src/staticHolidays.js +0 -637
  145. package/dist/src/string.d.ts +0 -2
  146. package/dist/src/string.js +0 -6
  147. package/dist/src/tachanun.d.ts +0 -29
  148. package/dist/src/tachanun.js +0 -120
  149. package/dist/src/zmanim.d.ts +0 -620
  150. package/dist/src/zmanim.js +0 -1003
  151. package/dist/version.d.ts +0 -1
  152. package/dist/version.js +0 -8
@@ -1,1003 +0,0 @@
1
- import 'temporal-polyfill/global';
2
- import { NOAACalculator } from '@hebcal/noaa';
3
- import { HDate, getPseudoISO, getTimezoneOffset, isDate, pad2, } from '@hebcal/hdate';
4
- import { Molad } from './molad';
5
- /**
6
- * @private
7
- */
8
- function zdtToDate(zdt) {
9
- if (zdt === null) {
10
- return new Date(NaN);
11
- }
12
- const res = new Date(zdt.epochMilliseconds);
13
- res.setMilliseconds(0);
14
- return res;
15
- }
16
- /**
17
- * The zenith of astronomical sunrise and sunset. The sun is 90° from the vertical 0°
18
- */
19
- const GEOMETRIC_ZENITH = 90;
20
- /**
21
- * The zenith of 1.583° below {@link GEOMETRIC_ZENITH geometric zenith} (90°). This calculation is used for
22
- * calculating _netz amiti_ (sunrise) and _shkiah amiti_ (sunset) based on the opinion of the
23
- * <a href="https://en.wikipedia.org/wiki/Shneur_Zalman_of_Liadi">Baal Hatanya</a>.
24
- *
25
- * @see Zmanim.sunriseBaalHatanya()
26
- * @see Zmanim.sunsetBaalHatanya()
27
- */
28
- const ZENITH_1_POINT_583 = GEOMETRIC_ZENITH + 1.583;
29
- /**
30
- * Calculate halachic times (zmanim / זְמַנִּים) for a given day and location.
31
- * Calculations are available for tzeit / tzais (nightfall),
32
- * shkiah (sunset) and more.
33
- *
34
- * Zmanim are estimated using an algorithm published by the US National Oceanic
35
- * and Atmospheric Administration. The NOAA solar calculator is based on equations
36
- * from _Astronomical Algorithms_ by Jean Meeus.
37
- *
38
- * The sunrise and sunset results are theoretically accurate to within a minute for
39
- * locations between +/- 72° latitude, and within 10 minutes outside of those latitudes.
40
- * However, due to variations in atmospheric composition, temperature, pressure and
41
- * conditions, observed values may vary from calculations.
42
- * https://gml.noaa.gov/grad/solcalc/calcdetails.html
43
- *
44
- * @example
45
- * const {GeoLocation, Zmanim} = require('@hebcal/core');
46
- * const latitude = 41.822232;
47
- * const longitude = -71.448292;
48
- * const tzid = 'America/New_York';
49
- * const friday = new Date(2023, 8, 8);
50
- * const gloc = new GeoLocation(null, latitude, longitude, 0, tzid);
51
- * const zmanim = new Zmanim(gloc, friday, false);
52
- * const candleLighting = zmanim.sunsetOffset(-18, true);
53
- * const timeStr = Zmanim.formatISOWithTimeZone(tzid, candleLighting);
54
- */
55
- export class Zmanim {
56
- hdate;
57
- plainDate;
58
- gloc;
59
- noaa;
60
- useElevation;
61
- /**
62
- * Initialize a Zmanim instance.
63
- * @param gloc GeoLocation including latitude, longitude, and timezone
64
- * @param date Regular or Hebrew Date. If `date` is a regular `Date`,
65
- * hours, minutes, seconds and milliseconds are ignored.
66
- * @param useElevation use elevation for calculations (default `false`).
67
- * If `true`, use elevation to affect the calculation of all sunrise/sunset based
68
- * zmanim. Note: there are some zmanim such as degree-based zmanim that are driven
69
- * by the amount of light in the sky and are not impacted by elevation.
70
- * These zmanim intentionally do not support elevation adjustment.
71
- */
72
- constructor(gloc, date, useElevation) {
73
- this.hdate = new HDate(date);
74
- const dt = isDate(date) ? date : this.hdate.greg();
75
- this.plainDate = Temporal.PlainDate.from({
76
- year: dt.getFullYear(),
77
- month: dt.getMonth() + 1,
78
- day: dt.getDate(),
79
- });
80
- this.gloc = gloc;
81
- this.noaa = new NOAACalculator(gloc, this.plainDate);
82
- this.useElevation = Boolean(useElevation);
83
- }
84
- /**
85
- * Returns `true` if elevation adjustment is enabled
86
- * for zmanim support elevation adjustment
87
- */
88
- getUseElevation() {
89
- return this.useElevation;
90
- }
91
- /**
92
- * Enables or disables elevation adjustment for zmanim support elevation adjustment
93
- * @param useElevation
94
- */
95
- setUseElevation(useElevation) {
96
- this.useElevation = useElevation;
97
- }
98
- /**
99
- * Convenience function to get the time when sun is above or below the horizon
100
- * for a certain angle (in degrees).
101
- * This function does not support elevation adjustment.
102
- * @param angle
103
- * @param rising
104
- */
105
- timeAtAngle(angle, rising) {
106
- const offsetZenith = GEOMETRIC_ZENITH + angle;
107
- const zdt = rising
108
- ? this.noaa.getSunriseOffsetByDegrees(offsetZenith)
109
- : this.noaa.getSunsetOffsetByDegrees(offsetZenith);
110
- return zdtToDate(zdt);
111
- }
112
- /**
113
- * Upper edge of the Sun appears over the eastern horizon in the morning (0.833° above horizon)
114
- * If elevation is enabled, this function will include elevation in the calculation.
115
- */
116
- sunrise() {
117
- const zdt = this.useElevation
118
- ? this.noaa.getSunrise()
119
- : this.noaa.getSeaLevelSunrise();
120
- return zdtToDate(zdt);
121
- }
122
- /**
123
- * Upper edge of the Sun appears over the eastern horizon in the morning (0.833° above horizon).
124
- * This function does not support elevation adjustment.
125
- */
126
- seaLevelSunrise() {
127
- const zdt = this.noaa.getSeaLevelSunrise();
128
- return zdtToDate(zdt);
129
- }
130
- /**
131
- * When the upper edge of the Sun disappears below the horizon (0.833° below horizon).
132
- * If elevation is enabled, this function will include elevation in the calculation.
133
- */
134
- sunset() {
135
- const zdt = this.useElevation
136
- ? this.noaa.getSunset()
137
- : this.noaa.getSeaLevelSunset();
138
- return zdtToDate(zdt);
139
- }
140
- /**
141
- * When the upper edge of the Sun disappears below the horizon (0.833° below horizon).
142
- * This function does not support elevation adjustment.
143
- */
144
- seaLevelSunset() {
145
- const zdt = this.noaa.getSeaLevelSunset();
146
- return zdtToDate(zdt);
147
- }
148
- /**
149
- * Civil dawn; Sun is 6° below the horizon in the morning.
150
- * Because degree-based functions estimate the amount of light in the sky,
151
- * the result is not impacted by elevation.
152
- */
153
- dawn() {
154
- const zdt = this.noaa.getBeginCivilTwilight();
155
- return zdtToDate(zdt);
156
- }
157
- /**
158
- * Civil dusk; Sun is 6° below the horizon in the evening.
159
- * Because degree-based functions estimate the amount of light in the sky,
160
- * the result is not impacted by elevation.
161
- */
162
- dusk() {
163
- const zdt = this.noaa.getEndCivilTwilight();
164
- return zdtToDate(zdt);
165
- }
166
- /**
167
- * Returns sunset for the previous day.
168
- * If elevation is enabled, this function will include elevation in the calculation.
169
- */
170
- gregEve() {
171
- const prev0 = this.plainDate.subtract({ days: 1 });
172
- const prev = new Date(prev0.year, prev0.month - 1, prev0.day);
173
- const zman = new Zmanim(this.gloc, prev, this.useElevation);
174
- return zman.sunset();
175
- }
176
- /**
177
- * @private
178
- */
179
- nightHour() {
180
- return (this.sunrise().getTime() - this.gregEve().getTime()) / 12; // ms in hour
181
- }
182
- /**
183
- * Midday – Chatzot; Sunrise plus 6 halachic hours
184
- */
185
- chatzot() {
186
- const startOfDay = this.noaa.getSeaLevelSunrise();
187
- const endOfDay = this.noaa.getSeaLevelSunset();
188
- const zdt = this.noaa.getSunTransit(startOfDay, endOfDay);
189
- return zdtToDate(zdt);
190
- }
191
- /**
192
- * Midnight – Chatzot; Sunset plus 6 halachic hours.
193
- * If elevation is enabled, this function will include elevation in the calculation.
194
- */
195
- chatzotNight() {
196
- return new Date(this.sunrise().getTime() - this.nightHour() * 6);
197
- }
198
- /**
199
- * Dawn – Alot haShachar; Sun is 16.1° below the horizon in the morning.
200
- * Because degree-based functions estimate the amount of light in the sky,
201
- * the result is not impacted by elevation.
202
- */
203
- alotHaShachar() {
204
- return this.timeAtAngle(16.1, true);
205
- }
206
- /**
207
- * Dawn – Alot haShachar; calculated as 72 minutes before sunrise or
208
- * sea level sunrise.
209
- */
210
- alotHaShachar72() {
211
- return this.sunriseOffset(-72, false, false);
212
- }
213
- alotHaShachar72zdt() {
214
- const zdt = this.useElevation
215
- ? this.noaa.getSunrise()
216
- : this.noaa.getSeaLevelSunrise();
217
- if (!zdt) {
218
- return null;
219
- }
220
- return zdt.subtract({ minutes: 72 });
221
- }
222
- /**
223
- * Earliest talis & tefillin – Misheyakir; Sun is 11.5° below the horizon in the morning.
224
- * Because degree-based functions estimate the amount of light in the sky,
225
- * the result is not impacted by elevation.
226
- */
227
- misheyakir() {
228
- return this.timeAtAngle(11.5, true);
229
- }
230
- /**
231
- * Earliest talis & tefillin – Misheyakir Machmir; Sun is 10.2° below the horizon in the morning.
232
- * Because degree-based functions estimate the amount of light in the sky,
233
- * the result is not impacted by elevation.
234
- */
235
- misheyakirMachmir() {
236
- return this.timeAtAngle(10.2, true);
237
- }
238
- getShaahZmanisBasedZmanZdt(startOfDay, endOfDay, hours) {
239
- const temporalHour = this.noaa.getTemporalHour(startOfDay, endOfDay);
240
- const offset = Math.trunc(temporalHour * hours);
241
- const zdt = NOAACalculator.getTimeOffset(startOfDay, offset);
242
- return zdt;
243
- }
244
- /**
245
- * Utility method for using elevation-aware sunrise/sunset
246
- * @private
247
- * @param hours
248
- */
249
- getShaahZmanisBasedZman(hours) {
250
- const startOfDay = this.useElevation
251
- ? this.noaa.getSunrise()
252
- : this.noaa.getSeaLevelSunrise();
253
- const endOfDay = this.useElevation
254
- ? this.noaa.getSunset()
255
- : this.noaa.getSeaLevelSunset();
256
- const zdt = this.getShaahZmanisBasedZmanZdt(startOfDay, endOfDay, hours);
257
- return zdtToDate(zdt);
258
- }
259
- /**
260
- * Latest Shema (Gra); Sunrise plus 3 halachic hours, according to the Gra.
261
- * If elevation is enabled, this function will include elevation in the calculation.
262
- */
263
- sofZmanShma() {
264
- // Gra
265
- return this.getShaahZmanisBasedZman(3);
266
- }
267
- /**
268
- * Latest Shacharit (Gra); Sunrise plus 4 halachic hours, according to the Gra.
269
- *
270
- * This method returns the latest *zman tfila* (time to recite shema in the morning)
271
- * that is 4 *shaos zmaniyos* (solar hours) after sunrise or sea level sunrise
272
- * (depending on the `useElevation` setting), according
273
- * to the [GRA](https://en.wikipedia.org/wiki/Vilna_Gaon).
274
- *
275
- * If elevation is enabled, this function will include elevation in the calculation.
276
- */
277
- sofZmanTfilla() {
278
- // Gra
279
- return this.getShaahZmanisBasedZman(4);
280
- }
281
- /**
282
- * This method returns the latest time for burning _chametz_ on _Erev Pesach_ according to the opinion
283
- * of the <a href="https://en.wikipedia.org/wiki/Vilna_Gaon">GRA</a>. This time is 5 hours into the day based on the
284
- * opinion of the <a href="https://en.wikipedia.org/wiki/Vilna_Gaon">GRA</a> that the day is calculated from
285
- * sunrise to sunset. This returns the time 5 * {@link #getShaahZmanisGra()} after {@link #getSeaLevelSunrise() sea
286
- * level sunrise}.
287
- * @return the <code>Date</code> of the latest time for burning _chametz_ on _Erev Pesach_. If it is not
288
- * _erev Pesach_ or the calculation can't be computed such as in the Arctic Circle where there is at least
289
- * one day a year where the sun does not rise, and one where it does not set, a <code>null</code> will be
290
- * returned.
291
- */
292
- sofZmanBiurChametzGRA() {
293
- return this.getShaahZmanisBasedZman(5);
294
- }
295
- /**
296
- * Returns an array with alot (Date) and ms in hour (number)
297
- * @private
298
- */
299
- getTemporalHour72(forceSeaLevel) {
300
- const alot72 = this.sunriseOffset(-72, false, forceSeaLevel);
301
- const tzeit72 = this.sunsetOffset(72, false, forceSeaLevel);
302
- const temporalHour = (tzeit72.getTime() - alot72.getTime()) / 12;
303
- return [alot72, temporalHour];
304
- }
305
- /**
306
- * Returns an array with alot (Date) and ms in hour (number)
307
- * @private
308
- */
309
- getTemporalHourByDeg(angle) {
310
- const alot = this.timeAtAngle(angle, true);
311
- const tzeit = this.timeAtAngle(angle, false);
312
- const temporalHour = (tzeit.getTime() - alot.getTime()) / 12;
313
- return [alot, temporalHour];
314
- }
315
- /**
316
- * Latest Shema (MGA); Sunrise plus 3 halachic hours, according to Magen Avraham.
317
- * Based on the opinion of the MGA that the day is calculated from
318
- * dawn being fixed 72 minutes before sea-level sunrise, and nightfall is fixed
319
- * 72 minutes after sea-level sunset.
320
- */
321
- sofZmanShmaMGA() {
322
- // Magen Avraham
323
- const [alot72, temporalHour] = this.getTemporalHour72(true);
324
- const offset = Math.floor(3 * temporalHour);
325
- return new Date(alot72.getTime() + offset);
326
- }
327
- /**
328
- * Latest Shema (MGA); Sunrise plus 3 halachic hours, according to Magen Avraham.
329
- * Based on the opinion of the MGA that the day is calculated from
330
- * dawn to nightfall with both being 16.1° below the horizon.
331
- */
332
- sofZmanShmaMGA16Point1() {
333
- const [alot, temporalHour] = this.getTemporalHourByDeg(16.1);
334
- const offset = Math.floor(3 * temporalHour);
335
- return new Date(alot.getTime() + offset);
336
- }
337
- /**
338
- * Latest Shema (MGA); Sunrise plus 3 halachic hours, according to Magen Avraham.
339
- * Based on the opinion of the MGA that the day is calculated from
340
- * dawn to nightfall with both being 19.8° below the horizon.
341
- *
342
- * This calculation is based on the position of the sun 90 minutes after sunset in Jerusalem
343
- * around the equinox / equilux which calculates to 19.8° below geometric zenith.
344
- * https://kosherjava.com/2022/01/12/equinox-vs-equilux-zmanim-calculations/
345
- */
346
- sofZmanShmaMGA19Point8() {
347
- const [alot, temporalHour] = this.getTemporalHourByDeg(19.8);
348
- const offset = Math.floor(3 * temporalHour);
349
- return new Date(alot.getTime() + offset);
350
- }
351
- /**
352
- * Latest Shacharit (MGA); Sunrise plus 4 halachic hours, according to Magen Avraham
353
- */
354
- sofZmanTfillaMGA() {
355
- // Magen Avraham
356
- const [alot72, temporalHour] = this.getTemporalHour72(true);
357
- const offset = Math.floor(4 * temporalHour);
358
- return new Date(alot72.getTime() + offset);
359
- }
360
- /**
361
- * Latest Shacharit (MGA); Sunrise plus 4 halachic hours, according to Magen Avraham.
362
- * Based on the opinion of the MGA that the day is calculated from
363
- * dawn to nightfall with both being 16.1° below the horizon.
364
- */
365
- sofZmanTfillaMGA16Point1() {
366
- const [alot, temporalHour] = this.getTemporalHourByDeg(16.1);
367
- const offset = Math.floor(4 * temporalHour);
368
- return new Date(alot.getTime() + offset);
369
- }
370
- /**
371
- * Latest Shacharit (MGA); Sunrise plus 4 halachic hours, according to Magen Avraham.
372
- * Based on the opinion of the MGA that the day is calculated from
373
- * dawn to nightfall with both being 19.8° below the horizon.
374
- *
375
- * This calculation is based on the position of the sun 90 minutes after sunset in Jerusalem
376
- * around the equinox / equilux which calculates to 19.8° below geometric zenith.
377
- * https://kosherjava.com/2022/01/12/equinox-vs-equilux-zmanim-calculations/
378
- */
379
- sofZmanTfillaMGA19Point8() {
380
- const [alot, temporalHour] = this.getTemporalHourByDeg(19.8);
381
- const offset = Math.floor(4 * temporalHour);
382
- return new Date(alot.getTime() + offset);
383
- }
384
- /**
385
- * Earliest Mincha – Mincha Gedola (GRA); Sunrise plus 6.5 halachic hours.
386
- * If elevation is enabled, this function will include elevation in the calculation.
387
- *
388
- * This method returns the latest mincha gedola, the earliest time one can pray mincha
389
- * that is 6.5 shaos zmaniyos (solar hours) after sunrise or sea level sunrise
390
- * (depending on the `useElevation` setting), according
391
- * to the [GRA](https://en.wikipedia.org/wiki/Vilna_Gaon).
392
- *
393
- * The Ramba"m is of the opinion that it is better to delay *mincha* until
394
- * *mincha ketana* while the Ra"sh, Tur, GRA and others are of the
395
- * opinion that *mincha* can be prayed *lechatchila* starting at *mincha gedola*.
396
- */
397
- minchaGedola() {
398
- return this.getShaahZmanisBasedZman(6.5);
399
- }
400
- /**
401
- * Earliest Mincha – Mincha Gedola (MGA); Sunrise plus 6.5 halachic hours.
402
- * If elevation is enabled, this function will include elevation in the calculation.
403
- *
404
- * This method returns the time of *mincha gedola* according to the Magen Avraham
405
- * with the day starting 72 minutes before sunrise and ending 72 minutes after sunset.
406
- * This is the earliest time to pray *mincha*.
407
- */
408
- minchaGedolaMGA() {
409
- const [alot72, temporalHour] = this.getTemporalHour72(false);
410
- const offset = Math.floor(6.5 * temporalHour);
411
- return new Date(alot72.getTime() + offset);
412
- }
413
- /**
414
- * Preferable earliest time to recite Minchah – Mincha Ketana; Sunrise plus 9.5 halachic hours.
415
- * If elevation is enabled, this function will include elevation in the calculation.
416
- *
417
- * This method returns *mincha ketana*, the preferred earliest time to pray *mincha* in the
418
- * opinion of the [Rambam](https://en.wikipedia.org/wiki/Maimonides) and others,
419
- * that is 9.5 *shaos zmaniyos* (solar hours) after sunrise or sea level sunrise
420
- * (depending on the `useElevation` setting), according
421
- * to the [GRA](https://en.wikipedia.org/wiki/Vilna_Gaon).
422
- */
423
- minchaKetana() {
424
- return this.getShaahZmanisBasedZman(9.5);
425
- }
426
- /**
427
- * This method returns the time of *mincha ketana* according to the Magen Avraham
428
- * with the day starting 72 minutes before sunrise and ending 72 minutes after sunset.
429
- * This is the preferred earliest time to pray *mincha* according to the opinion of
430
- * the [Rambam](https://en.wikipedia.org/wiki/Maimonides) and others.
431
- *
432
- * If elevation is enabled, this function will include elevation in the calculation.
433
- */
434
- minchaKetanaMGA() {
435
- const [alot72, temporalHour] = this.getTemporalHour72(false);
436
- return new Date(alot72.getTime() + Math.floor(9.5 * temporalHour));
437
- }
438
- /**
439
- * Plag haMincha; Sunrise plus 10.75 halachic hours.
440
- * If elevation is enabled, this function will include elevation in the calculation.
441
- */
442
- plagHaMincha() {
443
- return this.getShaahZmanisBasedZman(10.75);
444
- }
445
- /**
446
- * @param [angle=8.5] optional time for solar depression.
447
- * Default is 8.5 degrees for 3 small stars, use 7.083 degrees for 3 medium-sized stars.
448
- * Because degree-based functions estimate the amount of light in the sky,
449
- * the result is not impacted by elevation.
450
- */
451
- tzeit(angle = 8.5) {
452
- return this.timeAtAngle(angle, false);
453
- }
454
- tzeit72() {
455
- const zdt = this.useElevation
456
- ? this.noaa.getSunset()
457
- : this.noaa.getSeaLevelSunset();
458
- if (!zdt) {
459
- return null;
460
- }
461
- return zdt.add({ minutes: 72 });
462
- }
463
- /**
464
- * Alias for sunrise
465
- */
466
- neitzHaChama() {
467
- return this.sunrise();
468
- }
469
- /**
470
- * Alias for sunset
471
- */
472
- shkiah() {
473
- return this.sunset();
474
- }
475
- /**
476
- * Rabbeinu Tam holds that bein hashmashos is a specific time
477
- * between sunset and tzeis hakochavim.
478
- * One opinion on how to calculate this time is that
479
- * it is 13.5 minutes before tzies 7.083.
480
- * Because degree-based functions estimate the amount of light in the sky,
481
- * the result is not impacted by elevation.
482
- */
483
- beinHaShmashos() {
484
- const tzeit = this.tzeit(7.083);
485
- const millis = tzeit.getTime();
486
- if (isNaN(millis)) {
487
- return tzeit;
488
- }
489
- return new Date(millis - 13.5 * 60 * 1000);
490
- }
491
- /**
492
- * Used by Molad based _zmanim_ to determine if _zmanim_ occur during the current day.
493
- * @return previous midnight
494
- */
495
- getMidnightLastNight() {
496
- // reset hour, minutes, seconds and millis
497
- return this.plainDate.toZonedDateTime({
498
- timeZone: this.gloc.getTimeZone(),
499
- });
500
- }
501
- /**
502
- * Used by Molad based _zmanim_ to determine if _zmanim_ occur during the current day.
503
- * @return following midnight
504
- */
505
- getMidnightTonight() {
506
- return this.plainDate.add({ days: 1 }).toZonedDateTime({
507
- timeZone: this.gloc.getTimeZone(),
508
- });
509
- }
510
- /**
511
- * Returns the Date of the _molad_ based time if it occurs on the current date. Since _Kiddush Levana_
512
- * can only be said during the day, there are parameters to limit it to between _alos_ and _tzais_. If
513
- * the time occurs between _alos_ and _tzais_, _tzais_ will be returned.
514
- *
515
- * @param moladBasedTime
516
- * the _molad_ based time such as _molad_, _tchilas_ and _sof zman Kiddush Levana_
517
- * @param alos
518
- * optional start of day to limit _molad_ times to the end of the night before or beginning of the next night.
519
- * Ignored if either _alos_ or _tzais_ are null.
520
- * @param tzais
521
- * optional end of day to limit _molad_ times to the end of the night before or beginning of the next night.
522
- * Ignored if either _tzais_ or _alos_ are null
523
- * @param techila
524
- * is it the start of _Kiddush Levana_ time or the end? If it is start roll it to the next _tzais_,
525
- * and if it is the end, return the end of the previous night (_alos_ passed in). Ignored if either
526
- * _alos_ or _tzais_ are null.
527
- * @return the _molad_ based time. If the _zman_ does not occur during the current date, `null` will be
528
- * returned.
529
- */
530
- getMoladBasedTime(moladBasedTime, alos, tzais, techila) {
531
- const lastMidnight = this.getMidnightLastNight();
532
- const midnightTonight = this.getMidnightTonight();
533
- if (Temporal.ZonedDateTime.compare(moladBasedTime, lastMidnight) < 0 ||
534
- Temporal.ZonedDateTime.compare(moladBasedTime, midnightTonight) > 0) {
535
- return null; // Invalid time, bailout
536
- }
537
- if (alos === null || tzais === null) {
538
- return moladBasedTime.withTimeZone(this.gloc.getTimeZone()); // Not enough info to adjust
539
- }
540
- if (Temporal.ZonedDateTime.compare(moladBasedTime, alos) > 0 &&
541
- Temporal.ZonedDateTime.compare(moladBasedTime, tzais) < 0) {
542
- // It's the daytime (after alos but before tzais)
543
- // get the next/prev night
544
- return techila ? tzais : alos;
545
- }
546
- // It's the night, the provided time is valid
547
- return moladBasedTime.withTimeZone(this.gloc.getTimeZone());
548
- }
549
- /**
550
- * Returns the latest time of Kiddush Levana according to the <a
551
- * href="https://en.wikipedia.org/wiki/Yaakov_ben_Moshe_Levi_Moelin">Maharil's</a> opinion that it is calculated as
552
- * halfway between _molad_ and _molad_. This adds half the 29 days, 12 hours and 793 chalakim time between
553
- * _molad_ and _molad_ (14 days, 18 hours, 22 minutes and 666 milliseconds) to the month's _molad_.
554
- * The _sof zman Kiddush Levana_ will be returned even if it occurs during the day. To limit the time to between
555
- * _tzais_ and _alos_, see {@link getSofZmanKidushLevanaBetweenMoldos}.
556
- *
557
- * @param alos
558
- * the beginning of the Jewish day. If _Kidush Levana_ occurs during the day (starting at _alos_ and
559
- * ending at _tzais_), the time returned will be alos. If either the _alos_ or _tzais_ parameters
560
- * are null, no daytime adjustment will be made.
561
- * @param tzais
562
- * the end of the Jewish day. If Kidush Levana occurs during the day (starting at alos and ending at
563
- * tzais), the time returned will be alos. If either the alos or tzais parameters are null, no daytime
564
- * adjustment will be made.
565
- * @return the Date representing the moment halfway between molad and molad. If the time occurs between
566
- * _alos_ and _tzais_, _alos_ will be returned. If the _zman_ will not occur on this
567
- * day, a `null` will be returned.
568
- */
569
- getSofZmanKidushLevanaBetweenMoldos(alos = null, tzais = null) {
570
- const hd = this.hdate;
571
- // Do not calculate for impossible dates, but account for extreme cases. In the extreme case of Rapa Iti in French
572
- // Polynesia on Dec 2027 when kiddush Levana 3 days can be said on _Rosh Chodesh_, the sof zman Kiddush Levana
573
- // will be on the 12th of the Teves. In the case of Anadyr, Russia on Jan, 2071, sof zman Kiddush Levana between the
574
- // moldos will occur is on the night of 17th of Shevat. See Rabbi Dovid Heber's Shaarei Zmanim chapter 4 (pages 28 and 32).
575
- if (hd.getDate() < 11 || hd.getDate() > 16) {
576
- return null;
577
- }
578
- const molad = new Molad(hd.getFullYear(), hd.getMonth());
579
- return this.getMoladBasedTime(molad.getSofZmanKidushLevanaBetweenMoldos(), alos, tzais, false);
580
- }
581
- /**
582
- * Returns the latest time of _Kiddush Levana_ calculated as 15 days after the molad. This is the opinion of
583
- * the Shulchan Aruch (Orach Chaim 426). It should be noted that some opinions hold that the
584
- * <a href="https://en.wikipedia.org/wiki/Moses_Isserles">Rema</a> who brings down the opinion of the <a
585
- * href="https://en.wikipedia.org/wiki/Yaakov_ben_Moshe_Levi_Moelin">Maharil's</a> of calculating
586
- * {@link getSofZmanKidushLevanaBetweenMoldos half way between _molad_ and _molad_} is of
587
- * the opinion that the Mechaber agrees to his opinion. Also see the Aruch Hashulchan. For additional details on the subject,
588
- * See Rabbi Dovid Heber's very detailed write-up in Siman Daled (chapter 4) of <a href="https://hebrewbooks.org/53000">Shaarei
589
- * Zmanim</a>. The _sof zman Kiddush Levana_ will be returned even if it occurs during the day. To limit the time to
590
- * between _tzais_ and _alos_, see {@link getSofZmanKidushLevana15Days}.
591
- *
592
- * @return the Date representing the moment 15 days after the _molad_. If the time occurs between
593
- * _alos_ and _tzais_, _alos_ will be returned. If the _zman_ will not occur on this day, a
594
- * `null` will be returned.
595
- *
596
- *
597
- */
598
- getSofZmanKidushLevana15Days(alos = null, tzais = null) {
599
- const hd = this.hdate;
600
- // Do not calculate for impossible dates, but account for extreme cases. In the extreme case of Rapa Iti in
601
- // French Polynesia on Dec 2027 when kiddush Levana 3 days can be said on _Rosh Chodesh_, the sof zman Kiddush
602
- // Levana will be on the 12th of the Teves. in the case of Anadyr, Russia on Jan, 2071, sof zman kiddush levana will
603
- // occur after midnight on the 17th of Shevat. See Rabbi Dovid Heber's Shaarei Zmanim chapter 4 (pages 28 and 32).
604
- if (hd.getDate() < 11 || hd.getDate() > 17) {
605
- return null;
606
- }
607
- const molad = new Molad(hd.getFullYear(), hd.getMonth());
608
- return this.getMoladBasedTime(molad.getSofZmanKidushLevana15Days(), alos, tzais, false);
609
- }
610
- /**
611
- * Returns the earliest time of _Kiddush Levana_ according to <a href=
612
- * "https://en.wikipedia.org/wiki/Yonah_Gerondi">Rabbeinu Yonah</a>'s opinion that it can be said 3 days after the _molad_.
613
- * If the time of _tchilas zman Kiddush Levana_ occurs during the day (between _alos_ and _tzais_ passed to
614
- * this method) it will return the following _tzais_. If null is passed for either _alos_ or _tzais_, the actual
615
- * _tchilas zman Kiddush Levana_ will be returned, regardless of if it is during the day or not.
616
- *
617
- * @param alos
618
- * the beginning of the Jewish day. If Kidush Levana occurs during the day (starting at _alos_ and ending
619
- * at _tzais_), the time returned will be _tzais_. If either the _alos_ or _tzais_ parameters
620
- * are null, no daytime adjustment will be made.
621
- * @param tzais
622
- * the end of the Jewish day. If _Kidush Levana_ occurs during the day (starting at _alos_ and ending at
623
- * _tzais_), the time returned will be _tzais_. If either the _alos_ or _tzais_ parameters
624
- * are null, no daytime adjustment will be made.
625
- *
626
- * @return the Date representing the moment 3 days after the molad. If the time occurs between _alos_ and
627
- * _tzais_, _tzais_ will be returned. If the _zman_ will not occur on this day, a
628
- * `null` will be returned.
629
- */
630
- getTchilasZmanKidushLevana3Days(alos = null, tzais = null) {
631
- const hd = this.hdate;
632
- // Do not calculate for impossible dates, but account for extreme cases. Tchilas zman kiddush Levana 3 days for
633
- // the extreme case of Rapa Iti in French Polynesia on Dec 2027 when kiddush Levana 3 days can be said on the evening
634
- // of the 30th, the second night of Rosh Chodesh. The 3rd day after the _molad_ will be on the 4th of the month.
635
- // In the case of Anadyr, Russia on Jan, 2071, when sof zman kiddush levana is on the 17th of the month, the 3rd day
636
- // from the molad will be on the 5th day of Shevat. See Rabbi Dovid Heber's Shaarei Zmanim chapter 4 (pages 28 and 32).
637
- if (hd.getDate() > 5 && hd.getDate() < 30) {
638
- return null;
639
- }
640
- const molad = new Molad(hd.getFullYear(), hd.getMonth());
641
- let zman = this.getMoladBasedTime(molad.getTchilasZmanKidushLevana3Days(), alos, tzais, true);
642
- // Get the following month's zman kiddush Levana for the extreme case of Rapa Iti in French Polynesia on Dec 2027 when
643
- // kiddush Levana can be said on Rosh Chodesh (the evening of the 30th). See Rabbi Dovid Heber's Shaarei Zmanim chapter 4 (page 32)
644
- if (zman === null && hd.getDate() === 30) {
645
- const hd2 = hd.add(1, 'week');
646
- const molad2 = new Molad(hd2.getFullYear(), hd2.getMonth());
647
- zman = this.getMoladBasedTime(molad2.getTchilasZmanKidushLevana3Days(), null, null, true);
648
- }
649
- return zman;
650
- }
651
- /**
652
- * Returns the point in time of _Molad_ as a <code>Date</code> Object. For the traditional day of week, hour,
653
- * minute and chalakim, {@link Molad.getInstant()} and the not yet completed
654
- * {@link HebrewDateFormatter} that will have formatting for this.
655
- *
656
- * @return the Date representing the moment of the molad. If the _molad_ does not occur on this day, a
657
- * `null` will be returned.
658
- *
659
- */
660
- getZmanMolad() {
661
- const hd = this.hdate;
662
- // Optimize to not calculate for impossible dates, but account for extreme cases. The molad in the extreme case of Rapa
663
- // Iti in French Polynesia on Dec 2027 occurs on the night of the 27th of Kislev. In the case of Anadyr, Russia on
664
- // Jan 2071, the molad will be on the 2nd day of Shevat. See Rabbi Dovid Heber's Shaarei Zmanim chapter 4 (pages 28 and 32).
665
- if (hd.getDate() > 2 && hd.getDate() < 27) {
666
- return null;
667
- }
668
- const molad = new Molad(hd.getFullYear(), hd.getMonth());
669
- let zman = this.getMoladBasedTime(molad.getInstant(), null, null, true);
670
- // deal with molad that happens on the end of the previous month
671
- if (zman === null && hd.getDate() > 26) {
672
- const hd2 = hd.add(1, 'week');
673
- const molad2 = new Molad(hd2.getFullYear(), hd2.getMonth());
674
- zman = this.getMoladBasedTime(molad2.getInstant(), null, null, true);
675
- }
676
- return zman;
677
- }
678
- /**
679
- * Returns the earliest time of _Kiddush Levana_ according to the opinions that it should not be said until 7
680
- * days after the _molad_. The time will be returned even if it occurs during the day when _Kiddush Levana_
681
- * can't be recited. Use {@link getTchilasZmanKidushLevana7Days} if you want to limit the time to night hours.
682
- *
683
- * @return the Date representing the moment 7 days after the molad regardless of it is day or night. If the _zman_
684
- * will not occur on this day, a `null` will be returned.
685
- */
686
- getTchilasZmanKidushLevana7Days(alos = null, tzais = null) {
687
- const hd = this.hdate;
688
- // Optimize to not calculate for impossible dates, but account for extreme cases. Tchilas zman kiddush Levana 7 days for
689
- // the extreme case of Rapa Iti in French Polynesia on Jan 2028 (when kiddush Levana 3 days can be said on the evening
690
- // of the 30th, the second night of Rosh Chodesh), the 7th day after the molad will be on the 4th of the month.
691
- // In the case of Anadyr, Russia on Jan, 2071, when sof zman kiddush levana is on the 17th of the month, the 7th day
692
- // from the molad will be on the 9th day of Shevat. See Rabbi Dovid Heber's Shaarei Zmanim chapter 4 (pages 28 and 32).
693
- if (hd.getDate() < 4 || hd.getDate() > 9) {
694
- return null;
695
- }
696
- const molad = new Molad(hd.getFullYear(), hd.getMonth());
697
- return this.getMoladBasedTime(molad.getTchilasZmanKidushLevana7Days(), alos, tzais, true);
698
- }
699
- /**
700
- * A method that returns the <a href="https://en.wikipedia.org/wiki/Shneur_Zalman_of_Liadi">Baal Hatanya</a>'s
701
- * _netz amiti_ (sunrise) without
702
- * elevation adjustment. This forms the base for the Baal Hatanya's dawn-based calculations that are
703
- * calculated as a dip below the horizon before sunrise.
704
- *
705
- * According to the Baal Hatanya, _netz amiti_, or true (halachic) sunrise, is when the top of the sun's
706
- * disk is visible at an elevation similar to the mountains of Eretz Yisrael. The time is calculated as the point at which
707
- * the center of the sun's disk is 1.583&deg; below the horizon. This degree-based calculation can be found in Rabbi Shalom
708
- * DovBer Levine's commentary on The <a href="https://www.chabadlibrary.org/books/pdf/Seder-Hachnosas-Shabbos.pdf">Baal
709
- * Hatanya's Seder Hachnasas Shabbos</a>. From an elevation of 546 meters, the top of <a href=
710
- * "https://en.wikipedia.org/wiki/Mount_Carmel">Har Hacarmel</a>, the sun disappears when it is 1&deg; 35' or 1.583&deg;
711
- * below the sea level horizon. This in turn is based on the Gemara <a href=
712
- * "https://hebrewbooks.org/shas.aspx?mesechta=2&daf=35">Shabbos 35a</a>. There are other opinions brought down by
713
- * Rabbi Levine, including Rabbi Yosef Yitzchok Feigelstock who calculates it as the degrees below the horizon 4 minutes after
714
- * sunset in Yerushalayim (on the equinox). That is brought down as 1.583&deg;. This is identical to the 1&deg; 35' _zman_
715
- * and is probably a typo and should be 1.683&deg;. These calculations are used by most <a href=
716
- * "https://en.wikipedia.org/wiki/Chabad">Chabad</a> calendars that use the Baal Hatanya's _zmanim_. See
717
- * <a href="https://www.chabad.org/library/article_cdo/aid/3209349/jewish/About-Our-Zmanim-Calculations.htm">About Our
718
- * _Zmanim_ Calculations @ Chabad.org</a>.
719
- *
720
- * Note: _netz amiti_ is used only for calculating certain _zmanim_, and is intentionally unpublished. For
721
- * practical purposes, daytime _mitzvos_ like _shofar_ and _lulav_ should not be done until after the
722
- * published time for _netz_ / sunrise.
723
- *
724
- * @return the <code>Date</code> representing the exact sea level _netz amiti_ (sunrise) time. If the calculation can't be
725
- * computed such as in the Arctic Circle where there is at least one day a year where the sun does not rise, and one
726
- * where it does not set, a `null` will be returned. See detailed explanation on top of the page.
727
- *
728
- * @see ZENITH_1_POINT_583
729
- */
730
- getSunriseBaalHatanya() {
731
- return this.noaa.getSunriseOffsetByDegrees(ZENITH_1_POINT_583);
732
- }
733
- /**
734
- * A method that returns the <a href="https://en.wikipedia.org/wiki/Shneur_Zalman_of_Liadi">Baal Hatanya</a>'s
735
- * _shkiah amiti_ (sunset) without
736
- * elevation adjustment. This forms the base for the Baal Hatanya's dusk-based calculations that are calculated
737
- * as a dip below the horizon after sunset.
738
- *
739
- * According to the Baal Hatanya, _shkiah amiti_, true (_halachic_) sunset, is when the top of the
740
- * sun's disk disappears from view at an elevation similar to the mountains of _Eretz Yisrael_.
741
- * This time is calculated as the point at which the center of the sun's disk is 1.583 degrees below the horizon.
742
- *
743
- * Note: _shkiah amiti_ is used only for calculating certain _zmanim_, and is intentionally unpublished. For
744
- * practical purposes, all daytime mitzvos should be completed before the published time for _shkiah_ / sunset.
745
- *
746
- * For further explanation of the calculations used for the Baal Hatanya's _zmanim_ in this library, see
747
- * <a href="https://www.chabad.org/library/article_cdo/aid/3209349/jewish/About-Our-Zmanim-Calculations.htm">About Our
748
- * _Zmanim_ Calculations @ Chabad.org</a>.
749
- *
750
- * @return the <code>Date</code> representing the exact sea level _shkiah amiti_ (sunset) time. If the calculation
751
- * can't be computed such as in the Arctic Circle where there is at least one day a year where the sun does not
752
- * rise, and one where it does not set, a `null` will be returned.
753
- *
754
- * @see ZENITH_1_POINT_583
755
- */
756
- getSunsetBaalHatanya() {
757
- return this.noaa.getSunsetOffsetByDegrees(ZENITH_1_POINT_583);
758
- }
759
- /**
760
- * Returns the <a href="https://en.wikipedia.org/wiki/Shneur_Zalman_of_Liadi">Baal Hatanya</a>'s _alos_
761
- * (dawn) calculated as the time when the sun is 16.9&deg; below the eastern {@link GEOMETRIC_ZENITH geometric horizon}
762
- * before {@link getSunrise() sunrise}.
763
- *
764
- * The zenith of 16.9&deg; below is based on the calculation that the time between dawn
765
- * and _netz amiti_ (sunrise) is 72 minutes, the time that is takes to walk 4 mil at 18 minutes
766
- * a mil (<a href="https://en.wikipedia.org/wiki/Maimonides">Rambam</a> and others). The sun's position at 72
767
- * minutes before {@link getSunriseBaalHatanya _netz amiti_ (sunrise)} in Jerusalem <a href=
768
- * "https://kosherjava.com/2022/01/12/equinox-vs-equilux-zmanim-calculations/">around the equinox / equilux</a> is
769
- * 16.9&deg; below {@link GEOMETRIC_ZENITH geometric zenith}.
770
- *
771
- * @return The <code>Date</code> of dawn. If the calculation can't be computed such as northern and southern
772
- * locations even south of the Arctic Circle and north of the Antarctic Circle where the sun may not reach
773
- * low enough below the horizon for this calculation, a `null` will be returned. */
774
- alosBaalHatanya() {
775
- return this.timeAtAngle(16.9, true);
776
- }
777
- getShaahZmanisBaalHatanya(hours) {
778
- const zdt = this.getShaahZmanisBasedZmanZdt(this.getSunriseBaalHatanya(), this.getSunsetBaalHatanya(), hours);
779
- return zdtToDate(zdt);
780
- }
781
- /**
782
- * This method returns the latest _zman krias shema_ (time to recite Shema in the morning). This time is 3
783
- * {@link shaahZmanisBaalHatanya() _shaos zmaniyos_} (solar hours) after {@link getSunriseBaalHatanya()
784
- * _netz amiti_ (sunrise)} based on the opinion of the Baal Hatanya that the day is calculated from
785
- * sunrise to sunset. This returns the time 3 * {@link getShaahZmanisBaalHatanya()} after {@link getSunriseBaalHatanya()
786
- * _netz amiti_ (sunrise)}.
787
- *
788
- * @return the <code>Date</code> of the latest _zman shema_ according to the Baal Hatanya. If the calculation
789
- * can't be computed such as in the Arctic Circle where there is at least one day a year where the sun does
790
- * not rise, and one where it does not set, a `null` will be returned.
791
- */
792
- sofZmanShmaBaalHatanya() {
793
- return this.getShaahZmanisBaalHatanya(3);
794
- }
795
- /**
796
- * This method returns the latest _zman tfilah_ (time to recite the morning prayers). This time is 4
797
- * hours into the day based on the opinion of the Baal Hatanya that the day is
798
- * calculated from sunrise to sunset. This returns the time 4 * {@link getShaahZmanisBaalHatanya()} after
799
- * {@link getSunriseBaalHatanya() _netz amiti_ (sunrise)}.
800
- *
801
- * @return the <code>Date</code> of the latest _zman tfilah_. If the calculation can't be computed such as in
802
- * the Arctic Circle where there is at least one day a year where the sun does not rise, and one where it does
803
- * not set, a `null` will be returned.
804
- */
805
- sofZmanTfilaBaalHatanya() {
806
- return this.getShaahZmanisBaalHatanya(4);
807
- }
808
- /**
809
- * This method returns the time of _mincha gedola_. _Mincha gedola_ is the earliest time one can pray
810
- * _mincha_. The <a href="https://en.wikipedia.org/wiki/Maimonides">Rambam</a> is of the opinion that it is
811
- * better to delay _mincha_ until {@link minchaKetanaBaalHatanya() _mincha ketana_} while the
812
- * <a href="https://en.wikipedia.org/wiki/Asher_ben_Jehiel">Ra"sh</a>,
813
- * <a href="https://en.wikipedia.org/wiki/Jacob_ben_Asher">Tur</a>, <a href=
814
- * "https://en.wikipedia.org/wiki/Vilna_Gaon">GRA</a> and others are of the opinion that _mincha_ can be prayed
815
- * _lechatchila_ starting at _mincha gedola_. This is calculated as 6.5 {@link getShaahZmanisBaalHatanya()
816
- * sea level solar hours} after {@link getSunriseBaalHatanya() _netz amiti_ (sunrise)}. This calculation is based
817
- * on the opinion of the Baal Hatanya that the day is calculated from sunrise to sunset. This returns the time 6.5
818
- * * {@link getShaahZmanisBaalHatanya()} after {@link getSunriseBaalHatanya() _netz amiti_ ("real" sunrise)}.
819
- * @return the <code>Date</code> of the time of _mincha gedola_ according to the Baal Hatanya. If the calculation
820
- * can't be computed such as in the Arctic Circle where there is at least one day a year where the sun does not rise,
821
- * and one where it does not set, a `null` will be returned.
822
- */
823
- minchaGedolaBaalHatanya() {
824
- return this.getShaahZmanisBaalHatanya(6.5);
825
- }
826
- /**
827
- * This method returns the time of _mincha ketana_. This is the preferred earliest time to pray
828
- * _mincha_ in the opinion of the <a href="https://en.wikipedia.org/wiki/Maimonides">Rambam</a> and others.
829
- * For more information on this see the documentation on {@link minchaGedolaBaalHatanya() _mincha gedola_}.
830
- * This is calculated as 9.5 sea level solar hours after {@link getSunriseBaalHatanya
831
- * _netz amiti_ (sunrise)}. This calculation is calculated based on the opinion of the Baal Hatanya that the
832
- * day is calculated from sunrise to sunset. This returns the time 9.5 * after
833
- * _netz amiti_ (sunrise).
834
- *
835
- * @return the <code>Date</code> of the time of _mincha ketana_. If the calculation can't be computed such as
836
- * in the Arctic Circle where there is at least one day a year where the sun does not rise, and one where it
837
- * does not set, a `null` will be returned.
838
- */
839
- minchaKetanaBaalHatanya() {
840
- return this.getShaahZmanisBaalHatanya(9.5);
841
- }
842
- /**
843
- * This method returns the time of _plag hamincha_. This is calculated as 10.75 hours after sunrise. This
844
- * calculation is based on the opinion of the Baal Hatanya that the day is calculated
845
- * from sunrise to sunset. This returns the time 10.75 * {@link getShaahZmanisBaalHatanya()} after
846
- * {@link getSunriseBaalHatanya() _netz amiti_ (sunrise)}.
847
- *
848
- * @return the <code>Date</code> of the time of _plag hamincha_. If the calculation can't be computed such as
849
- * in the Arctic Circle where there is at least one day a year where the sun does not rise, and one where it
850
- * does not set, a `null` will be returned.
851
- */
852
- plagHaminchaBaalHatanya() {
853
- return this.getShaahZmanisBaalHatanya(10.75);
854
- }
855
- /**
856
- * A method that returns _tzais_ (nightfall) when the sun is 6&deg; below the western geometric horizon
857
- * (90&deg;) after {@link getSunset() sunset}. For information on the source of this calculation see
858
- * {@link ZENITH_6_DEGREES}.
859
- *
860
- * @return The <code>Date</code> of nightfall. If the calculation can't be computed such as northern and southern
861
- * locations even south of the Arctic Circle and north of the Antarctic Circle where the sun may not reach
862
- * low enough below the horizon for this calculation, a `null` will be returned. * @see ZENITH_6_DEGREES
863
- */
864
- tzaisBaalHatanya() {
865
- return this.timeAtAngle(6, false);
866
- }
867
- /**
868
- * Uses timeFormat to return a date like '20:34'.
869
- * Returns `XX:XX` if the date is invalid.
870
- */
871
- static formatTime(dt, timeFormat) {
872
- if (isNaN(dt.getTime())) {
873
- return 'XX:XX'; // Invalid Date
874
- }
875
- const time = timeFormat.format(dt);
876
- const hm = time.split(':');
877
- if (hm[0] === '24') {
878
- return '00:' + hm[1];
879
- }
880
- return time;
881
- }
882
- /**
883
- * Discards seconds, rounding to nearest minute.
884
- * @param dt
885
- */
886
- static roundTime(dt) {
887
- const millis = dt.getTime();
888
- if (isNaN(millis)) {
889
- return dt;
890
- }
891
- // Round up to next minute if needed
892
- const millisOnly = dt.getMilliseconds();
893
- const seconds = dt.getSeconds();
894
- if (seconds === 0 && millisOnly === 0) {
895
- return dt;
896
- }
897
- const secAndMillis = seconds * 1000 + millisOnly;
898
- const delta = secAndMillis >= 30000 ? 60000 - secAndMillis : -1 * secAndMillis;
899
- return new Date(millis + delta);
900
- }
901
- /**
902
- * Get offset string (like "+05:00" or "-08:00") from tzid (like "Europe/Moscow")
903
- * @param tzid
904
- * @param date
905
- */
906
- static timeZoneOffset(tzid, date) {
907
- const offset = getTimezoneOffset(tzid, date);
908
- const offsetAbs = Math.abs(offset);
909
- const hours = Math.floor(offsetAbs / 60);
910
- const minutes = offsetAbs % 60;
911
- return (offset < 0 ? '+' : '-') + pad2(hours) + ':' + pad2(minutes);
912
- }
913
- /**
914
- * Returns a string like "2022-04-01T13:06:00-11:00"
915
- * @param tzid
916
- * @param date
917
- */
918
- static formatISOWithTimeZone(tzid, date) {
919
- if (isNaN(date.getTime())) {
920
- return '0000-00-00T00:00:00Z';
921
- }
922
- return (getPseudoISO(tzid, date).substring(0, 19) +
923
- Zmanim.timeZoneOffset(tzid, date));
924
- }
925
- /**
926
- * Returns sunrise + `offset` minutes (either positive or negative).
927
- * If elevation is enabled, this function will include elevation in the calculation
928
- * unless `forceSeaLevel` is `true`.
929
- * @param offset minutes
930
- * @param roundMinute round time to nearest minute (default true)
931
- * @param forceSeaLevel use sea-level sunrise (default false)
932
- */
933
- sunriseOffset(offset, roundMinute = true, forceSeaLevel = false) {
934
- const sunrise = forceSeaLevel ? this.seaLevelSunrise() : this.sunrise();
935
- if (isNaN(sunrise.getTime())) {
936
- return sunrise;
937
- }
938
- if (roundMinute) {
939
- // For positive offsets only, round up to next minute if needed
940
- if (offset > 0 && sunrise.getSeconds() >= 30) {
941
- offset++;
942
- }
943
- sunrise.setSeconds(0, 0);
944
- }
945
- return new Date(sunrise.getTime() + offset * 60 * 1000);
946
- }
947
- /**
948
- * Returns sunset + `offset` minutes (either positive or negative).
949
- * If elevation is enabled, this function will include elevation in the calculation
950
- * unless `forceSeaLevel` is `true`.
951
- * @param offset minutes
952
- * @param roundMinute round time to nearest minute (default true)
953
- * @param forceSeaLevel use sea-level sunset (default false)
954
- */
955
- sunsetOffset(offset, roundMinute = true, forceSeaLevel = false) {
956
- const sunset = forceSeaLevel ? this.seaLevelSunset() : this.sunset();
957
- if (isNaN(sunset.getTime())) {
958
- return sunset;
959
- }
960
- if (roundMinute) {
961
- // For Havdalah only, round up to next minute if needed
962
- if (offset > 0 && sunset.getSeconds() >= 30) {
963
- offset++;
964
- }
965
- sunset.setSeconds(0, 0);
966
- }
967
- return new Date(sunset.getTime() + offset * 60 * 1000);
968
- }
969
- /**
970
- * Returns the Hebrew date relative to the specified location and Gregorian date,
971
- * taking into consideration whether the time is before or after sunset.
972
- *
973
- * For example, if the given date and is `2024-09-22T10:35` (before sunset), and
974
- * sunset for the specified location is **19:04**, then this function would
975
- * return a Hebrew date of `19th of Elul, 5784`.
976
- * If the given date is the same Gregorian day after sunset
977
- * (for example `2024-09-22T20:07`), this function would return a
978
- * Hebrew date of `20th of Elul, 5784`.
979
- * @example
980
- * const {GeoLocation, Zmanim, HDate} = require('@hebcal/core');
981
- * const latitude = 48.85341;
982
- * const longitude = 2.3488;
983
- * const timezone = 'Europe/Paris';
984
- * const gloc = new GeoLocation(null, latitude, longitude, 0, timezone);
985
- * const before = Zmanim.makeSunsetAwareHDate(gloc, new Date('2024-09-22T17:38:46.123Z'), false);
986
- * console.log(before.toString()); // '19 Elul 5784'
987
- * const after = Zmanim.makeSunsetAwareHDate(gloc, new Date('2024-09-22T23:45:18.345Z'), false);
988
- * console.log(after.toString()); // '20 Elul 5784'
989
- */
990
- static makeSunsetAwareHDate(gloc, date, useElevation) {
991
- const zmanim = new Zmanim(gloc, date, useElevation);
992
- const sunset = zmanim.sunset();
993
- let hd = new HDate(date);
994
- const sunsetMillis = sunset.getTime();
995
- if (isNaN(sunsetMillis)) {
996
- return hd;
997
- }
998
- if (date.getTime() >= sunsetMillis) {
999
- hd = hd.next();
1000
- }
1001
- return hd;
1002
- }
1003
- }