@hebcal/core 6.16.1 → 6.16.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 (66) hide show
  1. package/dist/bundle.js +288 -208
  2. package/dist/bundle.js.map +1 -1
  3. package/dist/bundle.min.js +5 -5
  4. package/dist/bundle.min.js.map +1 -1
  5. package/dist/esm/DailyLearning.js +1 -1
  6. package/dist/esm/HebrewDateEvent.js +1 -1
  7. package/dist/esm/HolidayEvent.js +1 -1
  8. package/dist/esm/KiddushLevanaEvent.js +3 -4
  9. package/dist/esm/KiddushLevanaEvent.js.map +1 -1
  10. package/dist/esm/MevarchimChodeshEvent.js +1 -1
  11. package/dist/esm/ParshaEvent.js +1 -1
  12. package/dist/esm/TimedEvent.js +1 -1
  13. package/dist/esm/YomKippurKatanEvent.js +1 -1
  14. package/dist/esm/ashkenazi.po.js +1 -1
  15. package/dist/esm/calendar.js +4 -4
  16. package/dist/esm/calendar.js.map +1 -1
  17. package/dist/esm/candles.js +4 -2
  18. package/dist/esm/candles.js.map +1 -1
  19. package/dist/esm/cities.json.js +1 -1
  20. package/dist/esm/event.js +1 -1
  21. package/dist/esm/getStartAndEnd.js +2 -2
  22. package/dist/esm/getStartAndEnd.js.map +1 -1
  23. package/dist/esm/hallel.js +1 -1
  24. package/dist/esm/he-x-NoNikud.po.js +1 -1
  25. package/dist/esm/he.po.js +1 -1
  26. package/dist/esm/hebcal.js +3 -6
  27. package/dist/esm/hebcal.js.map +1 -1
  28. package/dist/esm/holidays.d.ts +17 -0
  29. package/dist/esm/holidays.js +78 -21
  30. package/dist/esm/holidays.js.map +1 -1
  31. package/dist/esm/horizon.js +1 -1
  32. package/dist/esm/index.d.ts +1 -0
  33. package/dist/esm/index.js +2 -1
  34. package/dist/esm/index.js.map +1 -1
  35. package/dist/esm/isAssurBemlacha.js +7 -23
  36. package/dist/esm/isAssurBemlacha.js.map +1 -1
  37. package/dist/esm/isAveilut.js +1 -1
  38. package/dist/esm/isFastDay.js +1 -1
  39. package/dist/esm/isYomTov.d.ts +21 -0
  40. package/dist/esm/isYomTov.js +46 -0
  41. package/dist/esm/isYomTov.js.map +1 -0
  42. package/dist/esm/locale.js +1 -1
  43. package/dist/esm/location.js +3 -3
  44. package/dist/esm/location.js.map +1 -1
  45. package/dist/esm/modern.js +1 -1
  46. package/dist/esm/molad.js +1 -1
  47. package/dist/esm/moladBase.js +1 -1
  48. package/dist/esm/moladDate.js +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 +2 -2
  56. package/dist/esm/reformatTimeStr.js.map +1 -1
  57. package/dist/esm/sedra.js +2 -2
  58. package/dist/esm/sedra.js.map +1 -1
  59. package/dist/esm/sefira.json.js +1 -1
  60. package/dist/esm/staticHolidays.js +1 -1
  61. package/dist/esm/string.js +1 -1
  62. package/dist/esm/tachanun.js +1 -1
  63. package/dist/esm/zenith.js +1 -1
  64. package/dist/esm/zmanim.js +4 -4
  65. package/dist/esm/zmanim.js.map +1 -1
  66. package/package.json +7 -7
