@hebcal/core 6.8.1 → 6.9.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 (97) hide show
  1. package/README.md +262 -4
  2. package/dist/bundle.js +1401 -943
  3. package/dist/bundle.js.map +1 -1
  4. package/dist/bundle.min.js +18 -17
  5. package/dist/bundle.min.js.map +1 -1
  6. package/dist/esm/CalOptions.d.ts +11 -1
  7. package/dist/esm/DailyLearning.d.ts +4 -4
  8. package/dist/esm/DailyLearning.js +5 -5
  9. package/dist/esm/DailyLearning.js.map +1 -1
  10. package/dist/esm/HebrewDateEvent.js +1 -1
  11. package/dist/esm/HolidayEvent.d.ts +7 -2
  12. package/dist/esm/HolidayEvent.js +8 -3
  13. package/dist/esm/HolidayEvent.js.map +1 -1
  14. package/dist/esm/MevarchimChodeshEvent.d.ts +2 -1
  15. package/dist/esm/MevarchimChodeshEvent.js +3 -2
  16. package/dist/esm/MevarchimChodeshEvent.js.map +1 -1
  17. package/dist/esm/ParshaEvent.d.ts +13 -0
  18. package/dist/esm/ParshaEvent.js +14 -1
  19. package/dist/esm/ParshaEvent.js.map +1 -1
  20. package/dist/esm/TimedEvent.d.ts +12 -4
  21. package/dist/esm/TimedEvent.js +13 -5
  22. package/dist/esm/TimedEvent.js.map +1 -1
  23. package/dist/esm/YomKippurKatanEvent.d.ts +2 -1
  24. package/dist/esm/YomKippurKatanEvent.js +3 -2
  25. package/dist/esm/YomKippurKatanEvent.js.map +1 -1
  26. package/dist/esm/ashkenazi.po.js +1 -1
  27. package/dist/esm/calendar.d.ts +17 -7
  28. package/dist/esm/calendar.js +23 -10
  29. package/dist/esm/calendar.js.map +1 -1
  30. package/dist/esm/candles.d.ts +19 -1
  31. package/dist/esm/candles.js +20 -2
  32. package/dist/esm/candles.js.map +1 -1
  33. package/dist/esm/cities.json.js +1 -1
  34. package/dist/esm/event.d.ts +2 -4
  35. package/dist/esm/event.js +3 -5
  36. package/dist/esm/event.js.map +1 -1
  37. package/dist/esm/getStartAndEnd.js +1 -1
  38. package/dist/esm/hallel.js +1 -1
  39. package/dist/esm/he-x-NoNikud.po.js +1 -1
  40. package/dist/esm/he.po.js +2 -2
  41. package/dist/esm/he.po.js.map +1 -1
  42. package/dist/esm/hebcal.d.ts +31 -96
  43. package/dist/esm/hebcal.js +34 -107
  44. package/dist/esm/hebcal.js.map +1 -1
  45. package/dist/esm/holidays.d.ts +8 -1
  46. package/dist/esm/holidays.js +2 -2
  47. package/dist/esm/holidays.js.map +1 -1
  48. package/dist/esm/index.d.ts +3 -1
  49. package/dist/esm/index.js +3 -1
  50. package/dist/esm/index.js.map +1 -1
  51. package/dist/esm/isAssurBemlacha.js +6 -3
  52. package/dist/esm/isAssurBemlacha.js.map +1 -1
  53. package/dist/esm/isAveilut.js +1 -1
  54. package/dist/esm/isFastDay.d.ts +1 -1
  55. package/dist/esm/isFastDay.js +2 -2
  56. package/dist/esm/isFastDay.js.map +1 -1
  57. package/dist/esm/locale.js +1 -1
  58. package/dist/esm/location.d.ts +37 -9
  59. package/dist/esm/location.js +38 -10
  60. package/dist/esm/location.js.map +1 -1
  61. package/dist/esm/modern.js +1 -1
  62. package/dist/esm/molad.d.ts +26 -20
  63. package/dist/esm/molad.js +27 -21
  64. package/dist/esm/molad.js.map +1 -1
  65. package/dist/esm/moladBase.d.ts +11 -0
  66. package/dist/esm/moladBase.js +12 -1
  67. package/dist/esm/moladBase.js.map +1 -1
  68. package/dist/esm/moladDate.d.ts +10 -6
  69. package/dist/esm/moladDate.js +25 -18
  70. package/dist/esm/moladDate.js.map +1 -1
  71. package/dist/esm/omer.d.ts +19 -3
  72. package/dist/esm/omer.js +20 -4
  73. package/dist/esm/omer.js.map +1 -1
  74. package/dist/esm/parshaName.js +1 -1
  75. package/dist/esm/parshaYear.d.ts +2 -2
  76. package/dist/esm/parshaYear.js +3 -3
  77. package/dist/esm/parshaYear.js.map +1 -1
  78. package/dist/esm/pkgVersion.d.ts +1 -1
  79. package/dist/esm/pkgVersion.js +2 -2
  80. package/dist/esm/pkgVersion.js.map +1 -1
  81. package/dist/esm/reformatTimeStr.d.ts +14 -2
  82. package/dist/esm/reformatTimeStr.js +15 -3
  83. package/dist/esm/reformatTimeStr.js.map +1 -1
  84. package/dist/esm/sedra.d.ts +44 -18
  85. package/dist/esm/sedra.js +39 -17
  86. package/dist/esm/sedra.js.map +1 -1
  87. package/dist/esm/sefira.json.js +1 -1
  88. package/dist/esm/staticHolidays.d.ts +0 -2
  89. package/dist/esm/staticHolidays.js +1 -3
  90. package/dist/esm/staticHolidays.js.map +1 -1
  91. package/dist/esm/string.js +1 -1
  92. package/dist/esm/tachanun.js +1 -1
  93. package/dist/esm/zmanim.d.ts +177 -142
  94. package/dist/esm/zmanim.js +183 -148
  95. package/dist/esm/zmanim.js.map +1 -1
  96. package/package.json +9 -10
  97. package/po/he.po +4 -2
