@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.cjs CHANGED
@@ -1,4 +1,4 @@
1
- /*! @hebcal/core v5.4.11 */
1
+ /*! @hebcal/core v5.5.0 */
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 = {
@@ -10328,7 +10363,7 @@ 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.0';
10332
10367
 
10333
10368
  /* eslint-disable max-len */
10334
10369
  /**