@hebcal/core 6.5.1 → 6.5.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 (126) hide show
  1. package/dist/bundle.js +5930 -5385
  2. package/dist/bundle.js.map +1 -1
  3. package/dist/bundle.min.js +17 -17
  4. package/dist/bundle.min.js.map +1 -1
  5. package/dist/eslint.config.mjs +1 -0
  6. package/dist/esm/CalOptions.d.ts +3 -4
  7. package/dist/esm/DailyLearning.d.ts +44 -7
  8. package/dist/esm/DailyLearning.js +45 -8
  9. package/dist/esm/DailyLearning.js.map +1 -1
  10. package/dist/esm/HebrewDateEvent.js +1 -1
  11. package/dist/esm/HolidayEvent.d.ts +34 -1
  12. package/dist/esm/HolidayEvent.js +35 -2
  13. package/dist/esm/HolidayEvent.js.map +1 -1
  14. package/dist/esm/MevarchimChodeshEvent.js +1 -1
  15. package/dist/esm/ParshaEvent.js +1 -1
  16. package/dist/esm/TimedEvent.d.ts +32 -3
  17. package/dist/esm/TimedEvent.js +33 -4
  18. package/dist/esm/TimedEvent.js.map +1 -1
  19. package/dist/esm/YomKippurKatanEvent.js +1 -1
  20. package/dist/esm/ashkenazi.po.d.ts +1 -0
  21. package/dist/esm/ashkenazi.po.js +2 -2
  22. package/dist/esm/ashkenazi.po.js.map +1 -1
  23. package/dist/esm/calendar.js +1 -1
  24. package/dist/esm/candles.d.ts +14 -1
  25. package/dist/esm/candles.js +15 -2
  26. package/dist/esm/candles.js.map +1 -1
  27. package/dist/esm/cities.json.js +1 -1
  28. package/dist/esm/event.d.ts +56 -13
  29. package/dist/esm/event.js +57 -14
  30. package/dist/esm/event.js.map +1 -1
  31. package/dist/esm/getStartAndEnd.js +10 -2
  32. package/dist/esm/getStartAndEnd.js.map +1 -1
  33. package/dist/esm/hallel.js +20 -28
  34. package/dist/esm/hallel.js.map +1 -1
  35. package/dist/esm/he-x-NoNikud.po.js +1 -1
  36. package/dist/esm/he.po.js +1 -1
  37. package/dist/esm/hebcal.d.ts +97 -19
  38. package/dist/esm/hebcal.js +102 -21
  39. package/dist/esm/hebcal.js.map +1 -1
  40. package/dist/esm/holidays.d.ts +21 -2
  41. package/dist/esm/holidays.js +22 -3
  42. package/dist/esm/holidays.js.map +1 -1
  43. package/dist/esm/index.d.ts +1 -1
  44. package/dist/esm/index.js +2 -1
  45. package/dist/esm/index.js.map +1 -1
  46. package/dist/esm/isAssurBemlacha.d.ts +24 -4
  47. package/dist/esm/isAssurBemlacha.js +25 -5
  48. package/dist/esm/isAssurBemlacha.js.map +1 -1
  49. package/dist/esm/isAveilut.d.ts +14 -3
  50. package/dist/esm/isAveilut.js +15 -4
  51. package/dist/esm/isAveilut.js.map +1 -1
  52. package/dist/esm/isFastDay.d.ts +13 -1
  53. package/dist/esm/isFastDay.js +14 -2
  54. package/dist/esm/isFastDay.js.map +1 -1
  55. package/dist/esm/locale.js +1 -1
  56. package/dist/esm/location.d.ts +96 -8
  57. package/dist/esm/location.js +101 -10
  58. package/dist/esm/location.js.map +1 -1
  59. package/dist/esm/modern.js +1 -1
  60. package/dist/esm/molad.d.ts +39 -7
  61. package/dist/esm/molad.js +40 -8
  62. package/dist/esm/molad.js.map +1 -1
  63. package/dist/esm/moladBase.js +1 -1
  64. package/dist/esm/moladDate.js +1 -1
  65. package/dist/esm/omer.d.ts +32 -4
  66. package/dist/esm/omer.js +33 -5
  67. package/dist/esm/omer.js.map +1 -1
  68. package/dist/esm/parshaName.js +1 -1
  69. package/dist/esm/parshaYear.d.ts +12 -1
  70. package/dist/esm/parshaYear.js +13 -2
  71. package/dist/esm/parshaYear.js.map +1 -1
  72. package/dist/esm/pkgVersion.d.ts +1 -1
  73. package/dist/esm/pkgVersion.js +2 -2
  74. package/dist/esm/pkgVersion.js.map +1 -1
  75. package/dist/esm/reformatTimeStr.js +1 -1
  76. package/dist/esm/sedra.d.ts +94 -14
  77. package/dist/esm/sedra.js +95 -15
  78. package/dist/esm/sedra.js.map +1 -1
  79. package/dist/esm/sefira.json.js +1 -1
  80. package/dist/esm/staticHolidays.js +1 -1
  81. package/dist/esm/tachanun.js +1 -1
  82. package/dist/esm/temporal-shim.js +1 -1
  83. package/dist/esm/zmanim.js +1 -1
  84. package/dist/src/CalOptions.d.ts +3 -4
  85. package/dist/src/DailyLearning.d.ts +44 -7
  86. package/dist/src/DailyLearning.js +44 -7
  87. package/dist/src/HolidayEvent.d.ts +34 -1
  88. package/dist/src/HolidayEvent.js +34 -1
  89. package/dist/src/TimedEvent.d.ts +32 -3
  90. package/dist/src/TimedEvent.js +32 -3
  91. package/dist/src/ashkenazi.po.d.ts +1 -0
  92. package/dist/src/ashkenazi.po.js +1 -1
  93. package/dist/src/candles.d.ts +14 -1
  94. package/dist/src/candles.js +14 -1
  95. package/dist/src/event.d.ts +56 -13
  96. package/dist/src/event.js +56 -13
  97. package/dist/src/getStartAndEnd.js +9 -1
  98. package/dist/src/hallel.js +19 -27
  99. package/dist/src/hebcal.d.ts +97 -19
  100. package/dist/src/hebcal.js +101 -20
  101. package/dist/src/holidays.d.ts +21 -2
  102. package/dist/src/holidays.js +21 -2
  103. package/dist/src/index.d.ts +1 -1
  104. package/dist/src/index.js +1 -0
  105. package/dist/src/isAssurBemlacha.d.ts +24 -4
  106. package/dist/src/isAssurBemlacha.js +24 -4
  107. package/dist/src/isAveilut.d.ts +14 -3
  108. package/dist/src/isAveilut.js +14 -3
  109. package/dist/src/isFastDay.d.ts +13 -1
  110. package/dist/src/isFastDay.js +13 -1
  111. package/dist/src/location.d.ts +96 -8
  112. package/dist/src/location.js +100 -9
  113. package/dist/src/molad.d.ts +39 -7
  114. package/dist/src/molad.js +39 -7
  115. package/dist/src/omer.d.ts +32 -4
  116. package/dist/src/omer.js +32 -4
  117. package/dist/src/parshaYear.d.ts +12 -1
  118. package/dist/src/parshaYear.js +12 -1
  119. package/dist/src/pkgVersion.d.ts +1 -1
  120. package/dist/src/pkgVersion.js +1 -1
  121. package/dist/src/sedra.d.ts +94 -14
  122. package/dist/src/sedra.js +94 -14
  123. package/package.json +11 -7
  124. package/po/ashkenazi.po +240 -0
  125. package/po/he-x-NoNikud.po +58 -0
  126. package/po/he.po +650 -0
