@hebcal/core 6.14.3 → 6.14.4

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 (52) hide show
  1. package/dist/bundle.js +212 -165
  2. package/dist/bundle.js.map +1 -1
  3. package/dist/bundle.min.js +6 -6
  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 +1 -1
  9. package/dist/esm/MevarchimChodeshEvent.js +1 -1
  10. package/dist/esm/ParshaEvent.js +1 -1
  11. package/dist/esm/TimedEvent.js +1 -1
  12. package/dist/esm/YomKippurKatanEvent.js +1 -1
  13. package/dist/esm/ashkenazi.po.js +1 -1
  14. package/dist/esm/calendar.d.ts +10 -0
  15. package/dist/esm/calendar.js +36 -27
  16. package/dist/esm/calendar.js.map +1 -1
  17. package/dist/esm/candles.js +1 -1
  18. package/dist/esm/cities.json.js +1 -1
  19. package/dist/esm/event.js +1 -1
  20. package/dist/esm/getStartAndEnd.js +1 -1
  21. package/dist/esm/hallel.js +1 -1
  22. package/dist/esm/he-x-NoNikud.po.js +1 -1
  23. package/dist/esm/he.po.js +1 -1
  24. package/dist/esm/hebcal.js +1 -1
  25. package/dist/esm/holidays.d.ts +26 -8
  26. package/dist/esm/holidays.js +54 -15
  27. package/dist/esm/holidays.js.map +1 -1
  28. package/dist/esm/index.js +1 -1
  29. package/dist/esm/isAssurBemlacha.js +1 -1
  30. package/dist/esm/isAveilut.js +1 -1
  31. package/dist/esm/isFastDay.js +1 -1
  32. package/dist/esm/locale.js +1 -1
  33. package/dist/esm/location.js +1 -1
  34. package/dist/esm/modern.js +1 -1
  35. package/dist/esm/molad.js +1 -1
  36. package/dist/esm/moladBase.js +1 -1
  37. package/dist/esm/moladDate.js +1 -1
  38. package/dist/esm/omer.js +1 -1
  39. package/dist/esm/parshaName.js +1 -1
  40. package/dist/esm/parshaYear.js +1 -1
  41. package/dist/esm/pkgVersion.d.ts +1 -1
  42. package/dist/esm/pkgVersion.js +2 -2
  43. package/dist/esm/pkgVersion.js.map +1 -1
  44. package/dist/esm/reformatTimeStr.js +1 -1
  45. package/dist/esm/sedra.js +1 -1
  46. package/dist/esm/sefira.json.js +1 -1
  47. package/dist/esm/staticHolidays.js +1 -1
  48. package/dist/esm/string.js +1 -1
  49. package/dist/esm/tachanun.js +1 -1
  50. package/dist/esm/zenith.js +1 -1
  51. package/dist/esm/zmanim.js +1 -1
  52. package/package.json +1 -1
package/dist/bundle.js CHANGED
@@ -1,9 +1,9 @@
1
- /*! @hebcal/core v6.14.3, distributed under GPLv2 or later https://www.gnu.org/licenses/gpl-2.0.txt */
1
+ /*! @hebcal/core v6.14.4, 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.14.3';
6
+ const version = '6.14.4';
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
  /**
@@ -12442,6 +12442,131 @@ function getSedra(hyear, il) {
12442
12442
  return sedra;
12443
12443
  }
12444
12444
 
12445
+ const { HAVDALAH, CANDLE_LIGHTING } = holidayDesc;
12446
+ /**
12447
+ * Base class for events that have an associated wall-clock time and
12448
+ * geographic location — for example, candle lighting, havdalah, and
12449
+ * fast begin/end times.
12450
+ *
12451
+ * Stores both a `Date` (`eventTime`) and pre-formatted 24-hour
12452
+ * (`eventTimeStr`) and locale-aware (`fmtTime`) strings. May reference a
12453
+ * "linked" event such as the holiday whose candle-lighting time this
12454
+ * represents.
12455
+ */
12456
+ class TimedEvent extends Event {
12457
+ /**
12458
+ * Normally created by {@link calendar} rather than directly.
12459
+ * @param date Hebrew date the event occurs
12460
+ * @param desc Description (not translated)
12461
+ * @param mask optional holiday flags
12462
+ * @param eventTime the exact moment of the event
12463
+ * @param location geographic location used to format the time
12464
+ * @param linkedEvent optional event this time is associated with
12465
+ * @param options optional; `locale` and `hour12` affect {@link fmtTime}
12466
+ */
12467
+ constructor(date, desc, mask, eventTime, location, linkedEvent, options) {
12468
+ super(date, desc, mask);
12469
+ this.eventTime = Zmanim.roundTime(eventTime);
12470
+ this.location = location;
12471
+ const timeFormat = location.getTimeFormatter();
12472
+ this.eventTimeStr = Zmanim.formatTime(this.eventTime, timeFormat);
12473
+ const opts = { ...options, location };
12474
+ this.fmtTime = reformatTimeStr(this.eventTimeStr, 'pm', opts);
12475
+ if (linkedEvent !== undefined) {
12476
+ this.linkedEvent = linkedEvent;
12477
+ }
12478
+ }
12479
+ /**
12480
+ * @param [locale] Optional locale name (defaults to empty locale)
12481
+ */
12482
+ render(locale) {
12483
+ return `${Locale.gettext(this.getDesc(), locale)}: ${this.fmtTime}`;
12484
+ }
12485
+ /**
12486
+ * Returns translation of "Candle lighting" without the time.
12487
+ * @param [locale] Optional locale name (defaults to empty locale)
12488
+ */
12489
+ renderBrief(locale) {
12490
+ return Locale.gettext(this.getDesc(), locale);
12491
+ }
12492
+ getCategories() {
12493
+ const desc = this.getDesc();
12494
+ switch (desc) {
12495
+ // LIGHT_CANDLES or LIGHT_CANDLES_TZEIS
12496
+ case CANDLE_LIGHTING:
12497
+ return ['candles'];
12498
+ // YOM_TOV_ENDS
12499
+ case HAVDALAH:
12500
+ return ['havdalah'];
12501
+ // flags.MINOR_FAST or flags.MAJOR_FAST
12502
+ case holidayDesc.FAST_BEGINS:
12503
+ case holidayDesc.FAST_ENDS:
12504
+ return ['zmanim', 'fast'];
12505
+ case holidayDesc.SOF_ZMAN_ACHILAT_CHAMETZ:
12506
+ return ['zmanim', 'achilasChametz'];
12507
+ case holidayDesc.BIUR_CHAMETZ:
12508
+ return ['zmanim', 'biurChametz'];
12509
+ }
12510
+ /* NOTREACHED */
12511
+ return ['unknown'];
12512
+ }
12513
+ }
12514
+ /**
12515
+ * Candle-lighting event for the eve of Shabbat or a Yom Tov.
12516
+ *
12517
+ * Generated by {@link calendar} when `options.candlelighting`
12518
+ * is `true` and `options.location` is provided. By default candle lighting
12519
+ * occurs 18 minutes before sundown in the Diaspora and 20 minutes before
12520
+ * sundown in Israel (40 minutes in Jerusalem; 30 minutes in Haifa and
12521
+ * Zikhron Ya'akov), configurable via `options.candleLightingMins`.
12522
+ */
12523
+ class CandleLightingEvent extends TimedEvent {
12524
+ constructor(date, mask, eventTime, location, linkedEvent, options) {
12525
+ super(date, CANDLE_LIGHTING, mask, eventTime, location, linkedEvent, options);
12526
+ }
12527
+ getEmoji() {
12528
+ return '🕯️';
12529
+ }
12530
+ }
12531
+ /**
12532
+ * Havdalah event marking the end of Shabbat or a Yom Tov.
12533
+ *
12534
+ * Generated by {@link calendar} when `options.candlelighting`
12535
+ * is `true` and `options.location` is provided. By default Havdalah is
12536
+ * calculated by *tzeit hakochavim* (8.5° solar depression); pass
12537
+ * `options.havdalahMins` to use a fixed minute offset instead, or
12538
+ * `options.havdalahDeg` to use a different degree.
12539
+ */
12540
+ class HavdalahEvent extends TimedEvent {
12541
+ constructor(date, mask, eventTime, location, havdalahMins, linkedEvent, options) {
12542
+ super(date, HAVDALAH, mask, eventTime, location, linkedEvent, options);
12543
+ if (havdalahMins) {
12544
+ this.havdalahMins = havdalahMins;
12545
+ }
12546
+ }
12547
+ /**
12548
+ * @param [locale] Optional locale name (defaults to empty locale)
12549
+ */
12550
+ render(locale) {
12551
+ return `${this.renderBrief(locale)}: ${this.fmtTime}`;
12552
+ }
12553
+ /**
12554
+ * Returns translation of "Havdalah" without the time.
12555
+ * @param [locale] Optional locale name (defaults to empty locale)
12556
+ */
12557
+ renderBrief(locale) {
12558
+ let str = Locale.gettext(this.getDesc(), locale);
12559
+ if (this.havdalahMins) {
12560
+ const min = Locale.gettext('min', locale);
12561
+ str += ` (${this.havdalahMins} ${min})`;
12562
+ }
12563
+ return str;
12564
+ }
12565
+ getEmoji() {
12566
+ return '✨';
12567
+ }
12568
+ }
12569
+
12445
12570
  const ykk = 'Yom Kippur Katan';
12446
12571
  /** YKK is minor day of atonement on the day preceeding each Rosh Chodesh */
12447
12572
  class YomKippurKatanEvent extends HolidayEvent {
@@ -12524,7 +12649,7 @@ function getHolidaysOnDate(date, il) {
12524
12649
  }
12525
12650
  return events.filter(ev => ev.observedIn(il));
12526
12651
  }
12527
- const { CHAG, LIGHT_CANDLES_TZEIS: LIGHT_CANDLES_TZEIS$2, CHANUKAH_CANDLES: CHANUKAH_CANDLES$1, BEHAB: BEHAB$1, MINOR_FAST: MINOR_FAST$1, SPECIAL_SHABBAT: SPECIAL_SHABBAT$1, MAJOR_FAST: MAJOR_FAST$1, MINOR_HOLIDAY: MINOR_HOLIDAY$1, EREV: EREV$1, SHABBAT_MEVARCHIM: SHABBAT_MEVARCHIM$1, } = flags;
12652
+ const { CHAG, LIGHT_CANDLES_TZEIS: LIGHT_CANDLES_TZEIS$2, CHANUKAH_CANDLES: CHANUKAH_CANDLES$1, BEHAB: BEHAB$1, MINOR_FAST: MINOR_FAST$1, SPECIAL_SHABBAT: SPECIAL_SHABBAT$1, MAJOR_FAST: MAJOR_FAST$1, MINOR_HOLIDAY: MINOR_HOLIDAY$1, EREV: EREV$1, } = flags;
12528
12653
  const SUN = 0;
12529
12654
  const TUE = 2;
12530
12655
  const THU = 4;
@@ -12545,36 +12670,74 @@ function addToMap(map, ...events) {
12545
12670
  }
12546
12671
  }
12547
12672
  /** @internal */
12548
- const TIME_OF_DAY_MORNING = 0;
12673
+ const TIME_OF_DAY_DAWN = 0;
12674
+ /** @internal */
12675
+ const TIME_OF_DAY_MORNING = 1;
12676
+ /** @internal */
12677
+ const TIME_OF_DAY_MEVARCHIM = 2;
12549
12678
  /** @internal */
12550
- const TIME_OF_DAY_MEVARCHIM = 1;
12679
+ const TIME_OF_DAY_DAY = 3;
12551
12680
  /** @internal */
12552
- const TIME_OF_DAY_DAY = 2;
12681
+ const TIME_OF_DAY_MIDDAY = 4;
12553
12682
  /** @internal */
12554
- const TIME_OF_DAY_EVENING = 3;
12683
+ const TIME_OF_DAY_LEARNING = 5;
12684
+ /** @internal */
12685
+ const TIME_OF_DAY_EVENING = 6;
12686
+ /** @internal */
12687
+ const TIME_OF_DAY_NIGHT = 7;
12555
12688
  /**
12556
12689
  * Approximate time of day of an event, used to order events on the same date.
12557
- * - Morning: special Shabbatot (tied to the Torah or Haftarah reading), minor
12558
- * fasts (which begin at dawn) and Birkat Hachamah (recited at sunrise)
12559
- * - Shabbat Mevarchim, announced in synagogue after the Torah reading
12560
- * - Day: everything else
12690
+ * Events of equal rank keep the order in which they were created, and timed
12691
+ * events of equal rank are ordered by their time.
12692
+ * - Dawn: Fast begins for a minor fast, and a Latest Kiddush Levana before
12693
+ * noon (which is never later than _alot hashachar_)
12694
+ * - Morning: the parsha, special Shabbatot (tied to the Torah or Haftarah
12695
+ * reading), minor fasts (which begin at dawn) and Birkat Hachamah
12696
+ * (recited at sunrise)
12697
+ * - Molad and Shabbat Mevarchim, announced in synagogue after the Torah
12698
+ * reading
12699
+ * - Day: everything else, including Yizkor and the Omer count
12700
+ * - Midday: the deadlines for eating and burning chametz
12701
+ * - Daily learning
12561
12702
  * - Evening: Erev holidays, Chanukah candle-lighting and Leil Selichot
12703
+ * - Night: other timed events such as candle-lighting, Havdalah,
12704
+ * Fast ends, and a Latest Kiddush Levana after noon
12562
12705
  * @internal
12563
12706
  */
12564
12707
  function timeOfDay(ev) {
12565
- const mask = ev.getFlags();
12708
+ if (ev instanceof TimedEvent) {
12709
+ return timedEventTimeOfDay(ev);
12710
+ }
12566
12711
  const desc = ev.getDesc();
12567
- if (mask & (EREV$1 | CHANUKAH_CANDLES$1) || desc === holidayDesc.LEIL_SELICHOT) {
12712
+ if (ev.hasAnyFlag('EREV', 'CHANUKAH_CANDLES') || desc === holidayDesc.LEIL_SELICHOT) {
12568
12713
  return TIME_OF_DAY_EVENING;
12569
12714
  }
12570
- if (mask & (SPECIAL_SHABBAT$1 | MINOR_FAST$1) || desc === holidayDesc.BIRKAT_HACHAMAH) {
12715
+ if (ev.hasAnyFlag('PARSHA_HASHAVUA', 'SPECIAL_SHABBAT', 'MINOR_FAST') ||
12716
+ desc === holidayDesc.BIRKAT_HACHAMAH) {
12571
12717
  return TIME_OF_DAY_MORNING;
12572
12718
  }
12573
- if (mask & SHABBAT_MEVARCHIM$1) {
12719
+ if (ev.hasAnyFlag('SHABBAT_MEVARCHIM', 'MOLAD')) {
12574
12720
  return TIME_OF_DAY_MEVARCHIM;
12575
12721
  }
12722
+ if (ev.hasAnyFlag('DAILY_LEARNING', 'DAF_YOMI', 'MISHNA_YOMI', 'NACH_YOMI', 'YERUSHALMI_YOMI')) {
12723
+ return TIME_OF_DAY_LEARNING;
12724
+ }
12576
12725
  return TIME_OF_DAY_DAY;
12577
12726
  }
12727
+ function timedEventTimeOfDay(ev) {
12728
+ const desc = ev.getDesc();
12729
+ if (desc === holidayDesc.SOF_ZMAN_ACHILAT_CHAMETZ || desc === holidayDesc.BIUR_CHAMETZ) {
12730
+ return TIME_OF_DAY_MIDDAY;
12731
+ }
12732
+ // A minor fast begins at dawn, but Tish'a B'Av at sunset the day before.
12733
+ // Latest Kiddush Levana is either before dawn or after nightfall.
12734
+ if (desc === holidayDesc.FAST_BEGINS || ev.hasFlag('KIDDUSH_LEVANA')) {
12735
+ // `eventTimeStr` is 24-hour local time; some engines format midnight as 24:00
12736
+ const hour = Number.parseInt(ev.eventTimeStr, 10) % 24;
12737
+ return hour < 12 ? TIME_OF_DAY_DAWN : TIME_OF_DAY_NIGHT;
12738
+ }
12739
+ return TIME_OF_DAY_NIGHT;
12740
+ }
12578
12741
  function addStaticHolidays(map, year) {
12579
12742
  for (const h of staticHolidays) {
12580
12743
  const hd = new HDate(h.dd, h.mm, year);
@@ -12950,131 +13113,6 @@ function isFastDay(date, il) {
12950
13113
  return events.some(ev => ev.hasAnyFlag('MAJOR_FAST', 'MINOR_FAST') && !ev.hasFlag('EREV'));
12951
13114
  }
12952
13115
 
12953
- const { HAVDALAH, CANDLE_LIGHTING } = holidayDesc;
12954
- /**
12955
- * Base class for events that have an associated wall-clock time and
12956
- * geographic location — for example, candle lighting, havdalah, and
12957
- * fast begin/end times.
12958
- *
12959
- * Stores both a `Date` (`eventTime`) and pre-formatted 24-hour
12960
- * (`eventTimeStr`) and locale-aware (`fmtTime`) strings. May reference a
12961
- * "linked" event such as the holiday whose candle-lighting time this
12962
- * represents.
12963
- */
12964
- class TimedEvent extends Event {
12965
- /**
12966
- * Normally created by {@link calendar} rather than directly.
12967
- * @param date Hebrew date the event occurs
12968
- * @param desc Description (not translated)
12969
- * @param mask optional holiday flags
12970
- * @param eventTime the exact moment of the event
12971
- * @param location geographic location used to format the time
12972
- * @param linkedEvent optional event this time is associated with
12973
- * @param options optional; `locale` and `hour12` affect {@link fmtTime}
12974
- */
12975
- constructor(date, desc, mask, eventTime, location, linkedEvent, options) {
12976
- super(date, desc, mask);
12977
- this.eventTime = Zmanim.roundTime(eventTime);
12978
- this.location = location;
12979
- const timeFormat = location.getTimeFormatter();
12980
- this.eventTimeStr = Zmanim.formatTime(this.eventTime, timeFormat);
12981
- const opts = { ...options, location };
12982
- this.fmtTime = reformatTimeStr(this.eventTimeStr, 'pm', opts);
12983
- if (linkedEvent !== undefined) {
12984
- this.linkedEvent = linkedEvent;
12985
- }
12986
- }
12987
- /**
12988
- * @param [locale] Optional locale name (defaults to empty locale)
12989
- */
12990
- render(locale) {
12991
- return `${Locale.gettext(this.getDesc(), locale)}: ${this.fmtTime}`;
12992
- }
12993
- /**
12994
- * Returns translation of "Candle lighting" without the time.
12995
- * @param [locale] Optional locale name (defaults to empty locale)
12996
- */
12997
- renderBrief(locale) {
12998
- return Locale.gettext(this.getDesc(), locale);
12999
- }
13000
- getCategories() {
13001
- const desc = this.getDesc();
13002
- switch (desc) {
13003
- // LIGHT_CANDLES or LIGHT_CANDLES_TZEIS
13004
- case CANDLE_LIGHTING:
13005
- return ['candles'];
13006
- // YOM_TOV_ENDS
13007
- case HAVDALAH:
13008
- return ['havdalah'];
13009
- // flags.MINOR_FAST or flags.MAJOR_FAST
13010
- case holidayDesc.FAST_BEGINS:
13011
- case holidayDesc.FAST_ENDS:
13012
- return ['zmanim', 'fast'];
13013
- case holidayDesc.SOF_ZMAN_ACHILAT_CHAMETZ:
13014
- return ['zmanim', 'achilasChametz'];
13015
- case holidayDesc.BIUR_CHAMETZ:
13016
- return ['zmanim', 'biurChametz'];
13017
- }
13018
- /* NOTREACHED */
13019
- return ['unknown'];
13020
- }
13021
- }
13022
- /**
13023
- * Candle-lighting event for the eve of Shabbat or a Yom Tov.
13024
- *
13025
- * Generated by {@link calendar} when `options.candlelighting`
13026
- * is `true` and `options.location` is provided. By default candle lighting
13027
- * occurs 18 minutes before sundown in the Diaspora and 20 minutes before
13028
- * sundown in Israel (40 minutes in Jerusalem; 30 minutes in Haifa and
13029
- * Zikhron Ya'akov), configurable via `options.candleLightingMins`.
13030
- */
13031
- class CandleLightingEvent extends TimedEvent {
13032
- constructor(date, mask, eventTime, location, linkedEvent, options) {
13033
- super(date, CANDLE_LIGHTING, mask, eventTime, location, linkedEvent, options);
13034
- }
13035
- getEmoji() {
13036
- return '🕯️';
13037
- }
13038
- }
13039
- /**
13040
- * Havdalah event marking the end of Shabbat or a Yom Tov.
13041
- *
13042
- * Generated by {@link calendar} when `options.candlelighting`
13043
- * is `true` and `options.location` is provided. By default Havdalah is
13044
- * calculated by *tzeit hakochavim* (8.5° solar depression); pass
13045
- * `options.havdalahMins` to use a fixed minute offset instead, or
13046
- * `options.havdalahDeg` to use a different degree.
13047
- */
13048
- class HavdalahEvent extends TimedEvent {
13049
- constructor(date, mask, eventTime, location, havdalahMins, linkedEvent, options) {
13050
- super(date, HAVDALAH, mask, eventTime, location, linkedEvent, options);
13051
- if (havdalahMins) {
13052
- this.havdalahMins = havdalahMins;
13053
- }
13054
- }
13055
- /**
13056
- * @param [locale] Optional locale name (defaults to empty locale)
13057
- */
13058
- render(locale) {
13059
- return `${this.renderBrief(locale)}: ${this.fmtTime}`;
13060
- }
13061
- /**
13062
- * Returns translation of "Havdalah" without the time.
13063
- * @param [locale] Optional locale name (defaults to empty locale)
13064
- */
13065
- renderBrief(locale) {
13066
- let str = Locale.gettext(this.getDesc(), locale);
13067
- if (this.havdalahMins) {
13068
- const min = Locale.gettext('min', locale);
13069
- str += ` (${this.havdalahMins} ${min})`;
13070
- }
13071
- return str;
13072
- }
13073
- getEmoji() {
13074
- return '✨';
13075
- }
13076
- }
13077
-
13078
13116
  const { LIGHT_CANDLES: LIGHT_CANDLES$1, LIGHT_CANDLES_TZEIS: LIGHT_CANDLES_TZEIS$1 } = flags;
13079
13117
  const { FAST_BEGINS, FAST_ENDS } = holidayDesc;
13080
13118
  /** @internal */
@@ -14511,6 +14549,16 @@ class MevarchimChodeshEvent extends Event {
14511
14549
  * * `options.addHebrewDates` - print the Hebrew date for the entire date range
14512
14550
  * * `options.addHebrewDatesForEvents` - print the Hebrew date for dates with some events
14513
14551
  *
14552
+ * Events are returned in date order. Events on the same date are ordered by
14553
+ * approximate time of day: timed events before dawn (Fast begins, an early
14554
+ * Latest Kiddush Levana), then the parsha, special Shabbatot and minor fasts,
14555
+ * then the Molad and Shabbat Mevarchim, then other holidays, Yizkor and the
14556
+ * Omer, then the chametz deadlines on Erev Pesach, then daily learning, then
14557
+ * evening holidays (Erev holidays, Chanukah), and finally the remaining timed
14558
+ * events (candle-lighting, Havdalah, Fast ends) in order of time. When
14559
+ * `options.addHebrewDates` or `options.addHebrewDatesForEvents` adds a Hebrew
14560
+ * date event, it comes first.
14561
+ *
14514
14562
  * Lastly, translation and transliteration of event titles is controlled by
14515
14563
  * `options.locale` and the {@link Locale} API.
14516
14564
  * `@hebcal/core` supports three locales by default:
@@ -14601,26 +14649,18 @@ function calendar(options = {}) {
14601
14649
  let candlesEv;
14602
14650
  const holidays0 = holidaysYear.get(hd.toString()) || [];
14603
14651
  const holidays = holidays0.filter(ev => ev.observedIn(il));
14604
- // On Shabbat, events tied to the morning Torah reading and announcements
14605
- // in synagogue come first: the parsha, special Shabbatot such as
14606
- // Shabbat Shekalim, then the Molad and Shabbat Mevarchim
14607
14652
  if (options.sedrot && isSaturday) {
14608
14653
  const parsha0 = sedra.lookup(abs);
14609
14654
  if (!parsha0.chag) {
14610
14655
  evts.push(new ParshaEvent(parsha0));
14611
14656
  }
14612
14657
  }
14613
- let mevarchim = isSaturday && (options.molad || options.shabbatMevarchim)
14614
- ? makeMoladAndMevarchimChodesh(hd, options)
14615
- : [];
14658
+ if (isSaturday && (options.molad || options.shabbatMevarchim)) {
14659
+ evts.push(...makeMoladAndMevarchimChodesh(hd, options));
14660
+ }
14616
14661
  for (const ev of holidays) {
14617
- if (mevarchim.length && timeOfDay(ev) > TIME_OF_DAY_MEVARCHIM) {
14618
- evts.push(...mevarchim);
14619
- mevarchim = [];
14620
- }
14621
14662
  candlesEv = appendHolidayAndRelated(candlesEv, evts, ev, options, isFriday, isSaturday, hasUserMask);
14622
14663
  }
14623
- evts.push(...mevarchim);
14624
14664
  const mm = hd.getMonth();
14625
14665
  const dd = hd.getDate();
14626
14666
  // When Erev Pesach falls on Shabbat, burning chametz is moved to Friday.
@@ -14686,9 +14726,10 @@ function calendar(options = {}) {
14686
14726
  kiddushLevanaEv = makeKiddushLevanaEvent(hyear, mm, options);
14687
14727
  }
14688
14728
  if (kiddushLevanaEv?.getDate().abs() === abs) {
14689
- insertTimedEvent(evts, prevEventsLength, kiddushLevanaEv);
14729
+ evts.push(kiddushLevanaEv);
14690
14730
  }
14691
14731
  }
14732
+ sortByTimeOfDay(evts, prevEventsLength);
14692
14733
  if (options.addHebrewDates ||
14693
14734
  (options.addHebrewDatesForEvents &&
14694
14735
  prevEventsLength !== evts.length - numDailyLearning)) {
@@ -14994,22 +15035,28 @@ function setOptionsFromMask(options) {
14994
15035
  options.kiddushLevanaMaharil = true;
14995
15036
  return m;
14996
15037
  }
15038
+ function compareTimeOfDay(a, b) {
15039
+ const diff = timeOfDay(a) - timeOfDay(b);
15040
+ if (diff !== 0) {
15041
+ return diff;
15042
+ }
15043
+ if (a instanceof TimedEvent && b instanceof TimedEvent) {
15044
+ return a.eventTime.getTime() - b.eventTime.getTime();
15045
+ }
15046
+ return 0;
15047
+ }
14997
15048
  /**
14998
- * Inserts `ev` into today's events (those at index `start` and beyond)
14999
- * just before the first `TimedEvent` that occurs later, or appends it.
15000
- * Unlike other timed events, Latest Kiddush Levana may fall at dawn,
15001
- * at candle-lighting or late at night, so its position can't be fixed.
15049
+ * Sorts today's events (those at index `start` and beyond) in place by
15050
+ * {@link timeOfDay}. The sort is stable, so events of equal rank keep the
15051
+ * order in which they were added, e.g. Yizkor after its holiday.
15002
15052
  */
15003
- function insertTimedEvent(events, start, ev) {
15004
- const time = ev.eventTime.getTime();
15005
- for (let i = start; i < events.length; i++) {
15006
- const other = events[i];
15007
- if (other instanceof TimedEvent && other.eventTime.getTime() > time) {
15008
- events.splice(i, 0, ev);
15009
- return;
15010
- }
15053
+ function sortByTimeOfDay(events, start) {
15054
+ if (events.length - start < 2) {
15055
+ return;
15011
15056
  }
15012
- events.push(ev);
15057
+ const today = events.splice(start);
15058
+ today.sort(compareTimeOfDay);
15059
+ events.push(...today);
15013
15060
  }
15014
15061
  /**
15015
15062
  * Appends the Event `ev` to the `events` array. Also may add related