package/dist/bundle.js CHANGED
@@ -1,9 +1,9 @@
1
- /*! @hebcal/core v6.16.1, distributed under GPLv2 or later https://www.gnu.org/licenses/gpl-2.0.txt */
1
+ /*! @hebcal/core v6.16.3, distributed under GPLv2 or later https://www.gnu.org/licenses/gpl-2.0.txt */
2
2
  var hebcal = (function (exports) {
3
3
  'use strict';
4
4
 
5
5
  /** DO NOT EDIT THIS AUTO-GENERATED FILE! */
6
- const version = '6.16.1';
6
+ const version = '6.16.3';
7
7
 
8
8
  /*! @hebcal/hdate v0.23.1, distributed under GPLv2 or later https://www.gnu.org/licenses/gpl-2.0.txt */
9
9
  /**
@@ -9161,11 +9161,11 @@ class Location extends GeoLocation {
9161
9161
  * @param [elevation] - in meters (default `0`)
9162
9162
  */
9163
9163
  constructor(latitude, longitude, il, tzid, cityName, countryCode, geoid, elevation) {
9164
- const lat = typeof latitude === 'number' ? latitude : parseFloat(latitude);
9164
+ const lat = typeof latitude === 'number' ? latitude : Number.parseFloat(latitude);
9165
9165
  if (Number.isNaN(lat) || lat < -90 || lat > 90) {
9166
9166
  throw new RangeError(`Latitude ${latitude} out of range [-90,90]`);
9167
9167
  }
9168
- const long = typeof longitude === 'number' ? longitude : parseFloat(longitude);
9168
+ const long = typeof longitude === 'number' ? longitude : Number.parseFloat(longitude);
9169
9169
  if (Number.isNaN(long) || long < -180 || long > 180) {
9170
9170
  throw new RangeError(`Longitude ${longitude} out of range [-180,180]`);
9171
9171
  }
@@ -9439,7 +9439,7 @@ function reformatTimeStr(timeStr, suffix, options) {
9439
9439
  return timeStr;
9440
9440
  }
9441
9441
  const hm = timeStr.split(':');
9442
- let hour = parseInt(hm[0], 10);
9442
+ let hour = Number.parseInt(hm[0], 10);
9443
9443
  if (hour < 12 && suffix) {
9444
9444
  suffix = suffix.replace('p', 'a').replace('P', 'A');
9445
9445
  if (hour === 0) {
@@ -10748,7 +10748,7 @@ class Zmanim {
10748
10748
  // Evaluate the low end first so polar day/night (NaN time) is caught at once.
10749
10749
  const tLo = timeAt(aLo);
10750
10750
  if (Number.isNaN(tLo)) {
10751
- return millisToDate(NaN);
10751
+ return millisToDate(Number.NaN);
10752
10752
  }
10753
10753
  if (g(aLo) >= 0) {
10754
10754
  return millisToDate(tLo);
@@ -10756,7 +10756,7 @@ class Zmanim {
10756
10756
  let prevA = aLo;
10757
10757
  for (let a = aLo + step; a <= aHi + 1e-9; a += step) {
10758
10758
  if (Number.isNaN(timeAt(a))) {
10759
- return millisToDate(NaN);
10759
+ return millisToDate(Number.NaN);
10760
10760
  }
10761
10761
  if (g(a) >= 0) {
10762
10762
  // Crossing in (prevA, a): bisect the altitude bracket to 0.0005°.
@@ -10775,7 +10775,7 @@ class Zmanim {
10775
10775
  }
10776
10776
  prevA = a;
10777
10777
  }
10778
- return millisToDate(NaN);
10778
+ return millisToDate(Number.NaN);
10779
10779
  }
10780
10780
  /**
10781
10781
  * Rabbeinu Tam holds that bein hashmashos is a specific time
@@ -11318,7 +11318,153 @@ class Zmanim {
11318
11318
  }
11319
11319
  }
11320
11320
 
11321
- const { NISAN: NISAN$4, IYYAR: IYYAR$2, SIVAN: SIVAN$2, AV: AV$2, ELUL: ELUL$1, TISHREI: TISHREI$2, SHVAT, ADAR_II: ADAR_II$1 } = months;
11321
+ /**
11322
+ * Returns `true` if the given Hebrew date is a _Yom Tov_ with a _melacha_
11323
+ * (work) prohibition: Rosh Hashana, Yom Kippur, the first and last days of
11324
+ * Sukkot/Pesach, Shmini Atzeret, Simchat Torah (Diaspora) and Shavuot.
11325
+ *
11326
+ * These are exactly the days that carry the `CHAG` flag. Shabbat is not
11327
+ * considered, and neither is Chol HaMoed.
11328
+ *
11329
+ * The result is computed directly from the Hebrew month and day,
11330
+ * without generating holiday events.
11331
+ * @example
11332
+ * import {isYomTov, HDate, months} from '@hebcal/core';
11333
+ * isYomTov(new HDate(10, months.TISHREI, 5785), false); // true (Yom Kippur)
11334
+ * isYomTov(new HDate(16, months.NISAN, 5784), false); // true (Pesach II)
11335
+ * isYomTov(new HDate(16, months.NISAN, 5784), true); // false (Chol HaMoed)
11336
+ * isYomTov(new HDate(25, months.KISLEV, 5784), false); // false (Chanukah)
11337
+ * @param hdate Hebrew date to test
11338
+ * @param il use the Israeli holiday schedule
11339
+ */
11340
+ function isYomTov(hdate, il) {
11341
+ const dd = hdate.getDate();
11342
+ switch (hdate.getMonth()) {
11343
+ case months.TISHREI:
11344
+ return (dd === 1 || // Rosh Hashana I
11345
+ dd === 2 || // Rosh Hashana II
11346
+ dd === 10 || // Yom Kippur
11347
+ dd === 15 || // Sukkot I
11348
+ dd === 22 || // Shmini Atzeret
11349
+ (!il && (dd === 16 || dd === 23)) // Sukkot II, Simchat Torah
11350
+ );
11351
+ case months.NISAN:
11352
+ // Pesach I and VII, plus Pesach II and VIII in the Diaspora
11353
+ return dd === 15 || dd === 21 || (!il && (dd === 16 || dd === 22));
11354
+ case months.SIVAN:
11355
+ // Shavuot, plus a second day in the Diaspora
11356
+ return dd === 6 || (!il && dd === 7);
11357
+ default:
11358
+ return false;
11359
+ }
11360
+ }
11361
+
11362
+ /**
11363
+ * Returns `true` if the given moment (date + time) falls within a period
11364
+ * when *melacha* (work) is prohibited — i.e. Shabbat or a Yom Tov.
11365
+ *
11366
+ * The Shabbat/Yom Tov window is taken to begin at sunset (shkiah) on the
11367
+ * preceding day (Erev Shabbat / Erev Yom Tov / Yom Tov sheni) and to end
11368
+ * at *tzais* (nightfall) on the day itself. *Tzais* is calculated using a
11369
+ * solar depression of 8.5° for simplicity; consult a halachic authority
11370
+ * for more stringent opinions.
11371
+ *
11372
+ * `useElevation` controls whether the location's elevation is taken into
11373
+ * account when computing sunset (it has no effect on the degree-based
11374
+ * tzais calculation). The Israel/Diaspora schedule comes from
11375
+ * `location.getIsrael()`.
11376
+ *
11377
+ * Throws if sunset cannot be calculated for the given location
11378
+ * (e.g. polar regions).
11379
+ * @example
11380
+ * import {isAssurBemlacha, Location} from '@hebcal/core';
11381
+ * const loc = Location.lookup('Jerusalem')!;
11382
+ * // Friday after sunset:
11383
+ * isAssurBemlacha(new Date('2024-04-26T18:00:00Z'), loc, false); // true
11384
+ * @param currentTime the moment to test (with hour/minute)
11385
+ * @param location geographic location (also supplies Israel/Diaspora flag and tzid)
11386
+ * @param useElevation include elevation when computing sunset
11387
+ * @return `true` if *melacha* is prohibited, `false` if it is not
11388
+ */
11389
+ function isAssurBemlacha(currentTime, location, useElevation) {
11390
+ // Determine the calendar date in the location's timezone, not the
11391
+ // timezone of the computer running this code. Otherwise the day-of-week,
11392
+ // Hebrew date and sunset/tzais times would depend on the machine's
11393
+ // local timezone, giving different (incorrect) results near midnight.
11394
+ const isoDate = getPseudoISO(location.getTzid(), currentTime);
11395
+ const year = Number.parseInt(isoDate.substring(0, 4), 10);
11396
+ const month = Number.parseInt(isoDate.substring(5, 7), 10);
11397
+ const day = Number.parseInt(isoDate.substring(8, 10), 10);
11398
+ const hd = new HDate(new Date(year, month - 1, day));
11399
+ const zmanim = new Zmanim(location, hd, useElevation);
11400
+ // erev shabbos, YT or YT sheni and after shkiah
11401
+ const sunset = zmanim.sunset();
11402
+ const sunsetMillis = sunset.getTime();
11403
+ if (Number.isNaN(sunsetMillis)) {
11404
+ throw new Error('Could not determine sunset');
11405
+ }
11406
+ // erev shabbos, YT or YT sheni and after shkiah
11407
+ const il = location.getIsrael();
11408
+ const currentMillis = currentTime.getTime();
11409
+ const dow = hd.getDay();
11410
+ if (currentMillis >= sunsetMillis && (dow === 5 || isYomTov(hd.next(), il))) {
11411
+ return true;
11412
+ }
11413
+ // is shabbos or YT and it is before tzais
11414
+ if (dow === 6 || isYomTov(hd, il)) {
11415
+ const tzais = zmanim.tzeit();
11416
+ const tzaisMillis = tzais.getTime();
11417
+ return currentMillis <= tzaisMillis;
11418
+ }
11419
+ return false;
11420
+ }
11421
+
11422
+ const { NISAN: NISAN$4, SIVAN: SIVAN$2, TAMUZ: TAMUZ$1, AV: AV$2 } = months;
11423
+ const SAT$2 = 6;
11424
+ function getHDate(date) {
11425
+ return HDate.isHDate(date) ? date : new HDate(date);
11426
+ }
11427
+ function isSefiratHaOmer(hd) {
11428
+ const hyear = hd.getFullYear();
11429
+ const beginOmer = new HDate(16, NISAN$4, hyear).abs();
11430
+ const endOmer = new HDate(5, SIVAN$2, hyear).abs();
11431
+ const abs = hd.abs();
11432
+ return abs >= beginOmer && abs <= endOmer;
11433
+ }
11434
+ function isBeinHaMetzarim(hd) {
11435
+ const hyear = hd.getFullYear();
11436
+ const begin = new HDate(17, TAMUZ$1, hyear).abs();
11437
+ const tishaBav = new HDate(9, AV$2, hyear);
11438
+ const end = tishaBav.getDay() === SAT$2 ? new HDate(10, AV$2, hyear).abs() : tishaBav.abs();
11439
+ const abs = hd.abs();
11440
+ return abs >= begin && abs <= end;
11441
+ }
11442
+ /**
11443
+ * Returns `true` if the given date falls within a public period of communal
11444
+ * mourning — specifically:
11445
+ *
11446
+ * - **Sefirat HaOmer**: 16 Nisan through 5 Sivan (the 49 days of the Omer).
11447
+ * - **Bein HaMetzarim** ("between the straits"): 17 Tammuz through 9 Av
11448
+ * (10 Av when 9 Av is postponed because it falls on Shabbat).
11449
+ *
11450
+ * This is a broad helper — it does not attempt to model minhag-specific
11451
+ * exceptions within those periods (e.g. Lag BaOmer, Rosh Chodesh Iyar,
11452
+ * the distinction between Sephardic and Ashkenazic customs on which
11453
+ * portion of the Omer is observed as mourning, etc.).
11454
+ * @example
11455
+ * import {isAveilut, HDate, months} from '@hebcal/core';
11456
+ * isAveilut(new HDate(20, months.NISAN, 5784)); // true (Omer)
11457
+ * isAveilut(new HDate(25, months.TAMUZ, 5784)); // true (Three Weeks)
11458
+ * isAveilut(new HDate(15, months.AV, 5784)); // false
11459
+ * @param date Hebrew Date, Gregorian date, or absolute R.D. day number
11460
+ * @return `true` if the date is during a mourning period
11461
+ */
11462
+ function isAveilut(date) {
11463
+ const hd = getHDate(date);
11464
+ return isSefiratHaOmer(hd) || isBeinHaMetzarim(hd);
11465
+ }
11466
+
11467
+ const { NISAN: NISAN$3, IYYAR: IYYAR$2, SIVAN: SIVAN$1, AV: AV$1, ELUL: ELUL$1, TISHREI: TISHREI$2, SHVAT, ADAR_II: ADAR_II$1 } = months;
11322
11468
  const { CHAG: CHAG$1, LIGHT_CANDLES: LIGHT_CANDLES$2, YOM_TOV_ENDS: YOM_TOV_ENDS$1, CHUL_ONLY: CHUL_ONLY$1, IL_ONLY: IL_ONLY$2, LIGHT_CANDLES_TZEIS: LIGHT_CANDLES_TZEIS$3, MAJOR_FAST: MAJOR_FAST$2, MINOR_HOLIDAY: MINOR_HOLIDAY$2, EREV: EREV$2, CHOL_HAMOED: CHOL_HAMOED$1, } = flags;
11323
11469
  /**
11324
11470
  * Transliterated names of holidays, used by `Event.getDesc()`
@@ -11579,82 +11725,82 @@ const staticHolidays = [
11579
11725
  holiday(ADAR_II$1, 14, d.PURIM, MINOR_HOLIDAY$2, { emoji: emojiPurim }),
11580
11726
  holiday(ADAR_II$1, 15, d.SHUSHAN_PURIM, MINOR_HOLIDAY$2, { emoji: emojiPurim }),
11581
11727
  // Pesach Israel
11582
- holiday(NISAN$4, 14, d.EREV_PESACH, IL_ONLY$2 | EREV$2 | LIGHT_CANDLES$2, {
11728
+ holiday(NISAN$3, 14, d.EREV_PESACH, IL_ONLY$2 | EREV$2 | LIGHT_CANDLES$2, {
11583
11729
  emoji: emojiErevPesach,
11584
11730
  }),
11585
- holiday(NISAN$4, 15, d.PESACH_I, IL_ONLY$2 | CHAG$1 | YOM_TOV_ENDS$1, {
11731
+ holiday(NISAN$3, 15, d.PESACH_I, IL_ONLY$2 | CHAG$1 | YOM_TOV_ENDS$1, {
11586
11732
  emoji: emojiPesach,
11587
11733
  }),
11588
- holiday(NISAN$4, 16, d.PESACH_II_CHM, IL_ONLY$2 | CHOL_HAMOED$1, {
11734
+ holiday(NISAN$3, 16, d.PESACH_II_CHM, IL_ONLY$2 | CHOL_HAMOED$1, {
11589
11735
  chmDay: 1,
11590
11736
  emoji: emojiPesach,
11591
11737
  }),
11592
- holiday(NISAN$4, 17, d.PESACH_III_CHM, IL_ONLY$2 | CHOL_HAMOED$1, {
11738
+ holiday(NISAN$3, 17, d.PESACH_III_CHM, IL_ONLY$2 | CHOL_HAMOED$1, {
11593
11739
  chmDay: 2,
11594
11740
  emoji: emojiPesach,
11595
11741
  }),
11596
- holiday(NISAN$4, 18, d.PESACH_IV_CHM, IL_ONLY$2 | CHOL_HAMOED$1, {
11742
+ holiday(NISAN$3, 18, d.PESACH_IV_CHM, IL_ONLY$2 | CHOL_HAMOED$1, {
11597
11743
  chmDay: 3,
11598
11744
  emoji: emojiPesach,
11599
11745
  }),
11600
- holiday(NISAN$4, 19, d.PESACH_V_CHM, IL_ONLY$2 | CHOL_HAMOED$1, {
11746
+ holiday(NISAN$3, 19, d.PESACH_V_CHM, IL_ONLY$2 | CHOL_HAMOED$1, {
11601
11747
  chmDay: 4,
11602
11748
  emoji: emojiPesach,
11603
11749
  }),
11604
- holiday(NISAN$4, 20, d.PESACH_VI_CHM, IL_ONLY$2 | CHOL_HAMOED$1 | LIGHT_CANDLES$2, {
11750
+ holiday(NISAN$3, 20, d.PESACH_VI_CHM, IL_ONLY$2 | CHOL_HAMOED$1 | LIGHT_CANDLES$2, {
11605
11751
  chmDay: 5,
11606
11752
  emoji: emojiPesach,
11607
11753
  }),
11608
- holiday(NISAN$4, 21, d.PESACH_VII, IL_ONLY$2 | CHAG$1 | YOM_TOV_ENDS$1, {
11754
+ holiday(NISAN$3, 21, d.PESACH_VII, IL_ONLY$2 | CHAG$1 | YOM_TOV_ENDS$1, {
11609
11755
  emoji: emojiPesach,
11610
11756
  }),
11611
11757
  // Pesach chutz l'aretz
11612
- holiday(NISAN$4, 14, d.EREV_PESACH, CHUL_ONLY$1 | EREV$2 | LIGHT_CANDLES$2, {
11758
+ holiday(NISAN$3, 14, d.EREV_PESACH, CHUL_ONLY$1 | EREV$2 | LIGHT_CANDLES$2, {
11613
11759
  emoji: emojiErevPesach,
11614
11760
  }),
11615
- holiday(NISAN$4, 15, d.PESACH_I, CHUL_ONLY$1 | CHAG$1 | LIGHT_CANDLES_TZEIS$3, {
11761
+ holiday(NISAN$3, 15, d.PESACH_I, CHUL_ONLY$1 | CHAG$1 | LIGHT_CANDLES_TZEIS$3, {
11616
11762
  emoji: emojiErevPesach,
11617
11763
  }),
11618
- holiday(NISAN$4, 16, d.PESACH_II, CHUL_ONLY$1 | CHAG$1 | YOM_TOV_ENDS$1, {
11764
+ holiday(NISAN$3, 16, d.PESACH_II, CHUL_ONLY$1 | CHAG$1 | YOM_TOV_ENDS$1, {
11619
11765
  emoji: emojiPesach,
11620
11766
  }),
11621
- holiday(NISAN$4, 17, d.PESACH_III_CHM, CHUL_ONLY$1 | CHOL_HAMOED$1, {
11767
+ holiday(NISAN$3, 17, d.PESACH_III_CHM, CHUL_ONLY$1 | CHOL_HAMOED$1, {
11622
11768
  chmDay: 1,
11623
11769
  emoji: emojiPesach,
11624
11770
  }),
11625
- holiday(NISAN$4, 18, d.PESACH_IV_CHM, CHUL_ONLY$1 | CHOL_HAMOED$1, {
11771
+ holiday(NISAN$3, 18, d.PESACH_IV_CHM, CHUL_ONLY$1 | CHOL_HAMOED$1, {
11626
11772
  chmDay: 2,
11627
11773
  emoji: emojiPesach,
11628
11774
  }),
11629
- holiday(NISAN$4, 19, d.PESACH_V_CHM, CHUL_ONLY$1 | CHOL_HAMOED$1, {
11775
+ holiday(NISAN$3, 19, d.PESACH_V_CHM, CHUL_ONLY$1 | CHOL_HAMOED$1, {
11630
11776
  chmDay: 3,
11631
11777
  emoji: emojiPesach,
11632
11778
  }),
11633
- holiday(NISAN$4, 20, d.PESACH_VI_CHM, CHUL_ONLY$1 | CHOL_HAMOED$1 | LIGHT_CANDLES$2, {
11779
+ holiday(NISAN$3, 20, d.PESACH_VI_CHM, CHUL_ONLY$1 | CHOL_HAMOED$1 | LIGHT_CANDLES$2, {
11634
11780
  chmDay: 4,
11635
11781
  emoji: emojiPesach,
11636
11782
  }),
11637
- holiday(NISAN$4, 21, d.PESACH_VII, CHUL_ONLY$1 | CHAG$1 | LIGHT_CANDLES_TZEIS$3, {
11783
+ holiday(NISAN$3, 21, d.PESACH_VII, CHUL_ONLY$1 | CHAG$1 | LIGHT_CANDLES_TZEIS$3, {
11638
11784
  emoji: emojiPesach,
11639
11785
  }),
11640
- holiday(NISAN$4, 22, d.PESACH_VIII, CHUL_ONLY$1 | CHAG$1 | YOM_TOV_ENDS$1, {
11786
+ holiday(NISAN$3, 22, d.PESACH_VIII, CHUL_ONLY$1 | CHAG$1 | YOM_TOV_ENDS$1, {
11641
11787
  emoji: emojiPesach,
11642
11788
  }),
11643
11789
  holiday(IYYAR$2, 14, d.PESACH_SHENI, MINOR_HOLIDAY$2),
11644
11790
  holiday(IYYAR$2, 18, d.LAG_BAOMER, MINOR_HOLIDAY$2, { emoji: '🔥' }),
11645
- holiday(SIVAN$2, 5, d.EREV_SHAVUOT, EREV$2 | LIGHT_CANDLES$2, {
11791
+ holiday(SIVAN$1, 5, d.EREV_SHAVUOT, EREV$2 | LIGHT_CANDLES$2, {
11646
11792
  emoji: emojiShavuot,
11647
11793
  }),
11648
- holiday(SIVAN$2, 6, d.SHAVUOT, IL_ONLY$2 | CHAG$1 | YOM_TOV_ENDS$1, {
11794
+ holiday(SIVAN$1, 6, d.SHAVUOT, IL_ONLY$2 | CHAG$1 | YOM_TOV_ENDS$1, {
11649
11795
  emoji: emojiShavuot,
11650
11796
  }),
11651
- holiday(SIVAN$2, 6, d.SHAVUOT_I, CHUL_ONLY$1 | CHAG$1 | LIGHT_CANDLES_TZEIS$3, {
11797
+ holiday(SIVAN$1, 6, d.SHAVUOT_I, CHUL_ONLY$1 | CHAG$1 | LIGHT_CANDLES_TZEIS$3, {
11652
11798
  emoji: emojiShavuot,
11653
11799
  }),
11654
- holiday(SIVAN$2, 7, d.SHAVUOT_II, CHUL_ONLY$1 | CHAG$1 | YOM_TOV_ENDS$1, {
11800
+ holiday(SIVAN$1, 7, d.SHAVUOT_II, CHUL_ONLY$1 | CHAG$1 | YOM_TOV_ENDS$1, {
11655
11801
  emoji: emojiShavuot,
11656
11802
  }),
11657
- holiday(AV$2, 15, d.TU_BAV, MINOR_HOLIDAY$2, { emoji: '❤️' }),
11803
+ holiday(AV$1, 15, d.TU_BAV, MINOR_HOLIDAY$2, { emoji: '❤️' }),
11658
11804
  holiday(ELUL$1, 1, d.ROSH_HASHANA_LABEHEMOT, MINOR_HOLIDAY$2, { emoji: '🐑' }),
11659
11805
  holiday(ELUL$1, 29, d.EREV_ROSH_HASHANA, EREV$2 | LIGHT_CANDLES$2, {
11660
11806
  emoji: emojiRoshHashana,
@@ -11894,7 +12040,7 @@ var Day;
11894
12040
  Day[Day["FRI"] = 5] = "FRI";
11895
12041
  Day[Day["SAT"] = 6] = "SAT";
11896
12042
  })(Day || (Day = {}));
11897
- const { NISAN: NISAN$3, IYYAR: IYYAR$1, CHESHVAN: CHESHVAN$1 } = months;
12043
+ const { NISAN: NISAN$2, IYYAR: IYYAR$1, CHESHVAN: CHESHVAN$1 } = months;
11898
12044
  /**
11899
12045
  * Yom HaShoah first observed in 1951.
11900
12046
  * When the actual date of Yom Hashoah falls on a Friday, the
@@ -11907,12 +12053,12 @@ function dateYomHaShoah(year) {
11907
12053
  if (year < 5711) {
11908
12054
  return null;
11909
12055
  }
11910
- let nisan27dt = new HDate(27, NISAN$3, year);
12056
+ let nisan27dt = new HDate(27, NISAN$2, year);
11911
12057
  if (nisan27dt.getDay() === Day.FRI) {
11912
- nisan27dt = new HDate(26, NISAN$3, year);
12058
+ nisan27dt = new HDate(26, NISAN$2, year);
11913
12059
  }
11914
12060
  else if (nisan27dt.getDay() === Day.SUN) {
11915
- nisan27dt = new HDate(28, NISAN$3, year);
12061
+ nisan27dt = new HDate(28, NISAN$2, year);
11916
12062
  }
11917
12063
  return nisan27dt;
11918
12064
  }
@@ -11925,7 +12071,7 @@ function dateYomHaZikaron(year) {
11925
12071
  return null;
11926
12072
  }
11927
12073
  let day;
11928
- const pesach = new HDate(15, NISAN$3, year);
12074
+ const pesach = new HDate(15, NISAN$2, year);
11929
12075
  const pdow = pesach.getDay();
11930
12076
  if (pdow === Day.SUN) {
11931
12077
  day = 2;
@@ -12007,7 +12153,7 @@ const staticModernHolidays = [
12007
12153
  suppressEmoji: true,
12008
12154
  postpone: 'friSatToThu',
12009
12155
  },
12010
- { firstYear: 5777, mm: NISAN$3, dd: 10, desc: holidayDesc.YOM_HAALIYAH, chul: true },
12156
+ { firstYear: 5777, mm: NISAN$2, dd: 10, desc: holidayDesc.YOM_HAALIYAH, chul: true },
12011
12157
  {
12012
12158
  firstYear: 5777,
12013
12159
  mm: CHESHVAN$1,
@@ -12520,7 +12666,7 @@ const parshiot = [
12520
12666
  * date on or after Rosh Hashana of `year` (whose R.D. day is `rh`)
12521
12667
  */
12522
12668
  function toAbsInYear(hd, rh, year) {
12523
- const abs = typeof hd === 'number' ? hd : HDate.isHDate(hd) ? hd.abs() : NaN;
12669
+ const abs = typeof hd === 'number' ? hd : HDate.isHDate(hd) ? hd.abs() : Number.NaN;
12524
12670
  if (Number.isNaN(abs)) {
12525
12671
  throw new TypeError(`Bad date argument: ${hd}`);
12526
12672
  }
@@ -12889,10 +13035,24 @@ class YomKippurKatanEvent extends HolidayEvent {
12889
13035
  * @param [il] use the Israeli schedule for holidays
12890
13036
  */
12891
13037
  function getHolidaysOnDate(date, il) {
12892
- const hd = HDate.isHDate(date) ? date : new HDate(date);
12893
- const hdStr = hd.toString();
12894
- const yearMap = getHolidaysForYear_(hd.getFullYear());
12895
- const events = yearMap.get(hdStr);
13038
+ let abs;
13039
+ let entry;
13040
+ const last = lastEntry;
13041
+ if (typeof date === 'number' &&
13042
+ last !== undefined &&
13043
+ date >= last.startAbs &&
13044
+ date <= last.endAbs) {
13045
+ // Callers often walk day by day; skip the R.D. → Hebrew date
13046
+ // conversion while the date stays within the most recently used year.
13047
+ abs = date;
13048
+ entry = last;
13049
+ }
13050
+ else {
13051
+ const hd = HDate.isHDate(date) ? date : new HDate(date);
13052
+ abs = hd.abs();
13053
+ entry = getYearEntry(hd.getFullYear());
13054
+ }
13055
+ const events = entry.map.get(abs);
12896
13056
  // if il isn't a boolean return both diaspora + IL for day
12897
13057
  if (il === undefined || events === undefined) {
12898
13058
  return events;
@@ -12904,12 +13064,15 @@ const SUN = 0;
12904
13064
  const TUE = 2;
12905
13065
  const THU = 4;
12906
13066
  const FRI$1 = 5;
12907
- const SAT$2 = 6;
12908
- const { NISAN: NISAN$2, IYYAR, TAMUZ: TAMUZ$1, AV: AV$1, TISHREI: TISHREI$1, CHESHVAN, KISLEV, TEVET, ADAR_I, ADAR_II } = months;
13067
+ const SAT$1 = 6;
13068
+ const { NISAN: NISAN$1, IYYAR, TAMUZ, AV, TISHREI: TISHREI$1, CHESHVAN, KISLEV, TEVET, ADAR_I, ADAR_II } = months;
12909
13069
  const yearCache = new QuickLRU({ maxSize: 120 });
13070
+ /** Most recently used year, so day-by-day callers skip the LRU lookup */
13071
+ let lastEntry;
13072
+ const stringMapCache = new WeakMap();
12910
13073
  function addToMap(map, ...events) {
12911
13074
  for (const ev of events) {
12912
- const key = ev.date.toString();
13075
+ const key = ev.date.abs();
12913
13076
  const arr = map.get(key);
12914
13077
  if (arr !== undefined) {
12915
13078
  arr.push(ev);
@@ -13005,7 +13168,7 @@ function addTishreiHolidays(map, year, RH) {
13005
13168
  const tzomGedaliahDay = RH.getDay() === THU ? 4 : 3;
13006
13169
  addToMap(map, new HolidayEvent(new HDate(tzomGedaliahDay, TISHREI$1, year), holidayDesc.TZOM_GEDALIAH, MINOR_FAST$1),
13007
13170
  // first SAT after RH
13008
- new HolidayEvent(new HDate(HDate.dayOnOrBefore(SAT$2, 7 + RH.abs())), holidayDesc.SHABBAT_SHUVA, SPECIAL_SHABBAT$1));
13171
+ new HolidayEvent(new HDate(HDate.dayOnOrBefore(SAT$1, 7 + RH.abs())), holidayDesc.SHABBAT_SHUVA, SPECIAL_SHABBAT$1));
13009
13172
  }
13010
13173
  function addChanukahAndTevet(map, year) {
13011
13174
  const rchTevet = HDate.shortKislev(year)
@@ -13022,15 +13185,15 @@ function addChanukahAndTevet(map, year) {
13022
13185
  }
13023
13186
  function addPesachSeasonHolidays(map, year, pesach) {
13024
13187
  const pesachAbs = pesach.abs();
13025
- const haChodeshAbs = HDate.dayOnOrBefore(SAT$2, pesachAbs - 14);
13026
- addToMap(map, new HolidayEvent(new HDate(HDate.dayOnOrBefore(SAT$2, pesachAbs - 43)), holidayDesc.SHABBAT_SHEKALIM, SPECIAL_SHABBAT$1), new HolidayEvent(new HDate(HDate.dayOnOrBefore(SAT$2, pesachAbs - 30)), holidayDesc.SHABBAT_ZACHOR, SPECIAL_SHABBAT$1), new HolidayEvent(new HDate(pesachAbs - (pesach.getDay() === TUE ? 33 : 31)), holidayDesc.TAANIT_ESTHER, MINOR_FAST$1), new HolidayEvent(new HDate(haChodeshAbs - 7), holidayDesc.SHABBAT_PARAH, SPECIAL_SHABBAT$1), new HolidayEvent(new HDate(haChodeshAbs), holidayDesc.SHABBAT_HACHODESH, SPECIAL_SHABBAT$1), new HolidayEvent(new HDate(HDate.dayOnOrBefore(SAT$2, pesachAbs - 1)), holidayDesc.SHABBAT_HAGADOL, SPECIAL_SHABBAT$1), new HolidayEvent(
13188
+ const haChodeshAbs = HDate.dayOnOrBefore(SAT$1, pesachAbs - 14);
13189
+ addToMap(map, new HolidayEvent(new HDate(HDate.dayOnOrBefore(SAT$1, pesachAbs - 43)), holidayDesc.SHABBAT_SHEKALIM, SPECIAL_SHABBAT$1), new HolidayEvent(new HDate(HDate.dayOnOrBefore(SAT$1, pesachAbs - 30)), holidayDesc.SHABBAT_ZACHOR, SPECIAL_SHABBAT$1), new HolidayEvent(new HDate(pesachAbs - (pesach.getDay() === TUE ? 33 : 31)), holidayDesc.TAANIT_ESTHER, MINOR_FAST$1), new HolidayEvent(new HDate(haChodeshAbs - 7), holidayDesc.SHABBAT_PARAH, SPECIAL_SHABBAT$1), new HolidayEvent(new HDate(haChodeshAbs), holidayDesc.SHABBAT_HACHODESH, SPECIAL_SHABBAT$1), new HolidayEvent(new HDate(HDate.dayOnOrBefore(SAT$1, pesachAbs - 1)), holidayDesc.SHABBAT_HAGADOL, SPECIAL_SHABBAT$1), new HolidayEvent(
13027
13190
  // if the fast falls on Shabbat, move to Thursday
13028
- pesach.prev().getDay() === SAT$2
13191
+ pesach.prev().getDay() === SAT$1
13029
13192
  ? pesach.onOrBefore(THU)
13030
- : new HDate(14, NISAN$2, year), holidayDesc.TAANIT_BECHOROT, MINOR_FAST$1));
13193
+ : new HDate(14, NISAN$1, year), holidayDesc.TAANIT_BECHOROT, MINOR_FAST$1));
13031
13194
  }
13032
13195
  function addLeilSelichot(map, year) {
13033
- addToMap(map, new HolidayEvent(new HDate(HDate.dayOnOrBefore(SAT$2, new HDate(1, TISHREI$1, year + 1).abs() - 4)), holidayDesc.LEIL_SELICHOT, MINOR_HOLIDAY$1, { emoji: '🕍' }));
13196
+ addToMap(map, new HolidayEvent(new HDate(HDate.dayOnOrBefore(SAT$1, new HDate(1, TISHREI$1, year + 1).abs() - 4)), holidayDesc.LEIL_SELICHOT, MINOR_HOLIDAY$1, { emoji: '🕍' }));
13034
13197
  }
13035
13198
  function addPurimVariants(map, year, pesach) {
13036
13199
  if (pesach.getDay() === SUN) {
@@ -13041,26 +13204,26 @@ function addPurimVariants(map, year, pesach) {
13041
13204
  }
13042
13205
  }
13043
13206
  function addSummerFasts(map, year) {
13044
- let tamuz17 = new HDate(17, TAMUZ$1, year);
13207
+ let tamuz17 = new HDate(17, TAMUZ, year);
13045
13208
  let tamuz17attrs;
13046
- if (tamuz17.getDay() === SAT$2) {
13047
- tamuz17 = new HDate(18, TAMUZ$1, year);
13209
+ if (tamuz17.getDay() === SAT$1) {
13210
+ tamuz17 = new HDate(18, TAMUZ, year);
13048
13211
  tamuz17attrs = { observed: true };
13049
13212
  }
13050
13213
  addToMap(map, new HolidayEvent(tamuz17, holidayDesc.TZOM_TAMMUZ, MINOR_FAST$1, tamuz17attrs));
13051
- let av9dt = new HDate(9, AV$1, year);
13214
+ let av9dt = new HDate(9, AV, year);
13052
13215
  let av9title = holidayDesc.TISHA_BAV;
13053
13216
  let av9attrs;
13054
- if (av9dt.getDay() === SAT$2) {
13217
+ if (av9dt.getDay() === SAT$1) {
13055
13218
  av9dt = av9dt.next();
13056
13219
  av9attrs = { observed: true };
13057
13220
  av9title += ' (observed)';
13058
13221
  }
13059
13222
  const av9abs = av9dt.abs();
13060
- addToMap(map, new HolidayEvent(new HDate(HDate.dayOnOrBefore(SAT$2, av9abs)), holidayDesc.SHABBAT_CHAZON, SPECIAL_SHABBAT$1), new HolidayEvent(av9dt.prev(), holidayDesc.EREV_TISHA_BAV, EREV$1 | MAJOR_FAST$1, av9attrs), new HolidayEvent(av9dt, av9title, MAJOR_FAST$1, av9attrs), new HolidayEvent(new HDate(HDate.dayOnOrBefore(SAT$2, av9abs + 7)), holidayDesc.SHABBAT_NACHAMU, SPECIAL_SHABBAT$1));
13223
+ addToMap(map, new HolidayEvent(new HDate(HDate.dayOnOrBefore(SAT$1, av9abs)), holidayDesc.SHABBAT_CHAZON, SPECIAL_SHABBAT$1), new HolidayEvent(av9dt.prev(), holidayDesc.EREV_TISHA_BAV, EREV$1 | MAJOR_FAST$1, av9attrs), new HolidayEvent(av9dt, av9title, MAJOR_FAST$1, av9attrs), new HolidayEvent(new HDate(HDate.dayOnOrBefore(SAT$1, av9abs + 7)), holidayDesc.SHABBAT_NACHAMU, SPECIAL_SHABBAT$1));
13061
13224
  }
13062
13225
  function daysInPreviousMonth(month, year) {
13063
- return month === NISAN$2
13226
+ return month === NISAN$1
13064
13227
  ? HDate.daysInMonth(HDate.monthsInYear(year - 1), year - 1)
13065
13228
  : HDate.daysInMonth(month - 1, year);
13066
13229
  }
@@ -13090,7 +13253,7 @@ function addYomKippurKatan(map, year) {
13090
13253
  }
13091
13254
  let ykk = new HDate(29, month, year);
13092
13255
  const dow = ykk.getDay();
13093
- if (dow === FRI$1 || dow === SAT$2) {
13256
+ if (dow === FRI$1 || dow === SAT$1) {
13094
13257
  ykk = ykk.onOrBefore(THU);
13095
13258
  }
13096
13259
  const nextMonthName = HDate.getMonthName(nextMonth, year);
@@ -13100,7 +13263,7 @@ function addYomKippurKatan(map, year) {
13100
13263
  function addBehab(map, year) {
13101
13264
  for (const month of [CHESHVAN, IYYAR]) {
13102
13265
  const roshChodesh = new HDate(1, month, year);
13103
- let shabbos = new HDate(HDate.dayOnOrBefore(SAT$2, roshChodesh.abs() + 6));
13266
+ let shabbos = new HDate(HDate.dayOnOrBefore(SAT$1, roshChodesh.abs() + 6));
13104
13267
  if (shabbos.abs() === roshChodesh.abs()) {
13105
13268
  shabbos = new HDate(shabbos.abs() + 7);
13106
13269
  }
@@ -13113,25 +13276,54 @@ function addBehab(map, year) {
13113
13276
  }
13114
13277
  }
13115
13278
  }
13279
+ /**
13280
+ * Holidays for an entire Hebrew year, indexed by R.D. day number
13281
+ * (`HDate.abs()`), so that per-day lookups don't have to build a date string.
13282
+ * The result is cached in an internal LRU and shared between callers.
13283
+ * @internal
13284
+ */
13285
+ function getHolidaysForYearByRd(year) {
13286
+ return getYearEntry(year).map;
13287
+ }
13116
13288
  /**
13117
13289
  * Lower-level holidays interface, which returns a `Map` of `Event`s indexed by
13118
13290
  * `HDate.toString()`. These events must filtered especially for `flags.IL_ONLY`
13119
13291
  * or `flags.CHUL_ONLY` depending on Israel vs. Diaspora holiday scheme.
13292
+ *
13293
+ * A string-keyed copy of {@link getHolidaysForYearByRd}, built once per
13294
+ * cached year; the event arrays are shared with it.
13120
13295
  * @internal
13121
13296
  */
13122
13297
  function getHolidaysForYear_(year) {
13298
+ const entry = getYearEntry(year);
13299
+ let strMap = stringMapCache.get(entry);
13300
+ if (strMap === undefined) {
13301
+ strMap = new Map();
13302
+ for (const [abs, events] of entry.map) {
13303
+ strMap.set(new HDate(abs).toString(), events);
13304
+ }
13305
+ stringMapCache.set(entry, strMap);
13306
+ }
13307
+ return strMap;
13308
+ }
13309
+ function getYearEntry(year) {
13310
+ const last = lastEntry;
13311
+ if (last?.year === year) {
13312
+ return last;
13313
+ }
13314
+ const entry = yearCache.get(year) ?? makeYearEntry(year);
13315
+ lastEntry = entry;
13316
+ return entry;
13317
+ }
13318
+ function makeYearEntry(year) {
13123
13319
  if (typeof year !== 'number') {
13124
13320
  throw new TypeError(`bad Hebrew year: ${year}`);
13125
13321
  }
13126
13322
  if (year < 1 || year > 32658) {
13127
13323
  throw new RangeError(`Hebrew year ${year} out of range 1-32658`);
13128
13324
  }
13129
- const cached = yearCache.get(year);
13130
- if (cached) {
13131
- return cached;
13132
- }
13133
13325
  const RH = new HDate(1, TISHREI$1, year);
13134
- const pesach = new HDate(15, NISAN$2, year);
13326
+ const pesach = new HDate(15, NISAN$1, year);
13135
13327
  const map = new Map();
13136
13328
  addStaticHolidays(map, year);
13137
13329
  addTishreiHolidays(map, year, RH);
@@ -13159,8 +13351,14 @@ function getHolidaysForYear_(year) {
13159
13351
  for (const arr of map.values()) {
13160
13352
  arr.sort((a, b) => timeOfDay(a) - timeOfDay(b));
13161
13353
  }
13162
- yearCache.set(year, map);
13163
- return map;
13354
+ const entry = {
13355
+ year,
13356
+ map,
13357
+ startAbs: RH.abs(),
13358
+ endAbs: HDate.hebrew2abs(year + 1, TISHREI$1, 1) - 1,
13359
+ };
13360
+ yearCache.set(year, entry);
13361
+ return entry;
13164
13362
  }
13165
13363
  /** 28 years of 365.25 days */
13166
13364
  const BIRKAT_HACHAMAH_CYCLE_DAYS = 10227;
@@ -13177,7 +13375,7 @@ const BIRKAT_HACHAMAH_REMAINDER = 172;
13177
13375
  */
13178
13376
  function getBirkatHaChama(year) {
13179
13377
  const leap = HDate.isLeapYear(year);
13180
- const startMonth = leap ? ADAR_II : NISAN$2;
13378
+ const startMonth = leap ? ADAR_II : NISAN$1;
13181
13379
  const startDay = leap ? 20 : 1;
13182
13380
  const baseRd = HDate.hebrew2abs(year, startMonth, startDay);
13183
13381
  for (let day = 0; day <= 40; day++) {
@@ -13204,141 +13402,25 @@ function getBirkatHaChama(year) {
13204
13402
  * @param il use the Israeli schedule for holidays
13205
13403
  */
13206
13404
  function getHolidaysForYearArray(year, il) {
13207
- const yearMap = getHolidaysForYear_(year);
13208
- const startAbs = HDate.hebrew2abs(year, TISHREI$1, 1);
13209
- const endAbs = HDate.hebrew2abs(year + 1, TISHREI$1, 1) - 1;
13405
+ const { map, startAbs, endAbs } = getYearEntry(year);
13406
+ const days = [];
13407
+ for (const abs of map.keys()) {
13408
+ if (abs >= startAbs && abs <= endAbs) {
13409
+ days.push(abs);
13410
+ }
13411
+ }
13412
+ days.sort((a, b) => a - b);
13210
13413
  const events = [];
13211
- for (let absDt = startAbs; absDt <= endAbs; absDt++) {
13212
- const hd = new HDate(absDt);
13213
- const holidays = yearMap.get(hd.toString());
13214
- if (holidays) {
13215
- events.push(...holidays.filter(ev => ev.observedIn(il)));
13414
+ for (const abs of days) {
13415
+ for (const ev of map.get(abs)) {
13416
+ if (ev.observedIn(il)) {
13417
+ events.push(ev);
13418
+ }
13216
13419
  }
13217
13420
  }
13218
13421
  return events;
13219
13422
  }
13220
13423
 
13221
- function isTomorrowShabbosOrYomTov(dow, events) {
13222
- return (dow === 5 ||
13223
- events.some(ev => ev.hasAnyFlag('LIGHT_CANDLES', 'LIGHT_CANDLES_TZEIS')));
13224
- }
13225
- /**
13226
- * Returns true if it is _Shabbos_ or if it is a _Yom Tov_ day that has a
13227
- * _melacha_ (work) prohibition.
13228
- *
13229
- * @param dow day of week, where `6` is Shabbos
13230
- * @param events events occurring on the day
13231
- * @return `true` if the day is a _Yom Tov_ that is _assur bemlacha_, or _Shabbos_
13232
- */
13233
- function isTodayAssurBemelacha(dow, events) {
13234
- return dow === 6 || events.some(ev => ev.hasFlag('CHAG'));
13235
- }
13236
- /**
13237
- * Returns `true` if the given moment (date + time) falls within a period
13238
- * when *melacha* (work) is prohibited — i.e. Shabbat or a Yom Tov.
13239
- *
13240
- * The Shabbat/Yom Tov window is taken to begin at sunset (shkiah) on the
13241
- * preceding day (Erev Shabbat / Erev Yom Tov / Yom Tov sheni) and to end
13242
- * at *tzais* (nightfall) on the day itself. *Tzais* is calculated using a
13243
- * solar depression of 8.5° for simplicity; consult a halachic authority
13244
- * for more stringent opinions.
13245
- *
13246
- * `useElevation` controls whether the location's elevation is taken into
13247
- * account when computing sunset (it has no effect on the degree-based
13248
- * tzais calculation). The Israel/Diaspora schedule comes from
13249
- * `location.getIsrael()`.
13250
- *
13251
- * Throws if sunset cannot be calculated for the given location
13252
- * (e.g. polar regions).
13253
- * @example
13254
- * import {isAssurBemlacha, Location} from '@hebcal/core';
13255
- * const loc = Location.lookup('Jerusalem')!;
13256
- * // Friday after sunset:
13257
- * isAssurBemlacha(new Date('2024-04-26T18:00:00Z'), loc, false); // true
13258
- * @param currentTime the moment to test (with hour/minute)
13259
- * @param location geographic location (also supplies Israel/Diaspora flag and tzid)
13260
- * @param useElevation include elevation when computing sunset
13261
- * @return `true` if *melacha* is prohibited, `false` if it is not
13262
- */
13263
- function isAssurBemlacha(currentTime, location, useElevation) {
13264
- // Determine the calendar date in the location's timezone, not the
13265
- // timezone of the computer running this code. Otherwise the day-of-week,
13266
- // Hebrew date and sunset/tzais times would depend on the machine's
13267
- // local timezone, giving different (incorrect) results near midnight.
13268
- const isoDate = getPseudoISO(location.getTzid(), currentTime);
13269
- const year = parseInt(isoDate.substring(0, 4), 10);
13270
- const month = parseInt(isoDate.substring(5, 7), 10);
13271
- const day = parseInt(isoDate.substring(8, 10), 10);
13272
- const hd = new HDate(new Date(year, month - 1, day));
13273
- const zmanim = new Zmanim(location, hd, useElevation);
13274
- // erev shabbos, YT or YT sheni and after shkiah
13275
- const sunset = zmanim.sunset();
13276
- const sunsetMillis = sunset.getTime();
13277
- if (Number.isNaN(sunsetMillis)) {
13278
- throw new Error('Could not determine sunset');
13279
- }
13280
- // erev shabbos, YT or YT sheni and after shkiah
13281
- const il = location.getIsrael();
13282
- const currentMillis = currentTime.getTime();
13283
- const dow = hd.getDay();
13284
- const events = getHolidaysOnDate(hd, il) ?? [];
13285
- if (isTomorrowShabbosOrYomTov(dow, events) && currentMillis >= sunsetMillis) {
13286
- return true;
13287
- }
13288
- // is shabbos or YT and it is before tzais
13289
- if (isTodayAssurBemelacha(dow, events)) {
13290
- const tzais = zmanim.tzeit();
13291
- const tzaisMillis = tzais.getTime();
13292
- return currentMillis <= tzaisMillis;
13293
- }
13294
- return false;
13295
- }
13296
-
13297
- const { NISAN: NISAN$1, SIVAN: SIVAN$1, TAMUZ, AV } = months;
13298
- const SAT$1 = 6;
13299
- function getHDate(date) {
13300
- return HDate.isHDate(date) ? date : new HDate(date);
13301
- }
13302
- function isSefiratHaOmer(hd) {
13303
- const hyear = hd.getFullYear();
13304
- const beginOmer = new HDate(16, NISAN$1, hyear).abs();
13305
- const endOmer = new HDate(5, SIVAN$1, hyear).abs();
13306
- const abs = hd.abs();
13307
- return abs >= beginOmer && abs <= endOmer;
13308
- }
13309
- function isBeinHaMetzarim(hd) {
13310
- const hyear = hd.getFullYear();
13311
- const begin = new HDate(17, TAMUZ, hyear).abs();
13312
- const tishaBav = new HDate(9, AV, hyear);
13313
- const end = tishaBav.getDay() === SAT$1 ? new HDate(10, AV, hyear).abs() : tishaBav.abs();
13314
- const abs = hd.abs();
13315
- return abs >= begin && abs <= end;
13316
- }
13317
- /**
13318
- * Returns `true` if the given date falls within a public period of communal
13319
- * mourning — specifically:
13320
- *
13321
- * - **Sefirat HaOmer**: 16 Nisan through 5 Sivan (the 49 days of the Omer).
13322
- * - **Bein HaMetzarim** ("between the straits"): 17 Tammuz through 9 Av
13323
- * (10 Av when 9 Av is postponed because it falls on Shabbat).
13324
- *
13325
- * This is a broad helper — it does not attempt to model minhag-specific
13326
- * exceptions within those periods (e.g. Lag BaOmer, Rosh Chodesh Iyar,
13327
- * the distinction between Sephardic and Ashkenazic customs on which
13328
- * portion of the Omer is observed as mourning, etc.).
13329
- * @example
13330
- * import {isAveilut, HDate, months} from '@hebcal/core';
13331
- * isAveilut(new HDate(20, months.NISAN, 5784)); // true (Omer)
13332
- * isAveilut(new HDate(25, months.TAMUZ, 5784)); // true (Three Weeks)
13333
- * isAveilut(new HDate(15, months.AV, 5784)); // false
13334
- * @param date Hebrew Date, Gregorian date, or absolute R.D. day number
13335
- * @return `true` if the date is during a mourning period
13336
- */
13337
- function isAveilut(date) {
13338
- const hd = getHDate(date);
13339
- return isSefiratHaOmer(hd) || isBeinHaMetzarim(hd);
13340
- }
13341
-
13342
13424
  /**
13343
13425
  * Returns `true` if the given date is observed as a major or minor fast day.
13344
13426
  *
@@ -13423,7 +13505,9 @@ const MINOR_FAST_END_MINUTES_IL = 15;
13423
13505
  * Returns `val` when it is a finite nonzero number, otherwise `undefined`
13424
13506
  */
13425
13507
  function nonzero(val) {
13426
- return typeof val === 'number' && isFinite(val) && val !== 0 ? val : undefined;
13508
+ return typeof val === 'number' && Number.isFinite(val) && val !== 0
13509
+ ? val
13510
+ : undefined;
13427
13511
  }
13428
13512
  /**
13429
13513
  * Computes the "Fast begins" time for a minor fast (one that begins at dawn).
@@ -13678,8 +13762,7 @@ function isShabbatOrChag(hd, il) {
13678
13762
  if (hd.getDay() === 6) {
13679
13763
  return true;
13680
13764
  }
13681
- const events = getHolidaysOnDate(hd, il) ?? [];
13682
- return events.some(ev => ev.hasFlag('CHAG'));
13765
+ return isYomTov(hd, il);
13683
13766
  }
13684
13767
  /**
13685
13768
  * Makes the "Latest Kiddush Levana" event for one Hebrew month, or
@@ -14567,7 +14650,7 @@ function getMonth(options) {
14567
14650
  return options.month;
14568
14651
  }
14569
14652
  }
14570
- return NaN;
14653
+ return Number.NaN;
14571
14654
  }
14572
14655
  function startEndGregorian(theMonth, theYear, numYears) {
14573
14656
  const gregMonth = theMonth ? theMonth - 1 : 0;
@@ -14923,7 +15006,7 @@ function calendar(options = {}) {
14923
15006
  const hyear = hd.getFullYear();
14924
15007
  if (hyear !== currentYear) {
14925
15008
  currentYear = hyear;
14926
- holidaysYear = getHolidaysForYear_(currentYear);
15009
+ holidaysYear = getHolidaysForYearByRd(currentYear);
14927
15010
  if (options.sedrot) {
14928
15011
  sedra = getSedra(currentYear, il);
14929
15012
  }
@@ -14937,7 +15020,7 @@ function calendar(options = {}) {
14937
15020
  const isFriday = dow === FRI;
14938
15021
  const isSaturday = dow === SAT;
14939
15022
  let candlesEv;
14940
- const holidays0 = holidaysYear.get(hd.toString()) || [];
15023
+ const holidays0 = holidaysYear.get(abs) || [];
14941
15024
  const holidays = holidays0.filter(ev => ev.observedIn(il));
14942
15025
  if (options.sedrot && isSaturday) {
14943
15026
  const parsha0 = sedra.lookup(abs);
@@ -15712,7 +15795,7 @@ class HebrewCalendar {
15712
15795
  const today = new HDate(date);
15713
15796
  const friday = today.after(5);
15714
15797
  const tomorrow = today.next();
15715
- return isChag(friday, il) && !isChag(today, il) && isChag(tomorrow, il);
15798
+ return isYomTov(friday, il) && !isYomTov(today, il) && isYomTov(tomorrow, il);
15716
15799
  }
15717
15800
  /**
15718
15801
  * Helper function to format a 24-hour (00:00-23:59) time string in either
@@ -15811,10 +15894,6 @@ class HebrewCalendar {
15811
15894
  return tachanun(hdate, il);
15812
15895
  }
15813
15896
  }
15814
- function isChag(date, il) {
15815
- const events = getHolidaysOnDate(date, il) ?? [];
15816
- return events.some(ev => ev.hasFlag('CHAG'));
15817
- }
15818
15897
 
15819
15898
  exports.AsaraBTevetEvent = AsaraBTevetEvent;
15820
15899
  exports.CandleLightingEvent = CandleLightingEvent;
@@ -15858,6 +15937,7 @@ exports.holidayDesc = holidayDesc;
15858
15937
  exports.isAssurBemlacha = isAssurBemlacha;
15859
15938
  exports.isAveilut = isAveilut;
15860
15939
  exports.isFastDay = isFastDay;
15940
+ exports.isYomTov = isYomTov;
15861
15941
  exports.months = months;
15862
15942
  exports.parshaYear = parshaYear;
15863
15943
  exports.parshiot = parshiot;