@hebcal/core 5.4.11 → 5.5.0

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.0 */
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 = {
@@ -10326,7 +10361,7 @@ 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.0';
10330
10365
 
10331
10366
  /* eslint-disable max-len */
10332
10367
  /**