package/README.md CHANGED
@@ -12,8 +12,21 @@ yahrzeits, birthdays and anniversaries.
12
12
 
13
13
  `@hebcal/core` targets both browser-based JavaScript and server-side Node.js.
14
14
 
15
- Many users of this library will utilize the [HebrewCalendar](https://hebcal.github.io/api/core/classes/HebrewCalendar.html)
16
- and [HDate](https://hebcal.github.io/api/hdate/classes/HDate.html) interfaces.
15
+ Most work starts with the [`calendar()`](https://hebcal.github.io/api/core/functions/calendar.html)
16
+ function and the [`HDate`](https://hebcal.github.io/api/hdate/classes/HDate.html) class.
17
+
18
+ Nearly everything is available as a standalone function — `calendar()`,
19
+ `getHolidaysOnDate()`, `getSedra()`, `tachanun()`, `reformatTimeStr()` — and the
20
+ examples here use that form, since importing only what you need is what lets a
21
+ bundler drop the rest. The same functions are also reachable as static methods on
22
+ [`HebrewCalendar`](https://hebcal.github.io/api/core/classes/HebrewCalendar.html).
23
+
24
+ Yahrzeits and birthdays are standalone functions too, but they live in
25
+ `@hebcal/hdate` rather than here — import `yahrzeit()` and
26
+ `birthdayOrAnniversary()` from there directly.
27
+ `HebrewCalendar.getYahrzeit()` and `.getBirthdayOrAnniversary()` are thin
28
+ wrappers over them. A few odds and ends remain class-only:
29
+ `eruvTavshilin()`, `hallel()` and `getHolidaysForYear()`.
17
30
 
18
31
  ## Installation
19
32
 
@@ -24,9 +37,9 @@ npm install @hebcal/core
24
37
  ## Synopsis
25
38
 
26
39
  ```javascript
27
- import {HebrewCalendar, Location} from '@hebcal/core';
40
+ import {calendar, Location} from '@hebcal/core';
28
41
 
29
- const events = HebrewCalendar.calendar({
42
+ const events = calendar({
30
43
  year: 1981,
31
44
  isHebrewYear: false,
32
45
  candlelighting: true,
@@ -42,6 +55,222 @@ for (const ev of events) {
42
55
  }
43
56
  ```
44
57
 
58
+ ## Events and flags
59
+
60
+ Everything `calendar()` returns is an [`Event`](https://hebcal.github.io/api/core/classes/Event.html):
61
+ a Hebrew date, a description, a `flags` bitmask, and optional extras. Subclasses add
62
+ detail — `HolidayEvent`, `ParshaEvent`, `OmerEvent`, `CandleLightingEvent` and
63
+ `HavdalahEvent` (both `TimedEvent`s, carrying an `eventTime`), `MoladEvent`,
64
+ `HebrewDateEvent`, and others.
65
+
66
+ Rather than testing `instanceof`, classify events with `flags`:
67
+
68
+ ```javascript
69
+ import {calendar, flags} from '@hebcal/core';
70
+
71
+ const events = calendar({year: 5784, isHebrewYear: true});
72
+
73
+ for (const ev of events) {
74
+ if (ev.getFlags() & flags.MAJOR_FAST) {
75
+ console.log('fast day:', ev.render('en'));
76
+ }
77
+ }
78
+ ```
79
+
80
+ You can also push the filter down into generation, which is cheaper than filtering
81
+ afterwards, via `options.mask`:
82
+
83
+ ```javascript
84
+ const roshChodesh = calendar({
85
+ year: 5784,
86
+ isHebrewYear: true,
87
+ mask: flags.ROSH_CHODESH,
88
+ });
89
+ ```
90
+
91
+ `Event.getCategories()` gives a coarser, string-based classification
92
+ (`['holiday', 'major', 'fast']`) that is handy for CSS classes or grouping.
93
+ See the [flags API docs](https://hebcal.github.io/api/core/variables/flags.html)
94
+ for the full list.
95
+
96
+ ## Looking up a single date
97
+
98
+ `calendar()` is built for generating a _range_. When you only need to know what
99
+ falls on one day, `getHolidaysOnDate()` is much more direct — it reads from an
100
+ internally cached per-year map instead of running the full generator:
101
+
102
+ ```javascript
103
+ import {getHolidaysOnDate, HDate, months} from '@hebcal/core';
104
+
105
+ const events = getHolidaysOnDate(new HDate(15, months.NISAN, 5784), false);
106
+ console.log(events?.map(ev => ev.getDesc())); // ['Pesach I']
107
+ ```
108
+
109
+ Three things to know:
110
+
111
+ - It returns `undefined` — not an empty array — when nothing falls on that date, so
112
+ use `events?.map(...)` or check before indexing.
113
+ - The `il` argument is optional, and **omitting it is not the same as passing
114
+ `false`**. With `il` omitted you get both the Israel and Diaspora events for that
115
+ date, unfiltered; pass `true` or `false` to get one schedule.
116
+ - It accepts an `HDate`, a `Date`, or an absolute R.D. day number.
117
+
118
+ It returns only holidays. Candle-lighting times, Torah readings and Omer days come
119
+ from `calendar()`, which is what `options.candlelighting`, `options.sedrot` and
120
+ `options.omer` drive.
121
+
122
+ ## Daily learning (Daf Yomi and friends)
123
+
124
+ `@hebcal/core` ships **no** learning schedules itself. `DailyLearning` is a plug-in
125
+ registry; the schedules live in the separate
126
+ [`@hebcal/learning`](https://github.com/hebcal/hebcal-learning) package, which
127
+ registers them by calling `DailyLearning.addCalendar()` when you import it. This
128
+ keeps the daily-study tables — which are large and grow as new cycles are added —
129
+ out of the core bundle for the many users who don't need them.
130
+
131
+ Import `@hebcal/learning` once for its side effects, then request calendars through
132
+ `options.dailyLearning`:
133
+
134
+ ```javascript
135
+ import '@hebcal/learning';
136
+ import {calendar, flags} from '@hebcal/core';
137
+
138
+ const events = calendar({
139
+ year: 5784,
140
+ isHebrewYear: true,
141
+ noHolidays: true,
142
+ dailyLearning: {dafYomi: true},
143
+ });
144
+
145
+ for (const ev of events) {
146
+ if (ev.getFlags() & flags.DAF_YOMI) {
147
+ console.log(ev.getDate().toString(), ev.render('en'));
148
+ }
149
+ }
150
+ ```
151
+
152
+ Daf Yomi (Babylonian Talmud) is by far the most widely used. `@hebcal/learning` also
153
+ provides Yerushalmi Yomi, Mishna Yomi, Nach Yomi, Daf Weekly, Chofetz Chaim, Rambam,
154
+ 929 and more. Most take `true`; `yerushalmi` takes a number selecting the edition
155
+ (`1` for Vilna, `2` for Schottenstein):
156
+
157
+ ```javascript
158
+ dailyLearning: {dafYomi: true, mishnaYomi: true, yerushalmi: 1}
159
+ ```
160
+
161
+ To query a single day without generating a calendar, use `DailyLearning.lookup()`:
162
+
163
+ ```javascript
164
+ import '@hebcal/learning';
165
+ import {DailyLearning, HDate, months} from '@hebcal/core';
166
+
167
+ const ev = DailyLearning.lookup(
168
+ 'dafYomi',
169
+ new HDate(15, months.CHESHVAN, 5784),
170
+ false
171
+ );
172
+ console.log(ev?.render('en')); // 'Daf Yomi: Kiddushin 78'
173
+ ```
174
+
175
+ `DailyLearning.getCalendars()` returns the authoritative list of what the installed
176
+ version of `@hebcal/learning` actually registered; `has()` and `getStartDate()` report
177
+ whether a given calendar is available and from what date. You can register your own
178
+ schedule with `addCalendar()` — the same entry point `@hebcal/learning` uses.
179
+
180
+ ## Candle lighting, Havdalah, and fast times
181
+
182
+ Set `options.candlelighting = true` and supply an `options.location` to get timed
183
+ events. Times are computed from latitude and longitude via NOAA solar equations. If
184
+ you ever have any doubts about Hebcal's times, consult your local halachic authority —
185
+ and note that coordinates above the Arctic or below the Antarctic circle are
186
+ guaranteed to be wrong.
187
+
188
+ ```javascript
189
+ import {calendar, Location, flags} from '@hebcal/core';
190
+
191
+ const events = calendar({
192
+ year: 2024,
193
+ candlelighting: true,
194
+ location: Location.lookup('Jerusalem'),
195
+ });
196
+
197
+ for (const ev of events) {
198
+ if (ev.getFlags() & flags.LIGHT_CANDLES) {
199
+ console.log(ev.getDate().toString(), ev.eventTimeStr); // '24 Tevet 5784' '16:08'
200
+ }
201
+ }
202
+ ```
203
+
204
+ **Candle lighting** defaults to 18 minutes before sunset in the Diaspora and 20
205
+ minutes in Israel, with 40 minutes for Jerusalem and 30 for Haifa and Zikhron
206
+ Ya'akov. Override with `options.candleLightingMins`.
207
+
208
+ **Havdalah** defaults to Tzeit Hakochavim — nightfall, when 3 small stars are
209
+ visible — calculated at 8.5° of solar depression. Two mutually exclusive overrides:
210
+
211
+ - `options.havdalahDeg` — a different solar depression angle (7.083° is the common
212
+ alternative, for 3 medium-sized stars). Set to `0` to suppress Havdalah times.
213
+ - `options.havdalahMins` — a fixed number of minutes after sunset instead (42, 50
214
+ and 72 are typical). Set to `0` to suppress Havdalah times.
215
+
216
+ **Minor fasts** begin at Alot HaShachar (16.1° in the morning). They end at 7.083°
217
+ in the Diaspora, or 15 minutes after sunset in Israel (Rabbi Deblitzky's practice).
218
+ Override with `options.fastEndDeg` or `options.fastEndMins` — again mutually
219
+ exclusive. When a minor fast falls on a Friday, the end time is suppressed, because
220
+ Shabbat begins before nightfall.
221
+
222
+ **Tish'a B'Av** does not follow those rules: it begins at sunset the previous day and
223
+ always ends at 6.45° (Rabbi Yechiel Michel Tucazinsky), ignoring `fastEndDeg` and
224
+ `fastEndMins`.
225
+
226
+ **Chanukah** candle-lighting, also generated when `candlelighting` and `location`
227
+ are set, is at Bein HaShmashos (13.5 minutes before 7.083°) on weekdays, regular
228
+ candle-lighting time on Friday, and regular Havdalah time on Saturday night.
229
+
230
+ Set `options.useElevation = true` to factor a location's elevation into sunrise and
231
+ sunset. Note that degree-based zmanim estimate the amount of light in the sky and
232
+ so are unaffected by elevation by design; `chatzot` is also always computed at sea
233
+ level.
234
+
235
+ For zmanim outside the calendar-generation flow, use the
236
+ [`Zmanim`](https://hebcal.github.io/api/core/classes/Zmanim.html) class directly.
237
+
238
+ ## Yahrzeits, birthdays, and anniversaries
239
+
240
+ These are two different calculations, not one function with a flag, because the
241
+ customs genuinely differ. Both follow "Calendrical Calculations" by Reingold and
242
+ Dershowitz.
243
+
244
+ Both live in `@hebcal/hdate`; `HebrewCalendar` exposes them as wrappers for
245
+ convenience.
246
+
247
+ ```javascript
248
+ import {birthdayOrAnniversary, yahrzeit} from '@hebcal/hdate';
249
+
250
+ const dt = new Date(2014, 2, 2); // 30 Adar I 5774
251
+
252
+ birthdayOrAnniversary(5785, dt)?.toString(); // '1 Nisan 5785'
253
+ yahrzeit(5785, dt)?.toString(); // '30 Sh'vat 5785'
254
+ ```
255
+
256
+ The short version: **a birthday moves forward, a yahrzeit moves back.** When the
257
+ original day doesn't exist in the target year, a birthday is postponed to the first
258
+ of the following month, whereas a yahrzeit is observed on the day _before_ that — so
259
+ in the example above the two land a month apart.
260
+
261
+ A yahrzeit has one more wrinkle: for a death on 30 Marcheshvan or 30 Kislev, the
262
+ date in later years depends on what happened at the **first** anniversary, so the
263
+ observance is fixed by precedent rather than recomputed independently each year.
264
+
265
+ They also differ at the boundary, and for a reason: asking for the original year
266
+ gives you the original date back from `birthdayOrAnniversary()`, because a "0th
267
+ birthday" is a meaningful thing to ask for. `yahrzeit()` returns `undefined` there,
268
+ because a yahrzeit only has meaning from the first anniversary onward. Both return
269
+ `undefined` for years before the original.
270
+
271
+ Neither function modifies the date you pass in, so a single original date can be
272
+ reused to generate a run of years.
273
+
45
274
  ## Displaying the current Shabbat
46
275
 
47
276
  `ParshaEvent` is designed for regular weekly parsha readings. On Shabbatot
@@ -75,6 +304,35 @@ console.log(reading.name.he);
75
304
  console.log(reading.summary);
76
305
  ```
77
306
 
307
+ ## `Date`, `Temporal`, and what's coming in v7
308
+
309
+ Solar calculations in this library run on
310
+ [Temporal](https://tc39.es/proposal-temporal/docs/), which arrives via the
311
+ `@hebcal/noaa` dependency. It is supplied by `temporal-polyfill`, imported through
312
+ its `/global` entry point — that installs `Temporal` onto `globalThis` only when
313
+ `globalThis.Temporal` is absent, so on an engine that ships Temporal natively you
314
+ transparently get the native implementation instead.
315
+
316
+ Temporal is newer than most of the JavaScript standard library, but it has been
317
+ running in production here for over two years. It is worth the dependency: unlike
318
+ `Date`, it models instants, wall-clock times, and time zones as distinct things,
319
+ which is exactly the distinction zmanim arithmetic depends on. Getting DST
320
+ transitions and standard-time offsets right with `Date` alone means a lot of
321
+ error-prone manual bookkeeping.
322
+
323
+ The awkward part today is that the public API is still mostly `Date`-based, and
324
+ `Zmanim` in particular mixes the two — most methods return a `Date` rounded to the
325
+ minute, while a few (`tzeit72()`, `alotHaShachar72zdt()`, the Kiddush Levana methods
326
+ on `Molad`) return a `Temporal.ZonedDateTime` with seconds precision. Where a
327
+ `Date`-returning method can't compute a time — far enough north or south that the sun
328
+ doesn't cross the relevant angle — it returns an `Invalid Date`; the
329
+ `Temporal`-returning ones return `null` instead.
330
+
331
+ That split is transitional. The intent is to move the library to `Temporal`
332
+ throughout, which is a breaking change and so is planned for `@hebcal/core` version 7.
333
+ Until then, checking `isNaN(dt.getTime())` on `Date` results and `=== null` on
334
+ `Temporal` results is the portable approach.
335
+
78
336
  ## Usage
79
337
 
80
338
  This package exports two categories of output: