@hebcal/core 5.4.11 → 5.5.1

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.
package/dist/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- /*! @hebcal/core v5.4.11 */
1
+ /*! @hebcal/core v5.5.1 */
2
2
  /* eslint-disable @typescript-eslint/no-namespace, no-inner-declarations */
3
3
  /** @private */
4
4
  const lengths = [0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
@@ -7774,6 +7774,7 @@ class Location extends GeoLocation {
7774
7774
  * @param dst single char 'Y' or 'N'
7775
7775
  */
7776
7776
  static getUsaTzid(state, tz, dst) {
7777
+ tz = +tz;
7777
7778
  if (tz === 10 && state === 'AK') {
7778
7779
  return 'America/Adak';
7779
7780
  }
@@ -8341,6 +8342,40 @@ class Zmanim {
8341
8342
  }
8342
8343
  return new Date(sunset.getTime() + offset * 60 * 1000);
8343
8344
  }
8345
+ /**
8346
+ * Returns the Hebrew date relative to the specified location and Gregorian date,
8347
+ * taking into consideration whether the time is before or after sunset.
8348
+ *
8349
+ * For example, if the given date and is `2024-09-22T10:35` (before sunset), and
8350
+ * sunset for the specified location is **19:04**, then this function would
8351
+ * return a Hebrew date of `19th of Elul, 5784`.
8352
+ * If the given date is the same Gregorian day after sunset
8353
+ * (for example `2024-09-22T20:07`), this function would return a
8354
+ * Hebrew date of `20th of Elul, 5784`.
8355
+ * @example
8356
+ * const {GeoLocation, Zmanim, HDate} = require('@hebcal/core');
8357
+ * const latitude = 48.85341;
8358
+ * const longitude = 2.3488;
8359
+ * const timezone = 'Europe/Paris';
8360
+ * const gloc = new GeoLocation(null, latitude, longitude, 0, timezone);
8361
+ * const before = Zmanim.makeSunsetAwareHDate(gloc, new Date('2024-09-22T17:38:46.123Z'), false);
8362
+ * console.log(before.toString()); // '19 Elul 5784'
8363
+ * const after = Zmanim.makeSunsetAwareHDate(gloc, new Date('2024-09-22T23:45:18.345Z'), false);
8364
+ * console.log(after.toString()); // '20 Elul 5784'
8365
+ */
8366
+ static makeSunsetAwareHDate(gloc, date, useElevation) {
8367
+ const zmanim = new Zmanim(gloc, date, useElevation);
8368
+ const sunset = zmanim.sunset();
8369
+ let hd = new HDate(date);
8370
+ const sunsetMillis = sunset.getTime();
8371
+ if (isNaN(sunsetMillis)) {
8372
+ return hd;
8373
+ }
8374
+ if (date.getTime() >= sunsetMillis) {
8375
+ hd = hd.next();
8376
+ }
8377
+ return hd;
8378
+ }
8344
8379
  }
8345
8380
 
8346
8381
  const hour12cc = {
@@ -9481,11 +9516,11 @@ const Kislev = months.KISLEV;
9481
9516
  const Shvat = months.SHVAT;
9482
9517
  const Adar2 = months.ADAR_II;
9483
9518
  const CHAG$1 = flags.CHAG;
9484
- const LIGHT_CANDLES$1 = flags.LIGHT_CANDLES;
9519
+ const LIGHT_CANDLES$2 = flags.LIGHT_CANDLES;
9485
9520
  const YOM_TOV_ENDS$1 = flags.YOM_TOV_ENDS;
9486
9521
  const CHUL_ONLY$1 = flags.CHUL_ONLY;
9487
9522
  const IL_ONLY$2 = flags.IL_ONLY;
9488
- const LIGHT_CANDLES_TZEIS$2 = flags.LIGHT_CANDLES_TZEIS;
9523
+ const LIGHT_CANDLES_TZEIS$3 = flags.LIGHT_CANDLES_TZEIS;
9489
9524
  const CHANUKAH_CANDLES$2 = flags.CHANUKAH_CANDLES;
9490
9525
  const MAJOR_FAST$2 = flags.MAJOR_FAST;
9491
9526
  const MINOR_HOLIDAY$2 = flags.MINOR_HOLIDAY;
@@ -9704,7 +9739,7 @@ const staticHolidays = [
9704
9739
  flags: CHAG$1 | YOM_TOV_ENDS$1,
9705
9740
  emoji: '🍏🍯',
9706
9741
  },
9707
- { mm: Tishrei, dd: 9, desc: EREV_YOM_KIPPUR, flags: EREV$2 | LIGHT_CANDLES$1 },
9742
+ { mm: Tishrei, dd: 9, desc: EREV_YOM_KIPPUR, flags: EREV$2 | LIGHT_CANDLES$2 },
9708
9743
  {
9709
9744
  mm: Tishrei,
9710
9745
  dd: 10,
@@ -9715,14 +9750,14 @@ const staticHolidays = [
9715
9750
  mm: Tishrei,
9716
9751
  dd: 14,
9717
9752
  desc: EREV_SUKKOT,
9718
- flags: CHUL_ONLY$1 | EREV$2 | LIGHT_CANDLES$1,
9753
+ flags: CHUL_ONLY$1 | EREV$2 | LIGHT_CANDLES$2,
9719
9754
  emoji: emojiSukkot,
9720
9755
  },
9721
9756
  {
9722
9757
  mm: Tishrei,
9723
9758
  dd: 15,
9724
9759
  desc: SUKKOT_I,
9725
- flags: CHUL_ONLY$1 | CHAG$1 | LIGHT_CANDLES_TZEIS$2,
9760
+ flags: CHUL_ONLY$1 | CHAG$1 | LIGHT_CANDLES_TZEIS$3,
9726
9761
  emoji: emojiSukkot,
9727
9762
  },
9728
9763
  {
@@ -9768,7 +9803,7 @@ const staticHolidays = [
9768
9803
  mm: Tishrei,
9769
9804
  dd: 22,
9770
9805
  desc: SHMINI_ATZERET,
9771
- flags: CHUL_ONLY$1 | CHAG$1 | LIGHT_CANDLES_TZEIS$2,
9806
+ flags: CHUL_ONLY$1 | CHAG$1 | LIGHT_CANDLES_TZEIS$3,
9772
9807
  },
9773
9808
  {
9774
9809
  mm: Tishrei,
@@ -9780,7 +9815,7 @@ const staticHolidays = [
9780
9815
  mm: Tishrei,
9781
9816
  dd: 14,
9782
9817
  desc: EREV_SUKKOT,
9783
- flags: IL_ONLY$2 | EREV$2 | LIGHT_CANDLES$1,
9818
+ flags: IL_ONLY$2 | EREV$2 | LIGHT_CANDLES$2,
9784
9819
  emoji: emojiSukkot,
9785
9820
  },
9786
9821
  {
@@ -9840,7 +9875,7 @@ const staticHolidays = [
9840
9875
  mm: Tishrei,
9841
9876
  dd: 21,
9842
9877
  desc: SUKKOT_VII_HOSHANA_RABA,
9843
- flags: LIGHT_CANDLES$1 | CHOL_HAMOED$1,
9878
+ flags: LIGHT_CANDLES$2 | CHOL_HAMOED$1,
9844
9879
  chmDay: -1,
9845
9880
  emoji: emojiSukkot,
9846
9881
  },
@@ -9872,7 +9907,7 @@ const staticHolidays = [
9872
9907
  mm: Nisan,
9873
9908
  dd: 14,
9874
9909
  desc: EREV_PESACH,
9875
- flags: IL_ONLY$2 | EREV$2 | LIGHT_CANDLES$1,
9910
+ flags: IL_ONLY$2 | EREV$2 | LIGHT_CANDLES$2,
9876
9911
  emoji: '🫓🍷',
9877
9912
  },
9878
9913
  {
@@ -9918,7 +9953,7 @@ const staticHolidays = [
9918
9953
  mm: Nisan,
9919
9954
  dd: 20,
9920
9955
  desc: PESACH_VI_CHM,
9921
- flags: IL_ONLY$2 | CHOL_HAMOED$1 | LIGHT_CANDLES$1,
9956
+ flags: IL_ONLY$2 | CHOL_HAMOED$1 | LIGHT_CANDLES$2,
9922
9957
  chmDay: 5,
9923
9958
  emoji: emojiPesach,
9924
9959
  },
@@ -9934,14 +9969,14 @@ const staticHolidays = [
9934
9969
  mm: Nisan,
9935
9970
  dd: 14,
9936
9971
  desc: EREV_PESACH,
9937
- flags: CHUL_ONLY$1 | EREV$2 | LIGHT_CANDLES$1,
9972
+ flags: CHUL_ONLY$1 | EREV$2 | LIGHT_CANDLES$2,
9938
9973
  emoji: '🫓🍷',
9939
9974
  },
9940
9975
  {
9941
9976
  mm: Nisan,
9942
9977
  dd: 15,
9943
9978
  desc: PESACH_I,
9944
- flags: CHUL_ONLY$1 | CHAG$1 | LIGHT_CANDLES_TZEIS$2,
9979
+ flags: CHUL_ONLY$1 | CHAG$1 | LIGHT_CANDLES_TZEIS$3,
9945
9980
  emoji: '🫓🍷',
9946
9981
  },
9947
9982
  {
@@ -9979,7 +10014,7 @@ const staticHolidays = [
9979
10014
  mm: Nisan,
9980
10015
  dd: 20,
9981
10016
  desc: PESACH_VI_CHM,
9982
- flags: CHUL_ONLY$1 | CHOL_HAMOED$1 | LIGHT_CANDLES$1,
10017
+ flags: CHUL_ONLY$1 | CHOL_HAMOED$1 | LIGHT_CANDLES$2,
9983
10018
  chmDay: 4,
9984
10019
  emoji: emojiPesach,
9985
10020
  },
@@ -9987,7 +10022,7 @@ const staticHolidays = [
9987
10022
  mm: Nisan,
9988
10023
  dd: 21,
9989
10024
  desc: PESACH_VII,
9990
- flags: CHUL_ONLY$1 | CHAG$1 | LIGHT_CANDLES_TZEIS$2,
10025
+ flags: CHUL_ONLY$1 | CHAG$1 | LIGHT_CANDLES_TZEIS$3,
9991
10026
  emoji: emojiPesach,
9992
10027
  },
9993
10028
  {
@@ -10003,7 +10038,7 @@ const staticHolidays = [
10003
10038
  mm: Sivan,
10004
10039
  dd: 5,
10005
10040
  desc: EREV_SHAVUOT,
10006
- flags: EREV$2 | LIGHT_CANDLES$1,
10041
+ flags: EREV$2 | LIGHT_CANDLES$2,
10007
10042
  emoji: '⛰️🌸',
10008
10043
  },
10009
10044
  {
@@ -10017,7 +10052,7 @@ const staticHolidays = [
10017
10052
  mm: Sivan,
10018
10053
  dd: 6,
10019
10054
  desc: SHAVUOT_I,
10020
- flags: CHUL_ONLY$1 | CHAG$1 | LIGHT_CANDLES_TZEIS$2,
10055
+ flags: CHUL_ONLY$1 | CHAG$1 | LIGHT_CANDLES_TZEIS$3,
10021
10056
  emoji: '⛰️🌸',
10022
10057
  },
10023
10058
  {
@@ -10039,7 +10074,7 @@ const staticHolidays = [
10039
10074
  mm: Elul,
10040
10075
  dd: 29,
10041
10076
  desc: EREV_ROSH_HASHANA,
10042
- flags: EREV$2 | LIGHT_CANDLES$1,
10077
+ flags: EREV$2 | LIGHT_CANDLES$2,
10043
10078
  emoji: '🍏🍯',
10044
10079
  },
10045
10080
  ];
@@ -10326,20 +10361,22 @@ class DailyLearning {
10326
10361
  }
10327
10362
 
10328
10363
  /** DO NOT EDIT THIS AUTO-GENERATED FILE! */
10329
- const version = '5.4.11';
10364
+ const version = '5.5.1';
10330
10365
 
10331
10366
  /* eslint-disable max-len */
10367
+ const LIGHT_CANDLES$1 = flags.LIGHT_CANDLES;
10368
+ const LIGHT_CANDLES_TZEIS$2 = flags.LIGHT_CANDLES_TZEIS;
10332
10369
  /**
10333
10370
  * @private
10334
10371
  */
10335
10372
  function makeCandleEvent(ev, hd, options, isFriday, isSaturday) {
10336
10373
  let havdalahTitle = false;
10337
10374
  let useHavdalahOffset = isSaturday;
10338
- let mask = ev ? ev.getFlags() : flags.LIGHT_CANDLES;
10375
+ let mask = ev ? ev.getFlags() : LIGHT_CANDLES$1;
10339
10376
  if (typeof ev !== 'undefined') {
10340
10377
  // if linked event && dow == FRI, use Candle lighting time & title
10341
10378
  if (!isFriday) {
10342
- if (mask & (flags.LIGHT_CANDLES_TZEIS | flags.CHANUKAH_CANDLES)) {
10379
+ if (mask & (LIGHT_CANDLES_TZEIS$2 | flags.CHANUKAH_CANDLES)) {
10343
10380
  useHavdalahOffset = true;
10344
10381
  }
10345
10382
  else if (mask & flags.YOM_TOV_ENDS) {
@@ -10350,7 +10387,7 @@ function makeCandleEvent(ev, hd, options, isFriday, isSaturday) {
10350
10387
  }
10351
10388
  else if (isSaturday) {
10352
10389
  havdalahTitle = true;
10353
- mask = flags.LIGHT_CANDLES_TZEIS;
10390
+ mask = LIGHT_CANDLES_TZEIS$2;
10354
10391
  }
10355
10392
  // if offset is 0 or undefined, we'll use tzeit time
10356
10393
  const offset = useHavdalahOffset
@@ -10369,6 +10406,7 @@ function makeCandleEvent(ev, hd, options, isFriday, isSaturday) {
10369
10406
  return new HavdalahEvent(hd, mask, time, location, options.havdalahMins, ev, options);
10370
10407
  }
10371
10408
  else {
10409
+ mask |= LIGHT_CANDLES$1;
10372
10410
  return new CandleLightingEvent(hd, mask, time, location, ev, options);
10373
10411
  }
10374
10412
  }