@@ -46,7 +46,7 @@ export class HebrewCalendar {
46
46
  * The date range returned by this function can be controlled by:
47
47
  * * `options.year` - Gregorian (e.g. 1993) or Hebrew year (e.g. 5749)
48
48
  * * `options.isHebrewYear` - to interpret `year` as Hebrew year
49
- * * `options.numYears` - generate calendar for multiple years (default 1)
49
+ * * `options.numYears` - generate calendar for multiple years (default 1, maximum 2000)
50
50
  * * `options.month` - Gregorian or Hebrew month (to filter results to a single month)
51
51
  *
52
52
  * Alternatively, specify start and end days with `Date` or {@link HDate} instances:
@@ -223,15 +223,36 @@ export class HebrewCalendar {
223
223
  }
224
224
  /**
225
225
  * Lower-level holidays interface, which returns a `Map` of `Event`s indexed by
226
- * `HDate.toString()`. These events must filtered especially for `flags.IL_ONLY`
226
+ * `HDate.toString()`. These events must be filtered for `flags.IL_ONLY`
227
227
  * or `flags.CHUL_ONLY` depending on Israel vs. Diaspora holiday scheme.
228
+ *
229
+ * Includes Rosh Chodesh, fasts, Yom Kippur Katan, Special Shabbatot, etc.,
230
+ * but does not generate candle-lighting times, Torah readings, or Omer days.
231
+ * The result is cached in an internal LRU.
232
+ * @example
233
+ * import {HebrewCalendar} from '@hebcal/core';
234
+ * const map = HebrewCalendar.getHolidaysForYear(5784);
235
+ * for (const [hdStr, events] of map.entries()) {
236
+ * for (const ev of events) {
237
+ * console.log(hdStr, ev.getDesc());
238
+ * }
239
+ * }
228
240
  * @param year Hebrew year
229
241
  */
230
242
  static getHolidaysForYear(year) {
231
243
  return getHolidaysForYear_(year);
232
244
  }
233
245
  /**
234
- * Returns an array of holidays for the year
246
+ * Returns a sorted array of holidays observed during the given Hebrew year.
247
+ *
248
+ * Events are pre-filtered by Israel vs. Diaspora schedule, so callers do not
249
+ * need to inspect `flags.IL_ONLY` / `flags.CHUL_ONLY` themselves.
250
+ * Includes Rosh Chodesh, fasts, modern holidays, special Shabbatot, etc.,
251
+ * but does not generate candle-lighting times, Torah readings, or Omer days.
252
+ * @example
253
+ * import {HebrewCalendar} from '@hebcal/core';
254
+ * const events = HebrewCalendar.getHolidaysForYearArray(5784, false);
255
+ * console.log(events[0].getDesc()); // 'Rosh Hashana 5784'
235
256
  * @param year Hebrew year
236
257
  * @param il use the Israeli schedule for holidays
237
258
  */
@@ -239,7 +260,16 @@ export class HebrewCalendar {
239
260
  return getHolidaysForYearArray(year, il);
240
261
  }
241
262
  /**
242
- * Returns an array of Events on this date (or `undefined` if no events)
263
+ * Returns an array of holiday Events that occur on the given date,
264
+ * or `undefined` if no holidays occur that day.
265
+ *
266
+ * When `il` is omitted, both Diaspora-only and Israel-only events are
267
+ * returned; pass `true` or `false` to filter to a single schedule.
268
+ * @example
269
+ * import {HebrewCalendar, HDate, months} from '@hebcal/core';
270
+ * const hd = new HDate(15, months.NISAN, 5784);
271
+ * const events = HebrewCalendar.getHolidaysOnDate(hd, false);
272
+ * console.log(events?.map(ev => ev.getDesc())); // ['Pesach I']
243
273
  * @param date Hebrew Date, Gregorian date, or absolute R.D. day number
244
274
  * @param [il] use the Israeli schedule for holidays
245
275
  */
@@ -247,7 +277,20 @@ export class HebrewCalendar {
247
277
  return getHolidaysOnDate(date, il);
248
278
  }
249
279
  /**
250
- * Eruv Tavshilin
280
+ * Returns `true` if Eruv Tavshilin should be prepared on the given date.
281
+ *
282
+ * Eruv Tavshilin is prepared when a Yom Tov falls on Friday (so cooking
283
+ * for Shabbat that begins Friday night may continue from Yom Tov into
284
+ * Shabbat). This requires the day before to be a weekday (Wednesday or
285
+ * Thursday), the following Friday to be Yom Tov, and the day after Friday
286
+ * (Shabbat) to also be a sacred day.
287
+ * @example
288
+ * import {HebrewCalendar} from '@hebcal/core';
289
+ * // Thursday April 25, 2024 — first day of Pesach 5784, with Shabbat
290
+ * // chol ha-moed the next day, so Eruv Tavshilin is required:
291
+ * HebrewCalendar.eruvTavshilin(new Date(2024, 3, 25), false); // true
292
+ * @param date Gregorian or Hebrew date to test
293
+ * @param il use the Israeli holiday schedule
251
294
  */
252
295
  static eruvTavshilin(date, il) {
253
296
  if (date.getDay() < 3 || date.getDay() > 4) {
@@ -262,11 +305,19 @@ export class HebrewCalendar {
262
305
  return true;
263
306
  }
264
307
  /**
265
- * Helper function to format a 23-hour (00:00-23:59) time in US format ("8:13pm") or
266
- * keep as "20:13" for any other locale/country. Uses {@link CalOptions} to determine
267
- * locale.
268
- * If `options.hour12` is `false`, locale is ignored and always returns 24-hour time.
269
- * If `options.hour12` is `true`, locale is ignored and always returns 12-hour time.
308
+ * Helper function to format a 24-hour (00:00-23:59) time string in either
309
+ * 12-hour US format (e.g. `"8:13pm"`) or keep it in 24-hour format (e.g.
310
+ * `"20:13"`) for any other locale or country.
311
+ *
312
+ * The locale (and therefore default behavior) is derived from
313
+ * `options.location` / `options.locale`. The `options.hour12` override
314
+ * takes precedence: if `false`, locale is ignored and the result is always
315
+ * 24-hour; if `true`, locale is ignored and the result is always 12-hour.
316
+ * @example
317
+ * import {HebrewCalendar, Location} from '@hebcal/core';
318
+ * const opts = {location: Location.lookup('Chicago')};
319
+ * HebrewCalendar.reformatTimeStr('20:30', 'pm', opts); // '8:30pm'
320
+ * HebrewCalendar.reformatTimeStr('20:30', 'pm', {hour12: false}); // '20:30'
270
321
  * @param timeStr - original time like "20:30"
271
322
  * @param suffix - "p" or "pm" or " P.M.". Add leading space if you want it
272
323
  * @param options
@@ -274,32 +325,53 @@ export class HebrewCalendar {
274
325
  static reformatTimeStr(timeStr, suffix, options) {
275
326
  return reformatTimeStr(timeStr, suffix, options);
276
327
  }
328
+ /**
329
+ * Returns the semantic version string of the `@hebcal/core` package
330
+ * (e.g. `"5.10.0"`). Useful for logging or feature detection.
331
+ */
277
332
  static version() {
278
333
  return pkgVersion;
279
334
  }
280
335
  /**
281
- * Convenience function to create an instance of `Sedra` or reuse a previously
282
- * created and cached instance.
336
+ * Convenience function to create an instance of {@link Sedra} or reuse a
337
+ * previously created and cached instance for the same year + schedule.
338
+ *
339
+ * Use this in preference to `new Sedra(...)` when calling repeatedly,
340
+ * since an internal LRU cache (~120 entries) avoids recomputing the
341
+ * keviyah-specific reading pattern.
342
+ * @example
343
+ * import {HebrewCalendar} from '@hebcal/core';
344
+ * const sedra = HebrewCalendar.getSedra(5784, false);
345
+ * const result = sedra.lookup(new HDate(15, 'Cheshvan', 5784));
346
+ * console.log(result.parsha); // ['Lech-Lecha']
347
+ * @param hyear Hebrew year
348
+ * @param il Use Israel sedra schedule (`false` for Diaspora)
283
349
  */
284
350
  static getSedra(hyear, il) {
285
351
  return getSedra(hyear, il);
286
352
  }
287
353
  /**
288
- * Return a number containing information on what Hallel is said on that day.
354
+ * Determines which form of Hallel (if any) is recited
355
+ * on a given Hebrew date.
356
+ *
357
+ * Returns 0 (none), 1 (half Hallel), or 2 (whole Hallel).
289
358
  *
290
359
  * Whole Hallel is said on Chanukah, the first Yom Tov of Pesach, Shavuot, Sukkot,
291
360
  * Yom Ha'atzmaut, and Yom Yerushalayim.
292
361
  *
293
362
  * Half Hallel is said on Rosh Chodesh (not Rosh Hashanah), and the last 6 days of Pesach.
294
- *
295
- * The number is one of the following values:
296
- *
297
- * 0 - No Hallel
298
- * 1 - Half Hallel
299
- * 2 - Whole Hallel
363
+ * @returns 0 for no Hallel, 1 for half Hallel, 2 for whole Hallel
364
+ * @example
365
+ * import {HebrewCalendar, HDate, months} from '@hebcal/core';
366
+ * HebrewCalendar.hallel(new HDate(25, months.KISLEV, 5784), false); // 2 (Chanukah)
367
+ * HebrewCalendar.hallel(new HDate(1, months.SHVAT, 5784), false); // 1 (Rosh Chodesh)
368
+ * HebrewCalendar.hallel(new HDate(2, months.SHVAT, 5784), false); // 0
300
369
  */
301
370
  static hallel(hdate, il) {
302
- const events = getHolidaysForYearArray(hdate.getFullYear(), il);
371
+ const events = getHolidaysOnDate(hdate, il);
372
+ if (!events) {
373
+ return 0;
374
+ }
303
375
  return hallel_(events, hdate);
304
376
  }
305
377
  /**
@@ -317,6 +389,15 @@ export class HebrewCalendar {
317
389
  * Tachanun is not said at Mincha on days before it is not said at Shacharit.
318
390
  *
319
391
  * Tachanun is not said at Shacharit on Shabbat, but is at Mincha, usually.
392
+ * @example
393
+ * import {HebrewCalendar, HDate, months} from '@hebcal/core';
394
+ * // Regular weekday — Tachanun is said at both services
395
+ * HebrewCalendar.tachanun(new HDate(2, months.SHVAT, 5784), false);
396
+ * // => { shacharit: true, mincha: true, allCongs: true }
397
+ *
398
+ * // Rosh Chodesh — no Tachanun
399
+ * HebrewCalendar.tachanun(new HDate(1, months.SHVAT, 5784), false);
400
+ * // => { shacharit: false, mincha: false, allCongs: false }
320
401
  */
321
402
  static tachanun(hdate, il) {
322
403
  return tachanun(hdate, il);
@@ -1,7 +1,17 @@
1
1
  import { HDate } from '@hebcal/hdate';
2
2
  import { HolidayEvent } from './HolidayEvent';
3
3
  /**
4
- * Returns an array of Events on this date (or `undefined` if no events)
4
+ * Returns an array of holiday Events that occur on the given date, or
5
+ * `undefined` if no holidays occur that day.
6
+ *
7
+ * When `il` is omitted, both Diaspora-only and Israel-only events are
8
+ * returned (e.g. on the second day of a Yom Tov, both `"Pesach II"` for
9
+ * Diaspora and any Israel-only events). Pass `true` or `false` to filter
10
+ * to a single schedule.
11
+ * @example
12
+ * import {getHolidaysOnDate, HDate, months} from '@hebcal/core';
13
+ * const events = getHolidaysOnDate(new HDate(15, months.NISAN, 5784), false);
14
+ * events?.map(ev => ev.getDesc()); // ['Pesach I']
5
15
  * @param date Hebrew Date, Gregorian date, or absolute R.D. day number
6
16
  * @param [il] use the Israeli schedule for holidays
7
17
  */
@@ -15,7 +25,16 @@ export type HolidayYearMap = Map<string, HolidayEvent[]>;
15
25
  */
16
26
  export declare function getHolidaysForYear_(year: number): HolidayYearMap;
17
27
  /**
18
- * Returns an array of holidays for the year
28
+ * Returns a sorted array of holidays observed during the given Hebrew year,
29
+ * filtered by Israel vs. Diaspora schedule.
30
+ *
31
+ * Includes Rosh Chodesh, fasts, special Shabbatot, modern holidays, etc.,
32
+ * but does not generate candle-lighting times, Torah readings, or Omer days.
33
+ * Use {@link HebrewCalendar.calendar} for those.
34
+ * @example
35
+ * import {getHolidaysForYearArray} from '@hebcal/core';
36
+ * const events = getHolidaysForYearArray(5784, false);
37
+ * console.log(events[0].getDesc()); // 'Rosh Hashana 5784'
19
38
  * @param year Hebrew year
20
39
  * @param il use the Israeli schedule for holidays
21
40
  */
@@ -27,7 +27,17 @@ import { staticHolidays, staticModernHolidays, holidayDesc as hdesc, } from './s
27
27
  import { YomKippurKatanEvent } from './YomKippurKatanEvent';
28
28
  import { HolidayEvent, ChanukahEvent, AsaraBTevetEvent, RoshHashanaEvent, RoshChodeshEvent, } from './HolidayEvent';
29
29
  /**
30
- * Returns an array of Events on this date (or `undefined` if no events)
30
+ * Returns an array of holiday Events that occur on the given date, or
31
+ * `undefined` if no holidays occur that day.
32
+ *
33
+ * When `il` is omitted, both Diaspora-only and Israel-only events are
34
+ * returned (e.g. on the second day of a Yom Tov, both `"Pesach II"` for
35
+ * Diaspora and any Israel-only events). Pass `true` or `false` to filter
36
+ * to a single schedule.
37
+ * @example
38
+ * import {getHolidaysOnDate, HDate, months} from '@hebcal/core';
39
+ * const events = getHolidaysOnDate(new HDate(15, months.NISAN, 5784), false);
40
+ * events?.map(ev => ev.getDesc()); // ['Pesach I']
31
41
  * @param date Hebrew Date, Gregorian date, or absolute R.D. day number
32
42
  * @param [il] use the Israeli schedule for holidays
33
43
  */
@@ -284,7 +294,16 @@ function getBirkatHaChama(year) {
284
294
  return 0;
285
295
  }
286
296
  /**
287
- * Returns an array of holidays for the year
297
+ * Returns a sorted array of holidays observed during the given Hebrew year,
298
+ * filtered by Israel vs. Diaspora schedule.
299
+ *
300
+ * Includes Rosh Chodesh, fasts, special Shabbatot, modern holidays, etc.,
301
+ * but does not generate candle-lighting times, Torah readings, or Omer days.
302
+ * Use {@link HebrewCalendar.calendar} for those.
303
+ * @example
304
+ * import {getHolidaysForYearArray} from '@hebcal/core';
305
+ * const events = getHolidaysForYearArray(5784, false);
306
+ * console.log(events[0].getDesc()); // 'Rosh Hashana 5784'
288
307
  * @param year Hebrew year
289
308
  * @param il use the Israeli schedule for holidays
290
309
  */
@@ -17,7 +17,7 @@ export { MoladBase, calculateMolad } from './moladBase';
17
17
  export { getMoladAsDate } from './moladDate';
18
18
  export { Molad, MoladEvent } from './molad';
19
19
  export { OmerEvent, OmerLang } from './omer';
20
- export { TachanunResult } from './tachanun';
20
+ export { TachanunResult, tachanun } from './tachanun';
21
21
  export { Sedra, SedraResult, parshiot, getSedra } from './sedra';
22
22
  export { ParshaEvent } from './ParshaEvent';
23
23
  export { parshaYear } from './parshaYear';
package/dist/src/index.js CHANGED
@@ -16,6 +16,7 @@ export { calculateMolad } from './moladBase';
16
16
  export { getMoladAsDate } from './moladDate';
17
17
  export { Molad, MoladEvent } from './molad';
18
18
  export { OmerEvent } from './omer';
19
+ export { tachanun } from './tachanun';
19
20
  export { Sedra, parshiot, getSedra } from './sedra';
20
21
  export { ParshaEvent } from './ParshaEvent';
21
22
  export { parshaYear } from './parshaYear';
@@ -1,9 +1,29 @@
1
1
  import { Location } from './location';
2
2
  /**
3
- * Utility method to determine if the date and time has a <em>melacha</em> (work) prohibition.
4
- * Although there are many opinions on the time of <em>tzais</em>, for simplicity
5
- * this function uses solar depression of 8.5 degrees.
3
+ * Returns `true` if the given moment (date + time) falls within a period
4
+ * when *melacha* (work) is prohibited i.e. Shabbat or a Yom Tov.
6
5
  *
7
- * @return `true` if <em>melacha</em> is prohibited or `false` if it is not.
6
+ * The Shabbat/Yom Tov window is taken to begin at sunset (shkiah) on the
7
+ * preceding day (Erev Shabbat / Erev Yom Tov / Yom Tov sheni) and to end
8
+ * at *tzais* (nightfall) on the day itself. *Tzais* is calculated using a
9
+ * solar depression of 8.5° for simplicity; consult a halachic authority
10
+ * for more stringent opinions.
11
+ *
12
+ * `useElevation` controls whether the location's elevation is taken into
13
+ * account when computing sunset (it has no effect on the degree-based
14
+ * tzais calculation). The Israel/Diaspora schedule comes from
15
+ * `location.getIsrael()`.
16
+ *
17
+ * Throws if sunset cannot be calculated for the given location
18
+ * (e.g. polar regions).
19
+ * @example
20
+ * import {isAssurBemlacha, Location} from '@hebcal/core';
21
+ * const loc = Location.lookup('Jerusalem')!;
22
+ * // Friday after sunset:
23
+ * isAssurBemlacha(new Date('2024-04-26T18:00:00Z'), loc, false); // true
24
+ * @param currentTime the moment to test (with hour/minute)
25
+ * @param location geographic location (also supplies Israel/Diaspora flag and tzid)
26
+ * @param useElevation include elevation when computing sunset
27
+ * @return `true` if *melacha* is prohibited, `false` if it is not
8
28
  */
9
29
  export declare function isAssurBemlacha(currentTime: Date, location: Location, useElevation: boolean): boolean;
@@ -29,11 +29,31 @@ function isTodayAssurBemelacha(dow, events) {
29
29
  return false;
30
30
  }
31
31
  /**
32
- * Utility method to determine if the date and time has a <em>melacha</em> (work) prohibition.
33
- * Although there are many opinions on the time of <em>tzais</em>, for simplicity
34
- * this function uses solar depression of 8.5 degrees.
32
+ * Returns `true` if the given moment (date + time) falls within a period
33
+ * when *melacha* (work) is prohibited i.e. Shabbat or a Yom Tov.
35
34
  *
36
- * @return `true` if <em>melacha</em> is prohibited or `false` if it is not.
35
+ * The Shabbat/Yom Tov window is taken to begin at sunset (shkiah) on the
36
+ * preceding day (Erev Shabbat / Erev Yom Tov / Yom Tov sheni) and to end
37
+ * at *tzais* (nightfall) on the day itself. *Tzais* is calculated using a
38
+ * solar depression of 8.5° for simplicity; consult a halachic authority
39
+ * for more stringent opinions.
40
+ *
41
+ * `useElevation` controls whether the location's elevation is taken into
42
+ * account when computing sunset (it has no effect on the degree-based
43
+ * tzais calculation). The Israel/Diaspora schedule comes from
44
+ * `location.getIsrael()`.
45
+ *
46
+ * Throws if sunset cannot be calculated for the given location
47
+ * (e.g. polar regions).
48
+ * @example
49
+ * import {isAssurBemlacha, Location} from '@hebcal/core';
50
+ * const loc = Location.lookup('Jerusalem')!;
51
+ * // Friday after sunset:
52
+ * isAssurBemlacha(new Date('2024-04-26T18:00:00Z'), loc, false); // true
53
+ * @param currentTime the moment to test (with hour/minute)
54
+ * @param location geographic location (also supplies Israel/Diaspora flag and tzid)
55
+ * @param useElevation include elevation when computing sunset
56
+ * @return `true` if *melacha* is prohibited, `false` if it is not
37
57
  */
38
58
  export function isAssurBemlacha(currentTime, location, useElevation) {
39
59
  const zmanim = new Zmanim(location, currentTime, useElevation);
@@ -1,10 +1,21 @@
1
1
  import { HDate } from '@hebcal/hdate';
2
2
  /**
3
- * Utility method to determine if the given date is during a mourning period.
3
+ * Returns `true` if the given date falls within a public period of communal
4
+ * mourning — specifically:
4
5
  *
5
- * This broad helper returns `true` during Sefirat HaOmer and Bein HaMetzarim.
6
- * It does not attempt to model minhag-specific exceptions within those periods.
6
+ * - **Sefirat HaOmer**: 16 Nisan through 5 Sivan (the 49 days of the Omer).
7
+ * - **Bein HaMetzarim** ("between the straits"): 17 Tammuz through 9 Av
8
+ * (10 Av when 9 Av is postponed because it falls on Shabbat).
7
9
  *
10
+ * This is a broad helper — it does not attempt to model minhag-specific
11
+ * exceptions within those periods (e.g. Lag BaOmer, Rosh Chodesh Iyar,
12
+ * the distinction between Sephardic and Ashkenazic customs on which
13
+ * portion of the Omer is observed as mourning, etc.).
14
+ * @example
15
+ * import {isAveilut, HDate, months} from '@hebcal/core';
16
+ * isAveilut(new HDate(20, months.NISAN, 5784)); // true (Omer)
17
+ * isAveilut(new HDate(25, months.TAMUZ, 5784)); // true (Three Weeks)
18
+ * isAveilut(new HDate(15, months.AV, 5784)); // false
8
19
  * @param date Hebrew Date, Gregorian date, or absolute R.D. day number
9
20
  * @return `true` if the date is during a mourning period
10
21
  */
@@ -23,11 +23,22 @@ function isBeinHaMetzarim(hd) {
23
23
  return abs >= begin && abs <= end;
24
24
  }
25
25
  /**
26
- * Utility method to determine if the given date is during a mourning period.
26
+ * Returns `true` if the given date falls within a public period of communal
27
+ * mourning — specifically:
27
28
  *
28
- * This broad helper returns `true` during Sefirat HaOmer and Bein HaMetzarim.
29
- * It does not attempt to model minhag-specific exceptions within those periods.
29
+ * - **Sefirat HaOmer**: 16 Nisan through 5 Sivan (the 49 days of the Omer).
30
+ * - **Bein HaMetzarim** ("between the straits"): 17 Tammuz through 9 Av
31
+ * (10 Av when 9 Av is postponed because it falls on Shabbat).
30
32
  *
33
+ * This is a broad helper — it does not attempt to model minhag-specific
34
+ * exceptions within those periods (e.g. Lag BaOmer, Rosh Chodesh Iyar,
35
+ * the distinction between Sephardic and Ashkenazic customs on which
36
+ * portion of the Omer is observed as mourning, etc.).
37
+ * @example
38
+ * import {isAveilut, HDate, months} from '@hebcal/core';
39
+ * isAveilut(new HDate(20, months.NISAN, 5784)); // true (Omer)
40
+ * isAveilut(new HDate(25, months.TAMUZ, 5784)); // true (Three Weeks)
41
+ * isAveilut(new HDate(15, months.AV, 5784)); // false
31
42
  * @param date Hebrew Date, Gregorian date, or absolute R.D. day number
32
43
  * @return `true` if the date is during a mourning period
33
44
  */
@@ -1,7 +1,19 @@
1
1
  import { HDate } from '@hebcal/hdate';
2
2
  /**
3
- * Utility method to determine if the given date is a fast day.
3
+ * Returns `true` if the given date is observed as a major or minor fast day.
4
4
  *
5
+ * Major fasts: Yom Kippur, Tish'a B'Av.
6
+ * Minor fasts: Tzom Gedaliah, Asara B'Tevet, Ta'anit Esther, Ta'anit
7
+ * Bechorot, Tzom Tammuz (plus BeHaB fasts when enabled).
8
+ *
9
+ * Erev Tish'a B'Av — even though the fast begins at sunset — is *not*
10
+ * counted here: only the actual fast day itself returns `true`.
11
+ * Postponed fasts return `true` on the actual observed date (e.g. when
12
+ * 17 Tammuz falls on Shabbat and is observed on the 18th).
13
+ * @example
14
+ * import {isFastDay, HDate, months} from '@hebcal/core';
15
+ * isFastDay(new HDate(10, months.TISHREI, 5784)); // true (Yom Kippur)
16
+ * isFastDay(new HDate(11, months.TISHREI, 5784)); // false
5
17
  * @param date Hebrew Date, Gregorian date, or absolute R.D. day number
6
18
  * @param il use the Israeli schedule for holidays
7
19
  * @return `true` if the date is a major or minor fast day
@@ -3,8 +3,20 @@ import { getHolidaysOnDate } from './holidays';
3
3
  const FAST_DAY = flags.MAJOR_FAST | flags.MINOR_FAST;
4
4
  const EREV = flags.EREV;
5
5
  /**
6
- * Utility method to determine if the given date is a fast day.
6
+ * Returns `true` if the given date is observed as a major or minor fast day.
7
7
  *
8
+ * Major fasts: Yom Kippur, Tish'a B'Av.
9
+ * Minor fasts: Tzom Gedaliah, Asara B'Tevet, Ta'anit Esther, Ta'anit
10
+ * Bechorot, Tzom Tammuz (plus BeHaB fasts when enabled).
11
+ *
12
+ * Erev Tish'a B'Av — even though the fast begins at sunset — is *not*
13
+ * counted here: only the actual fast day itself returns `true`.
14
+ * Postponed fasts return `true` on the actual observed date (e.g. when
15
+ * 17 Tammuz falls on Shabbat and is observed on the 18th).
16
+ * @example
17
+ * import {isFastDay, HDate, months} from '@hebcal/core';
18
+ * isFastDay(new HDate(10, months.TISHREI, 5784)); // true (Yom Kippur)
19
+ * isFastDay(new HDate(11, months.TISHREI, 5784)); // false
8
20
  * @param date Hebrew Date, Gregorian date, or absolute R.D. day number
9
21
  * @param il use the Israeli schedule for holidays
10
22
  * @return `true` if the date is a major or minor fast day
@@ -1,5 +1,29 @@
1
1
  import { GeoLocation } from '@hebcal/noaa';
2
- /** Class representing Location */
2
+ /**
3
+ * Class representing a geographic location for use with candle-lighting,
4
+ * havdalah, and zmanim calculations.
5
+ *
6
+ * Extends {@link GeoLocation} from `@hebcal/noaa` with Jewish-calendar
7
+ * specific data: an Israel/Diaspora flag, ISO country code, and an optional
8
+ * geographic identifier. Also provides {@link Location.lookup} for ~60
9
+ * built-in "classic" Hebcal cities.
10
+ *
11
+ * @example
12
+ * import {Location} from '@hebcal/core';
13
+ *
14
+ * // Create a location for a custom address
15
+ * const loc = new Location(
16
+ * 41.85003, // latitude
17
+ * -87.65005, // longitude
18
+ * false, // not in Israel
19
+ * 'America/Chicago',
20
+ * 'Chicago, Illinois, USA',
21
+ * 'US'
22
+ * );
23
+ *
24
+ * // Or look up a built-in classic city
25
+ * const tlv = Location.lookup('Tel Aviv');
26
+ */
3
27
  export declare class Location extends GeoLocation {
4
28
  private readonly il;
5
29
  private readonly cc?;
@@ -22,18 +46,54 @@ export declare class Location extends GeoLocation {
22
46
  * @param [elevation] - in meters (default `0`)
23
47
  */
24
48
  constructor(latitude: number, longitude: number, il: boolean, tzid: string, cityName?: string, countryCode?: string, geoid?: string | number, elevation?: number);
49
+ /**
50
+ * Returns `true` if this location is in Israel (uses the Israeli holiday
51
+ * and Torah-reading schedule), `false` for the Diaspora.
52
+ */
25
53
  getIsrael(): boolean;
54
+ /**
55
+ * Returns the full descriptive location name passed to the constructor,
56
+ * or `null` if no name was provided.
57
+ * @example
58
+ * Location.lookup('San Francisco')?.getName(); // 'San Francisco, California, USA'
59
+ */
26
60
  getName(): string | null;
27
61
  /**
28
- * Returns the location name, up to the first comma
62
+ * Returns the location name truncated at the first comma. Useful for
63
+ * compact display where only the city name is desired.
64
+ *
65
+ * Special-cased so that US locations of the form `"Washington, DC"` or
66
+ * `"Washington, D.C., ..."` keep the `DC` / `D.C.` suffix attached.
67
+ * @example
68
+ * Location.lookup('San Francisco')?.getShortName(); // 'San Francisco'
69
+ * Location.lookup('Washington DC')?.getShortName(); // 'Washington, DC'
29
70
  */
30
71
  getShortName(): string | null;
72
+ /**
73
+ * Returns the ISO 3166 alpha-2 country code (e.g. `"US"`, `"IL"`, `"FR"`)
74
+ * passed to the constructor, or `undefined` if none was provided.
75
+ */
31
76
  getCountryCode(): string | undefined;
77
+ /**
78
+ * Returns the Olson timezone identifier (e.g. `"America/Chicago"`).
79
+ * Alias for `getTimeZone()` from the parent `GeoLocation` class.
80
+ */
32
81
  getTzid(): string;
33
82
  /**
34
- * Gets a 24-hour time formatter (e.g. 07:41 or 20:03) for this location
83
+ * Returns a cached 24-hour `Intl.DateTimeFormat` (e.g. `07:41` or `20:03`)
84
+ * configured for this location's timezone. Formatters are memoized by
85
+ * timezone so repeated calls do not allocate.
86
+ * @example
87
+ * const loc = Location.lookup('Tel Aviv')!;
88
+ * const fmt = loc.getTimeFormatter();
89
+ * fmt.format(new Date()); // e.g. '18:42'
35
90
  */
36
91
  getTimeFormatter(): Intl.DateTimeFormat;
92
+ /**
93
+ * Returns the optional geographic identifier passed to the constructor
94
+ * (typically a GeoNames numeric ID or a US Zip Code string), or
95
+ * `undefined` if none was provided.
96
+ */
37
97
  getGeoId(): string | number | undefined;
38
98
  /**
39
99
  * Creates a location object from one of 60 "classic" Hebcal city names.
@@ -51,12 +111,31 @@ export declare class Location extends GeoLocation {
51
111
  * 'San Diego', 'San Francisco', 'Sao Paulo', 'Seattle', 'Sydney',
52
112
  * 'Tel Aviv', 'Tiberias', 'Toronto', 'Vancouver', 'White Plains',
53
113
  * 'Washington DC', 'Worcester'
54
- * @param name
114
+ *
115
+ * Lookups are case-insensitive. Returns `undefined` if the name is not
116
+ * recognized. The list can be extended with {@link Location.addLocation}.
117
+ * @example
118
+ * const loc = Location.lookup('San Francisco');
119
+ * console.log(loc?.getTzid()); // 'America/Los_Angeles'
120
+ * @param name case-insensitive classic city name
55
121
  */
56
122
  static lookup(name: string): Location | undefined;
123
+ /**
124
+ * Returns a JSON-serialized representation of this Location.
125
+ * Useful for debugging and structured logging.
126
+ */
57
127
  toString(): string;
58
128
  /**
59
- * Converts legacy Hebcal timezone to a standard Olson tzid.
129
+ * Converts a legacy Hebcal-style timezone (a numeric GMT offset plus a
130
+ * coarse DST region) to a standard IANA/Olson timezone ID.
131
+ *
132
+ * This exists to migrate data from older Hebcal versions that stored
133
+ * timezones as GMT offset + DST scheme rather than as a full tzid.
134
+ * @example
135
+ * Location.legacyTzToTzid(2, 'israel'); // 'Asia/Jerusalem'
136
+ * Location.legacyTzToTzid(0, 'eu'); // 'Europe/London'
137
+ * Location.legacyTzToTzid(0, 'none'); // 'UTC'
138
+ * Location.legacyTzToTzid(-5, 'none'); // 'Etc/GMT-5'
60
139
  * @param tz integer, GMT offset in hours
61
140
  * @param dst 'none', 'eu', 'usa', or 'israel'
62
141
  */
@@ -71,9 +150,18 @@ export declare class Location extends GeoLocation {
71
150
  */
72
151
  static getUsaTzid(state: string, tz: number, dst: string): string;
73
152
  /**
74
- * Adds a location name for `Location.lookup()` only if the name isn't
75
- * already being used. Returns `false` if the name is already taken
76
- * and `true` if successfully added.
153
+ * Registers a new named location with the built-in `Location.lookup()`
154
+ * registry. Names are stored case-insensitively. Returns `false` if a
155
+ * location with the same (lower-cased) name is already registered, and
156
+ * `true` if successfully added.
157
+ *
158
+ * Use this to extend the built-in set of ~60 classic Hebcal cities with
159
+ * your own custom locations.
160
+ * @example
161
+ * const tlv = new Location(32.0853, 34.7818, true,
162
+ * 'Asia/Tel_Aviv', 'My Office, Tel Aviv', 'IL');
163
+ * Location.addLocation('My Office', tlv); // true
164
+ * Location.lookup('my office')?.getTzid(); // 'Asia/Tel_Aviv'
77
165
  */
78
166
  static addLocation(cityName: string, location: Location): boolean;
79
167
  }