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