@hebcal/core 6.5.1 → 6.5.3

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 (126) hide show
  1. package/dist/bundle.js +5930 -5385
  2. package/dist/bundle.js.map +1 -1
  3. package/dist/bundle.min.js +17 -17
  4. package/dist/bundle.min.js.map +1 -1
  5. package/dist/eslint.config.mjs +1 -0
  6. package/dist/esm/CalOptions.d.ts +3 -4
  7. package/dist/esm/DailyLearning.d.ts +44 -7
  8. package/dist/esm/DailyLearning.js +45 -8
  9. package/dist/esm/DailyLearning.js.map +1 -1
  10. package/dist/esm/HebrewDateEvent.js +1 -1
  11. package/dist/esm/HolidayEvent.d.ts +34 -1
  12. package/dist/esm/HolidayEvent.js +35 -2
  13. package/dist/esm/HolidayEvent.js.map +1 -1
  14. package/dist/esm/MevarchimChodeshEvent.js +1 -1
  15. package/dist/esm/ParshaEvent.js +1 -1
  16. package/dist/esm/TimedEvent.d.ts +32 -3
  17. package/dist/esm/TimedEvent.js +33 -4
  18. package/dist/esm/TimedEvent.js.map +1 -1
  19. package/dist/esm/YomKippurKatanEvent.js +1 -1
  20. package/dist/esm/ashkenazi.po.d.ts +1 -0
  21. package/dist/esm/ashkenazi.po.js +2 -2
  22. package/dist/esm/ashkenazi.po.js.map +1 -1
  23. package/dist/esm/calendar.js +1 -1
  24. package/dist/esm/candles.d.ts +14 -1
  25. package/dist/esm/candles.js +15 -2
  26. package/dist/esm/candles.js.map +1 -1
  27. package/dist/esm/cities.json.js +1 -1
  28. package/dist/esm/event.d.ts +56 -13
  29. package/dist/esm/event.js +57 -14
  30. package/dist/esm/event.js.map +1 -1
  31. package/dist/esm/getStartAndEnd.js +10 -2
  32. package/dist/esm/getStartAndEnd.js.map +1 -1
  33. package/dist/esm/hallel.js +20 -28
  34. package/dist/esm/hallel.js.map +1 -1
  35. package/dist/esm/he-x-NoNikud.po.js +1 -1
  36. package/dist/esm/he.po.js +1 -1
  37. package/dist/esm/hebcal.d.ts +97 -19
  38. package/dist/esm/hebcal.js +102 -21
  39. package/dist/esm/hebcal.js.map +1 -1
  40. package/dist/esm/holidays.d.ts +21 -2
  41. package/dist/esm/holidays.js +22 -3
  42. package/dist/esm/holidays.js.map +1 -1
  43. package/dist/esm/index.d.ts +1 -1
  44. package/dist/esm/index.js +2 -1
  45. package/dist/esm/index.js.map +1 -1
  46. package/dist/esm/isAssurBemlacha.d.ts +24 -4
  47. package/dist/esm/isAssurBemlacha.js +25 -5
  48. package/dist/esm/isAssurBemlacha.js.map +1 -1
  49. package/dist/esm/isAveilut.d.ts +14 -3
  50. package/dist/esm/isAveilut.js +15 -4
  51. package/dist/esm/isAveilut.js.map +1 -1
  52. package/dist/esm/isFastDay.d.ts +13 -1
  53. package/dist/esm/isFastDay.js +14 -2
  54. package/dist/esm/isFastDay.js.map +1 -1
  55. package/dist/esm/locale.js +1 -1
  56. package/dist/esm/location.d.ts +96 -8
  57. package/dist/esm/location.js +101 -10
  58. package/dist/esm/location.js.map +1 -1
  59. package/dist/esm/modern.js +1 -1
  60. package/dist/esm/molad.d.ts +39 -7
  61. package/dist/esm/molad.js +40 -8
  62. package/dist/esm/molad.js.map +1 -1
  63. package/dist/esm/moladBase.js +1 -1
  64. package/dist/esm/moladDate.js +1 -1
  65. package/dist/esm/omer.d.ts +32 -4
  66. package/dist/esm/omer.js +33 -5
  67. package/dist/esm/omer.js.map +1 -1
  68. package/dist/esm/parshaName.js +1 -1
  69. package/dist/esm/parshaYear.d.ts +12 -1
  70. package/dist/esm/parshaYear.js +13 -2
  71. package/dist/esm/parshaYear.js.map +1 -1
  72. package/dist/esm/pkgVersion.d.ts +1 -1
  73. package/dist/esm/pkgVersion.js +2 -2
  74. package/dist/esm/pkgVersion.js.map +1 -1
  75. package/dist/esm/reformatTimeStr.js +1 -1
  76. package/dist/esm/sedra.d.ts +94 -14
  77. package/dist/esm/sedra.js +95 -15
  78. package/dist/esm/sedra.js.map +1 -1
  79. package/dist/esm/sefira.json.js +1 -1
  80. package/dist/esm/staticHolidays.js +1 -1
  81. package/dist/esm/tachanun.js +1 -1
  82. package/dist/esm/temporal-shim.js +1 -1
  83. package/dist/esm/zmanim.js +1 -1
  84. package/dist/src/CalOptions.d.ts +3 -4
  85. package/dist/src/DailyLearning.d.ts +44 -7
  86. package/dist/src/DailyLearning.js +44 -7
  87. package/dist/src/HolidayEvent.d.ts +34 -1
  88. package/dist/src/HolidayEvent.js +34 -1
  89. package/dist/src/TimedEvent.d.ts +32 -3
  90. package/dist/src/TimedEvent.js +32 -3
  91. package/dist/src/ashkenazi.po.d.ts +1 -0
  92. package/dist/src/ashkenazi.po.js +1 -1
  93. package/dist/src/candles.d.ts +14 -1
  94. package/dist/src/candles.js +14 -1
  95. package/dist/src/event.d.ts +56 -13
  96. package/dist/src/event.js +56 -13
  97. package/dist/src/getStartAndEnd.js +9 -1
  98. package/dist/src/hallel.js +19 -27
  99. package/dist/src/hebcal.d.ts +97 -19
  100. package/dist/src/hebcal.js +101 -20
  101. package/dist/src/holidays.d.ts +21 -2
  102. package/dist/src/holidays.js +21 -2
  103. package/dist/src/index.d.ts +1 -1
  104. package/dist/src/index.js +1 -0
  105. package/dist/src/isAssurBemlacha.d.ts +24 -4
  106. package/dist/src/isAssurBemlacha.js +24 -4
  107. package/dist/src/isAveilut.d.ts +14 -3
  108. package/dist/src/isAveilut.js +14 -3
  109. package/dist/src/isFastDay.d.ts +13 -1
  110. package/dist/src/isFastDay.js +13 -1
  111. package/dist/src/location.d.ts +96 -8
  112. package/dist/src/location.js +100 -9
  113. package/dist/src/molad.d.ts +39 -7
  114. package/dist/src/molad.js +39 -7
  115. package/dist/src/omer.d.ts +32 -4
  116. package/dist/src/omer.js +32 -4
  117. package/dist/src/parshaYear.d.ts +12 -1
  118. package/dist/src/parshaYear.js +12 -1
  119. package/dist/src/pkgVersion.d.ts +1 -1
  120. package/dist/src/pkgVersion.js +1 -1
  121. package/dist/src/sedra.d.ts +94 -14
  122. package/dist/src/sedra.js +94 -14
  123. package/package.json +11 -7
  124. package/po/ashkenazi.po +240 -0
  125. package/po/he-x-NoNikud.po +58 -0
  126. package/po/he.po +650 -0
@@ -1,6 +1,7 @@
1
- /*! @hebcal/core v6.5.1, distributed under GPLv2 https://www.gnu.org/licenses/gpl-2.0.txt */
1
+ /*! @hebcal/core v6.5.3, distributed under GPLv2 https://www.gnu.org/licenses/gpl-2.0.txt */
2
2
  import { GeoLocation } from '@hebcal/noaa';
3
3
  import citiesJson from './cities.json.js';
4
+ import QuickLRU from 'quick-lru';
4
5
 
5
6
  /*
6
7
  Hebcal - A Jewish Calendar Generator
@@ -40,7 +41,9 @@ const ZIPCODES_TZ_MAP = {
40
41
  '16': 'Pacific/Chuuk', // Micronesia (GMT +11:00)
41
42
  };
42
43
  /** @private */
43
- const timeFormatCache = new Map();
44
+ const timeFormatCache = new QuickLRU({
45
+ maxSize: 120,
46
+ });
44
47
  /**
45
48
  * Gets a 24-hour time formatter (e.g. 07:41 or 20:03) from cache
46
49
  * or makes a new one if needed
@@ -66,7 +69,31 @@ function initClassicCities() {
66
69
  Location.addLocation(cityName, location);
67
70
  }
68
71
  }
69
- /** Class representing Location */
72
+ /**
73
+ * Class representing a geographic location for use with candle-lighting,
74
+ * havdalah, and zmanim calculations.
75
+ *
76
+ * Extends {@link GeoLocation} from `@hebcal/noaa` with Jewish-calendar
77
+ * specific data: an Israel/Diaspora flag, ISO country code, and an optional
78
+ * geographic identifier. Also provides {@link Location.lookup} for ~60
79
+ * built-in "classic" Hebcal cities.
80
+ *
81
+ * @example
82
+ * import {Location} from '@hebcal/core';
83
+ *
84
+ * // Create a location for a custom address
85
+ * const loc = new Location(
86
+ * 41.85003, // latitude
87
+ * -87.65005, // longitude
88
+ * false, // not in Israel
89
+ * 'America/Chicago',
90
+ * 'Chicago, Illinois, USA',
91
+ * 'US'
92
+ * );
93
+ *
94
+ * // Or look up a built-in classic city
95
+ * const tlv = Location.lookup('Tel Aviv');
96
+ */
70
97
  class Location extends GeoLocation {
71
98
  il;
72
99
  cc;
@@ -109,14 +136,31 @@ class Location extends GeoLocation {
109
136
  this.cc = countryCode;
110
137
  this.geoid = geoid;
111
138
  }
139
+ /**
140
+ * Returns `true` if this location is in Israel (uses the Israeli holiday
141
+ * and Torah-reading schedule), `false` for the Diaspora.
142
+ */
112
143
  getIsrael() {
113
144
  return this.il;
114
145
  }
146
+ /**
147
+ * Returns the full descriptive location name passed to the constructor,
148
+ * or `null` if no name was provided.
149
+ * @example
150
+ * Location.lookup('San Francisco')?.getName(); // 'San Francisco, California, USA'
151
+ */
115
152
  getName() {
116
153
  return this.getLocationName();
117
154
  }
118
155
  /**
119
- * Returns the location name, up to the first comma
156
+ * Returns the location name truncated at the first comma. Useful for
157
+ * compact display where only the city name is desired.
158
+ *
159
+ * Special-cased so that US locations of the form `"Washington, DC"` or
160
+ * `"Washington, D.C., ..."` keep the `DC` / `D.C.` suffix attached.
161
+ * @example
162
+ * Location.lookup('San Francisco')?.getShortName(); // 'San Francisco'
163
+ * Location.lookup('Washington DC')?.getShortName(); // 'Washington, DC'
120
164
  */
121
165
  getShortName() {
122
166
  const name = this.getLocationName();
@@ -135,18 +179,37 @@ class Location extends GeoLocation {
135
179
  }
136
180
  return name.substring(0, comma);
137
181
  }
182
+ /**
183
+ * Returns the ISO 3166 alpha-2 country code (e.g. `"US"`, `"IL"`, `"FR"`)
184
+ * passed to the constructor, or `undefined` if none was provided.
185
+ */
138
186
  getCountryCode() {
139
187
  return this.cc;
140
188
  }
189
+ /**
190
+ * Returns the Olson timezone identifier (e.g. `"America/Chicago"`).
191
+ * Alias for `getTimeZone()` from the parent `GeoLocation` class.
192
+ */
141
193
  getTzid() {
142
194
  return this.getTimeZone();
143
195
  }
144
196
  /**
145
- * Gets a 24-hour time formatter (e.g. 07:41 or 20:03) for this location
197
+ * Returns a cached 24-hour `Intl.DateTimeFormat` (e.g. `07:41` or `20:03`)
198
+ * configured for this location's timezone. Formatters are memoized by
199
+ * timezone so repeated calls do not allocate.
200
+ * @example
201
+ * const loc = Location.lookup('Tel Aviv')!;
202
+ * const fmt = loc.getTimeFormatter();
203
+ * fmt.format(new Date()); // e.g. '18:42'
146
204
  */
147
205
  getTimeFormatter() {
148
206
  return getFormatter(this.getTimeZone());
149
207
  }
208
+ /**
209
+ * Returns the optional geographic identifier passed to the constructor
210
+ * (typically a GeoNames numeric ID or a US Zip Code string), or
211
+ * `undefined` if none was provided.
212
+ */
150
213
  getGeoId() {
151
214
  return this.geoid;
152
215
  }
@@ -166,7 +229,13 @@ class Location extends GeoLocation {
166
229
  * 'San Diego', 'San Francisco', 'Sao Paulo', 'Seattle', 'Sydney',
167
230
  * 'Tel Aviv', 'Tiberias', 'Toronto', 'Vancouver', 'White Plains',
168
231
  * 'Washington DC', 'Worcester'
169
- * @param name
232
+ *
233
+ * Lookups are case-insensitive. Returns `undefined` if the name is not
234
+ * recognized. The list can be extended with {@link Location.addLocation}.
235
+ * @example
236
+ * const loc = Location.lookup('San Francisco');
237
+ * console.log(loc?.getTzid()); // 'America/Los_Angeles'
238
+ * @param name case-insensitive classic city name
170
239
  */
171
240
  static lookup(name) {
172
241
  if (classicCities.size === 0) {
@@ -174,11 +243,24 @@ class Location extends GeoLocation {
174
243
  }
175
244
  return classicCities.get(name.toLowerCase());
176
245
  }
246
+ /**
247
+ * Returns a JSON-serialized representation of this Location.
248
+ * Useful for debugging and structured logging.
249
+ */
177
250
  toString() {
178
251
  return JSON.stringify(this);
179
252
  }
180
253
  /**
181
- * Converts legacy Hebcal timezone to a standard Olson tzid.
254
+ * Converts a legacy Hebcal-style timezone (a numeric GMT offset plus a
255
+ * coarse DST region) to a standard IANA/Olson timezone ID.
256
+ *
257
+ * This exists to migrate data from older Hebcal versions that stored
258
+ * timezones as GMT offset + DST scheme rather than as a full tzid.
259
+ * @example
260
+ * Location.legacyTzToTzid(2, 'israel'); // 'Asia/Jerusalem'
261
+ * Location.legacyTzToTzid(0, 'eu'); // 'Europe/London'
262
+ * Location.legacyTzToTzid(0, 'none'); // 'UTC'
263
+ * Location.legacyTzToTzid(-5, 'none'); // 'Etc/GMT-5'
182
264
  * @param tz integer, GMT offset in hours
183
265
  * @param dst 'none', 'eu', 'usa', or 'israel'
184
266
  */
@@ -236,9 +318,18 @@ class Location extends GeoLocation {
236
318
  }
237
319
  }
238
320
  /**
239
- * Adds a location name for `Location.lookup()` only if the name isn't
240
- * already being used. Returns `false` if the name is already taken
241
- * and `true` if successfully added.
321
+ * Registers a new named location with the built-in `Location.lookup()`
322
+ * registry. Names are stored case-insensitively. Returns `false` if a
323
+ * location with the same (lower-cased) name is already registered, and
324
+ * `true` if successfully added.
325
+ *
326
+ * Use this to extend the built-in set of ~60 classic Hebcal cities with
327
+ * your own custom locations.
328
+ * @example
329
+ * const tlv = new Location(32.0853, 34.7818, true,
330
+ * 'Asia/Tel_Aviv', 'My Office, Tel Aviv', 'IL');
331
+ * Location.addLocation('My Office', tlv); // true
332
+ * Location.lookup('my office')?.getTzid(); // 'Asia/Tel_Aviv'
242
333
  */
243
334
  static addLocation(cityName, location) {
244
335
  const name = cityName.toLowerCase();
@@ -1 +1 @@
1
- {"version":3,"file":"location.js","sources":["../../../src/location.ts"],"sourcesContent":["/*\n Hebcal - A Jewish Calendar Generator\n Copyright (c) 1994-2020 Danny Sadinoff\n Portions copyright Eyal Schachter and Michael J. Radwin\n\n https://github.com/hebcal/hebcal-es6\n\n This program is free software; you can redistribute it and/or\n modify it under the terms of the GNU General Public License\n as published by the Free Software Foundation; either version 2\n of the License, or (at your option) any later version.\n\n This program is distributed in the hope that it will be useful,\n but WITHOUT ANY WARRANTY; without even the implied warranty of\n MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n GNU General Public License for more details.\n\n You should have received a copy of the GNU General Public License\n along with this program. If not, see <http://www.gnu.org/licenses/>.\n */\nimport {GeoLocation} from '@hebcal/noaa';\nimport citiesJson from './cities.json';\n\nconst classicCities = new Map<string, Location>();\n\n// Zip-Codes.com TimeZone IDs\nconst ZIPCODES_TZ_MAP: Record<string, string> = {\n '0': 'UTC',\n '4': 'America/Puerto_Rico', // Atlantic (GMT -04:00)\n '5': 'America/New_York', // Eastern (GMT -05:00)\n '6': 'America/Chicago', // Central (GMT -06:00)\n '7': 'America/Denver', // Mountain (GMT -07:00)\n '8': 'America/Los_Angeles', // Pacific (GMT -08:00)\n '9': 'America/Anchorage', // Alaska (GMT -09:00)\n '10': 'Pacific/Honolulu', // Hawaii-Aleutian Islands (GMT -10:00)\n '11': 'Pacific/Pago_Pago', // American Samoa (GMT -11:00)\n '13': 'Pacific/Funafuti', // Marshall Islands (GMT +12:00)\n '14': 'Pacific/Guam', // Guam (GMT +10:00)\n '15': 'Pacific/Palau', // Palau (GMT +9:00)\n '16': 'Pacific/Chuuk', // Micronesia (GMT +11:00)\n} as const;\n\n/** @private */\nconst timeFormatCache = new Map<string, Intl.DateTimeFormat>();\n\n/**\n * Gets a 24-hour time formatter (e.g. 07:41 or 20:03) from cache\n * or makes a new one if needed\n * @private\n */\nfunction getFormatter(tzid: string): Intl.DateTimeFormat {\n const fmt = timeFormatCache.get(tzid);\n if (fmt) return fmt;\n const f = new Intl.DateTimeFormat('en-US', {\n timeZone: tzid,\n hour: 'numeric',\n minute: 'numeric',\n hour12: false,\n });\n timeFormatCache.set(tzid, f);\n return f;\n}\n\nfunction initClassicCities() {\n for (const entry of citiesJson) {\n const [cityName, cc, lat, lng, tzid, elev] = entry.split('|');\n const location = new Location(\n +lat,\n +lng,\n cc === 'IL',\n tzid,\n cityName,\n cc,\n undefined,\n +elev\n );\n Location.addLocation(cityName, location);\n }\n}\n\n/** Class representing Location */\nexport class Location extends GeoLocation {\n private readonly il: boolean;\n private readonly cc?: string;\n private readonly geoid?: string | number;\n admin1?: string;\n stateName?: string;\n geo?: 'zip' | 'geoname';\n zip?: string;\n population?: number;\n asciiname?: string;\n\n /**\n * Initialize a Location instance\n * @param latitude - Latitude as a decimal, valid range -90 thru +90 (e.g. 41.85003)\n * @param longitude - Longitude as a decimal, valid range -180 thru +180 (e.g. -87.65005)\n * @param il - in Israel (true) or Diaspora (false)\n * @param tzid - Olson timezone ID, e.g. \"America/Chicago\"\n * @param [cityName] - optional descriptive city name\n * @param [countryCode] - ISO 3166 alpha-2 country code (e.g. \"FR\")\n * @param [geoid] - optional string or numeric geographic ID\n * @param [elevation] - in meters (default `0`)\n */\n constructor(\n latitude: number,\n longitude: number,\n il: boolean,\n tzid: string,\n cityName?: string,\n countryCode?: string,\n geoid?: string | number,\n elevation?: number\n ) {\n const lat = typeof latitude === 'number' ? latitude : parseFloat(latitude);\n if (isNaN(lat) || lat < -90 || lat > 90) {\n throw new RangeError(`Latitude ${latitude} out of range [-90,90]`);\n }\n const long =\n typeof longitude === 'number' ? longitude : parseFloat(longitude);\n if (isNaN(long) || long < -180 || long > 180) {\n throw new RangeError(`Longitude ${longitude} out of range [-180,180]`);\n }\n if (!tzid) {\n throw new RangeError('Invalid timezone');\n }\n const elev = typeof elevation === 'number' && elevation > 0 ? elevation : 0;\n if (cityName && typeof cityName !== 'string') {\n cityName = String(cityName);\n }\n super(cityName || null, lat, long, elev, tzid);\n this.il = Boolean(il);\n this.cc = countryCode;\n this.geoid = geoid;\n }\n\n getIsrael(): boolean {\n return this.il;\n }\n\n getName(): string | null {\n return this.getLocationName();\n }\n\n /**\n * Returns the location name, up to the first comma\n */\n getShortName(): string | null {\n const name = this.getLocationName();\n if (!name) return name;\n const comma = name.indexOf(', ');\n if (comma === -1) return name;\n if (this.cc === 'US' && name[comma + 2] === 'D') {\n if (name[comma + 3] === 'C') {\n return name.substring(0, comma + 4);\n } else if (name[comma + 3] === '.' && name[comma + 4] === 'C') {\n return name.substring(0, comma + 6);\n }\n }\n return name.substring(0, comma);\n }\n\n getCountryCode(): string | undefined {\n return this.cc;\n }\n\n getTzid(): string {\n return this.getTimeZone();\n }\n\n /**\n * Gets a 24-hour time formatter (e.g. 07:41 or 20:03) for this location\n */\n getTimeFormatter(): Intl.DateTimeFormat {\n return getFormatter(this.getTimeZone());\n }\n\n getGeoId(): string | number | undefined {\n return this.geoid;\n }\n\n /**\n * Creates a location object from one of 60 \"classic\" Hebcal city names.\n * The following city names are supported:\n * 'Ashdod', 'Atlanta', 'Austin', 'Baghdad', 'Beer Sheva',\n * 'Berlin', 'Baltimore', 'Bogota', 'Boston', 'Budapest',\n * 'Buenos Aires', 'Buffalo', 'Chicago', 'Cincinnati', 'Cleveland',\n * 'Dallas', 'Denver', 'Detroit', 'Eilat', 'Gibraltar', 'Haifa',\n * 'Hawaii', 'Helsinki', 'Houston', 'Jerusalem', 'Johannesburg',\n * 'Kiev', 'La Paz', 'Livingston', 'Las Vegas', 'London', 'Los Angeles',\n * 'Marseilles', 'Miami', 'Minneapolis', 'Melbourne', 'Mexico City',\n * 'Montreal', 'Moscow', 'New York', 'Omaha', 'Ottawa', 'Panama City',\n * 'Paris', 'Pawtucket', 'Petach Tikvah', 'Philadelphia', 'Phoenix',\n * 'Pittsburgh', 'Providence', 'Portland', 'Saint Louis', 'Saint Petersburg',\n * 'San Diego', 'San Francisco', 'Sao Paulo', 'Seattle', 'Sydney',\n * 'Tel Aviv', 'Tiberias', 'Toronto', 'Vancouver', 'White Plains',\n * 'Washington DC', 'Worcester'\n * @param name\n */\n static lookup(name: string): Location | undefined {\n if (classicCities.size === 0) {\n initClassicCities();\n }\n return classicCities.get(name.toLowerCase());\n }\n\n toString(): string {\n return JSON.stringify(this);\n }\n\n /**\n * Converts legacy Hebcal timezone to a standard Olson tzid.\n * @param tz integer, GMT offset in hours\n * @param dst 'none', 'eu', 'usa', or 'israel'\n */\n static legacyTzToTzid(tz: number, dst: string): string | undefined {\n tz = +tz;\n if (dst === 'none') {\n if (tz === 0) {\n return 'UTC';\n } else {\n const plus = tz > 0 ? '+' : '';\n return `Etc/GMT${plus}${tz}`;\n }\n } else if (tz === 2 && dst === 'israel') {\n return 'Asia/Jerusalem';\n } else if (dst === 'eu') {\n switch (tz) {\n case -2:\n return 'Atlantic/Cape_Verde';\n case -1:\n return 'Atlantic/Azores';\n case 0:\n return 'Europe/London';\n case 1:\n return 'Europe/Paris';\n case 2:\n return 'Europe/Athens';\n default:\n break;\n }\n } else if (dst === 'usa') {\n return ZIPCODES_TZ_MAP[String(tz * -1)];\n }\n return undefined;\n }\n\n /**\n * Converts timezone info from Zip-Codes.com to a standard Olson tzid.\n * @example\n * Location.getUsaTzid('AZ', 7, 'Y') // 'America/Denver'\n * @param state two-letter all-caps US state abbreviation like 'CA'\n * @param tz positive number, 5=America/New_York, 8=America/Los_Angeles\n * @param dst single char 'Y' or 'N'\n */\n static getUsaTzid(state: string, tz: number, dst: string): string {\n tz = +tz;\n if (tz === 10 && state === 'AK') {\n return 'America/Adak';\n } else if (tz === 7 && state === 'AZ') {\n return dst === 'Y' ? 'America/Denver' : 'America/Phoenix';\n } else {\n return ZIPCODES_TZ_MAP[tz];\n }\n }\n\n /**\n * Adds a location name for `Location.lookup()` only if the name isn't\n * already being used. Returns `false` if the name is already taken\n * and `true` if successfully added.\n */\n static addLocation(cityName: string, location: Location): boolean {\n const name = cityName.toLowerCase();\n if (classicCities.has(name)) {\n return false;\n }\n classicCities.set(name, location);\n return true;\n }\n}\n"],"names":[],"mappings":";;;;AAAA;;;;;;;;;;;;;;;;;;;AAmBG;AAIH,MAAM,aAAa,GAAG,IAAI,GAAG,EAAoB;AAEjD;AACA,MAAM,eAAe,GAA2B;AAC9C,IAAA,GAAG,EAAE,KAAK;IACV,GAAG,EAAE,qBAAqB;IAC1B,GAAG,EAAE,kBAAkB;IACvB,GAAG,EAAE,iBAAiB;IACtB,GAAG,EAAE,gBAAgB;IACrB,GAAG,EAAE,qBAAqB;IAC1B,GAAG,EAAE,mBAAmB;IACxB,IAAI,EAAE,kBAAkB;IACxB,IAAI,EAAE,mBAAmB;IACzB,IAAI,EAAE,kBAAkB;IACxB,IAAI,EAAE,cAAc;IACpB,IAAI,EAAE,eAAe;IACrB,IAAI,EAAE,eAAe;CACb;AAEV;AACA,MAAM,eAAe,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,EAAE,KAAK,EAAE,IAAI,KAAK,KAAK,IAAI,EAAE;AAC/B,YAAA,OAAO,cAAc;QACvB;aAAO,IAAI,EAAE,KAAK,CAAC,IAAI,KAAK,KAAK,IAAI,EAAE;YACrC,OAAO,GAAG,KAAK,GAAG,GAAG,gBAAgB,GAAG,iBAAiB;QAC3D;aAAO;AACL,YAAA,OAAO,eAAe,CAAC,EAAE,CAAC;QAC5B;IACF;AAEA;;;;AAIG;AACH,IAAA,OAAO,WAAW,CAAC,QAAgB,EAAE,QAAkB,EAAA;AACrD,QAAA,MAAM,IAAI,GAAG,QAAQ,CAAC,WAAW,EAAE;AACnC,QAAA,IAAI,aAAa,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE;AAC3B,YAAA,OAAO,KAAK;QACd;AACA,QAAA,aAAa,CAAC,GAAG,CAAC,IAAI,EAAE,QAAQ,CAAC;AACjC,QAAA,OAAO,IAAI;IACb;AACD;;;;"}
1
+ {"version":3,"file":"location.js","sources":["../../../src/location.ts"],"sourcesContent":["/*\n Hebcal - A Jewish Calendar Generator\n Copyright (c) 1994-2020 Danny Sadinoff\n Portions copyright Eyal Schachter and Michael J. Radwin\n\n https://github.com/hebcal/hebcal-es6\n\n This program is free software; you can redistribute it and/or\n modify it under the terms of the GNU General Public License\n as published by the Free Software Foundation; either version 2\n of the License, or (at your option) any later version.\n\n This program is distributed in the hope that it will be useful,\n but WITHOUT ANY WARRANTY; without even the implied warranty of\n MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n GNU General Public License for more details.\n\n You should have received a copy of the GNU General Public License\n along with this program. If not, see <http://www.gnu.org/licenses/>.\n */\nimport {GeoLocation} from '@hebcal/noaa';\nimport citiesJson from './cities.json';\nimport QuickLRU from 'quick-lru';\n\nconst classicCities = new Map<string, Location>();\n\n// Zip-Codes.com TimeZone IDs\nconst ZIPCODES_TZ_MAP: Record<string, string> = {\n '0': 'UTC',\n '4': 'America/Puerto_Rico', // Atlantic (GMT -04:00)\n '5': 'America/New_York', // Eastern (GMT -05:00)\n '6': 'America/Chicago', // Central (GMT -06:00)\n '7': 'America/Denver', // Mountain (GMT -07:00)\n '8': 'America/Los_Angeles', // Pacific (GMT -08:00)\n '9': 'America/Anchorage', // Alaska (GMT -09:00)\n '10': 'Pacific/Honolulu', // Hawaii-Aleutian Islands (GMT -10:00)\n '11': 'Pacific/Pago_Pago', // American Samoa (GMT -11:00)\n '13': 'Pacific/Funafuti', // Marshall Islands (GMT +12:00)\n '14': 'Pacific/Guam', // Guam (GMT +10:00)\n '15': 'Pacific/Palau', // Palau (GMT +9:00)\n '16': 'Pacific/Chuuk', // Micronesia (GMT +11:00)\n} as const;\n\n/** @private */\nconst timeFormatCache = new QuickLRU<string, Intl.DateTimeFormat>({\n maxSize: 120,\n});\n\n/**\n * Gets a 24-hour time formatter (e.g. 07:41 or 20:03) from cache\n * or makes a new one if needed\n * @private\n */\nfunction getFormatter(tzid: string): Intl.DateTimeFormat {\n const fmt = timeFormatCache.get(tzid);\n if (fmt) return fmt;\n const f = new Intl.DateTimeFormat('en-US', {\n timeZone: tzid,\n hour: 'numeric',\n minute: 'numeric',\n hour12: false,\n });\n timeFormatCache.set(tzid, f);\n return f;\n}\n\nfunction initClassicCities() {\n for (const entry of citiesJson) {\n const [cityName, cc, lat, lng, tzid, elev] = entry.split('|');\n const location = new Location(\n +lat,\n +lng,\n cc === 'IL',\n tzid,\n cityName,\n cc,\n undefined,\n +elev\n );\n Location.addLocation(cityName, location);\n }\n}\n\n/**\n * Class representing a geographic location for use with candle-lighting,\n * havdalah, and zmanim calculations.\n *\n * Extends {@link GeoLocation} from `@hebcal/noaa` with Jewish-calendar\n * specific data: an Israel/Diaspora flag, ISO country code, and an optional\n * geographic identifier. Also provides {@link Location.lookup} for ~60\n * built-in \"classic\" Hebcal cities.\n *\n * @example\n * import {Location} from '@hebcal/core';\n *\n * // Create a location for a custom address\n * const loc = new Location(\n * 41.85003, // latitude\n * -87.65005, // longitude\n * false, // not in Israel\n * 'America/Chicago',\n * 'Chicago, Illinois, USA',\n * 'US'\n * );\n *\n * // Or look up a built-in classic city\n * const tlv = Location.lookup('Tel Aviv');\n */\nexport class Location extends GeoLocation {\n private readonly il: boolean;\n private readonly cc?: string;\n private readonly geoid?: string | number;\n admin1?: string;\n stateName?: string;\n geo?: 'zip' | 'geoname';\n zip?: string;\n population?: number;\n asciiname?: string;\n\n /**\n * Initialize a Location instance\n * @param latitude - Latitude as a decimal, valid range -90 thru +90 (e.g. 41.85003)\n * @param longitude - Longitude as a decimal, valid range -180 thru +180 (e.g. -87.65005)\n * @param il - in Israel (true) or Diaspora (false)\n * @param tzid - Olson timezone ID, e.g. \"America/Chicago\"\n * @param [cityName] - optional descriptive city name\n * @param [countryCode] - ISO 3166 alpha-2 country code (e.g. \"FR\")\n * @param [geoid] - optional string or numeric geographic ID\n * @param [elevation] - in meters (default `0`)\n */\n constructor(\n latitude: number,\n longitude: number,\n il: boolean,\n tzid: string,\n cityName?: string,\n countryCode?: string,\n geoid?: string | number,\n elevation?: number\n ) {\n const lat = typeof latitude === 'number' ? latitude : parseFloat(latitude);\n if (isNaN(lat) || lat < -90 || lat > 90) {\n throw new RangeError(`Latitude ${latitude} out of range [-90,90]`);\n }\n const long =\n typeof longitude === 'number' ? longitude : parseFloat(longitude);\n if (isNaN(long) || long < -180 || long > 180) {\n throw new RangeError(`Longitude ${longitude} out of range [-180,180]`);\n }\n if (!tzid) {\n throw new RangeError('Invalid timezone');\n }\n const elev = typeof elevation === 'number' && elevation > 0 ? elevation : 0;\n if (cityName && typeof cityName !== 'string') {\n cityName = String(cityName);\n }\n super(cityName || null, lat, long, elev, tzid);\n this.il = Boolean(il);\n this.cc = countryCode;\n this.geoid = geoid;\n }\n\n /**\n * Returns `true` if this location is in Israel (uses the Israeli holiday\n * and Torah-reading schedule), `false` for the Diaspora.\n */\n getIsrael(): boolean {\n return this.il;\n }\n\n /**\n * Returns the full descriptive location name passed to the constructor,\n * or `null` if no name was provided.\n * @example\n * Location.lookup('San Francisco')?.getName(); // 'San Francisco, California, USA'\n */\n getName(): string | null {\n return this.getLocationName();\n }\n\n /**\n * Returns the location name truncated at the first comma. Useful for\n * compact display where only the city name is desired.\n *\n * Special-cased so that US locations of the form `\"Washington, DC\"` or\n * `\"Washington, D.C., ...\"` keep the `DC` / `D.C.` suffix attached.\n * @example\n * Location.lookup('San Francisco')?.getShortName(); // 'San Francisco'\n * Location.lookup('Washington DC')?.getShortName(); // 'Washington, DC'\n */\n getShortName(): string | null {\n const name = this.getLocationName();\n if (!name) return name;\n const comma = name.indexOf(', ');\n if (comma === -1) return name;\n if (this.cc === 'US' && name[comma + 2] === 'D') {\n if (name[comma + 3] === 'C') {\n return name.substring(0, comma + 4);\n } else if (name[comma + 3] === '.' && name[comma + 4] === 'C') {\n return name.substring(0, comma + 6);\n }\n }\n return name.substring(0, comma);\n }\n\n /**\n * Returns the ISO 3166 alpha-2 country code (e.g. `\"US\"`, `\"IL\"`, `\"FR\"`)\n * passed to the constructor, or `undefined` if none was provided.\n */\n getCountryCode(): string | undefined {\n return this.cc;\n }\n\n /**\n * Returns the Olson timezone identifier (e.g. `\"America/Chicago\"`).\n * Alias for `getTimeZone()` from the parent `GeoLocation` class.\n */\n getTzid(): string {\n return this.getTimeZone();\n }\n\n /**\n * Returns a cached 24-hour `Intl.DateTimeFormat` (e.g. `07:41` or `20:03`)\n * configured for this location's timezone. Formatters are memoized by\n * timezone so repeated calls do not allocate.\n * @example\n * const loc = Location.lookup('Tel Aviv')!;\n * const fmt = loc.getTimeFormatter();\n * fmt.format(new Date()); // e.g. '18:42'\n */\n getTimeFormatter(): Intl.DateTimeFormat {\n return getFormatter(this.getTimeZone());\n }\n\n /**\n * Returns the optional geographic identifier passed to the constructor\n * (typically a GeoNames numeric ID or a US Zip Code string), or\n * `undefined` if none was provided.\n */\n getGeoId(): string | number | undefined {\n return this.geoid;\n }\n\n /**\n * Creates a location object from one of 60 \"classic\" Hebcal city names.\n * The following city names are supported:\n * 'Ashdod', 'Atlanta', 'Austin', 'Baghdad', 'Beer Sheva',\n * 'Berlin', 'Baltimore', 'Bogota', 'Boston', 'Budapest',\n * 'Buenos Aires', 'Buffalo', 'Chicago', 'Cincinnati', 'Cleveland',\n * 'Dallas', 'Denver', 'Detroit', 'Eilat', 'Gibraltar', 'Haifa',\n * 'Hawaii', 'Helsinki', 'Houston', 'Jerusalem', 'Johannesburg',\n * 'Kiev', 'La Paz', 'Livingston', 'Las Vegas', 'London', 'Los Angeles',\n * 'Marseilles', 'Miami', 'Minneapolis', 'Melbourne', 'Mexico City',\n * 'Montreal', 'Moscow', 'New York', 'Omaha', 'Ottawa', 'Panama City',\n * 'Paris', 'Pawtucket', 'Petach Tikvah', 'Philadelphia', 'Phoenix',\n * 'Pittsburgh', 'Providence', 'Portland', 'Saint Louis', 'Saint Petersburg',\n * 'San Diego', 'San Francisco', 'Sao Paulo', 'Seattle', 'Sydney',\n * 'Tel Aviv', 'Tiberias', 'Toronto', 'Vancouver', 'White Plains',\n * 'Washington DC', 'Worcester'\n *\n * Lookups are case-insensitive. Returns `undefined` if the name is not\n * recognized. The list can be extended with {@link Location.addLocation}.\n * @example\n * const loc = Location.lookup('San Francisco');\n * console.log(loc?.getTzid()); // 'America/Los_Angeles'\n * @param name case-insensitive classic city name\n */\n static lookup(name: string): Location | undefined {\n if (classicCities.size === 0) {\n initClassicCities();\n }\n return classicCities.get(name.toLowerCase());\n }\n\n /**\n * Returns a JSON-serialized representation of this Location.\n * Useful for debugging and structured logging.\n */\n toString(): string {\n return JSON.stringify(this);\n }\n\n /**\n * Converts a legacy Hebcal-style timezone (a numeric GMT offset plus a\n * coarse DST region) to a standard IANA/Olson timezone ID.\n *\n * This exists to migrate data from older Hebcal versions that stored\n * timezones as GMT offset + DST scheme rather than as a full tzid.\n * @example\n * Location.legacyTzToTzid(2, 'israel'); // 'Asia/Jerusalem'\n * Location.legacyTzToTzid(0, 'eu'); // 'Europe/London'\n * Location.legacyTzToTzid(0, 'none'); // 'UTC'\n * Location.legacyTzToTzid(-5, 'none'); // 'Etc/GMT-5'\n * @param tz integer, GMT offset in hours\n * @param dst 'none', 'eu', 'usa', or 'israel'\n */\n static legacyTzToTzid(tz: number, dst: string): string | undefined {\n tz = +tz;\n if (dst === 'none') {\n if (tz === 0) {\n return 'UTC';\n } else {\n const plus = tz > 0 ? '+' : '';\n return `Etc/GMT${plus}${tz}`;\n }\n } else if (tz === 2 && dst === 'israel') {\n return 'Asia/Jerusalem';\n } else if (dst === 'eu') {\n switch (tz) {\n case -2:\n return 'Atlantic/Cape_Verde';\n case -1:\n return 'Atlantic/Azores';\n case 0:\n return 'Europe/London';\n case 1:\n return 'Europe/Paris';\n case 2:\n return 'Europe/Athens';\n default:\n break;\n }\n } else if (dst === 'usa') {\n return ZIPCODES_TZ_MAP[String(tz * -1)];\n }\n return undefined;\n }\n\n /**\n * Converts timezone info from Zip-Codes.com to a standard Olson tzid.\n * @example\n * Location.getUsaTzid('AZ', 7, 'Y') // 'America/Denver'\n * @param state two-letter all-caps US state abbreviation like 'CA'\n * @param tz positive number, 5=America/New_York, 8=America/Los_Angeles\n * @param dst single char 'Y' or 'N'\n */\n static getUsaTzid(state: string, tz: number, dst: string): string {\n tz = +tz;\n if (tz === 10 && state === 'AK') {\n return 'America/Adak';\n } else if (tz === 7 && state === 'AZ') {\n return dst === 'Y' ? 'America/Denver' : 'America/Phoenix';\n } else {\n return ZIPCODES_TZ_MAP[tz];\n }\n }\n\n /**\n * Registers a new named location with the built-in `Location.lookup()`\n * registry. Names are stored case-insensitively. Returns `false` if a\n * location with the same (lower-cased) name is already registered, and\n * `true` if successfully added.\n *\n * Use this to extend the built-in set of ~60 classic Hebcal cities with\n * your own custom locations.\n * @example\n * const tlv = new Location(32.0853, 34.7818, true,\n * 'Asia/Tel_Aviv', 'My Office, Tel Aviv', 'IL');\n * Location.addLocation('My Office', tlv); // true\n * Location.lookup('my office')?.getTzid(); // 'Asia/Tel_Aviv'\n */\n static addLocation(cityName: string, location: Location): boolean {\n const name = cityName.toLowerCase();\n if (classicCities.has(name)) {\n return false;\n }\n classicCities.set(name, location);\n return true;\n }\n}\n"],"names":[],"mappings":";;;;;AAAA;;;;;;;;;;;;;;;;;;;AAmBG;AAKH,MAAM,aAAa,GAAG,IAAI,GAAG,EAAoB;AAEjD;AACA,MAAM,eAAe,GAA2B;AAC9C,IAAA,GAAG,EAAE,KAAK;IACV,GAAG,EAAE,qBAAqB;IAC1B,GAAG,EAAE,kBAAkB;IACvB,GAAG,EAAE,iBAAiB;IACtB,GAAG,EAAE,gBAAgB;IACrB,GAAG,EAAE,qBAAqB;IAC1B,GAAG,EAAE,mBAAmB;IACxB,IAAI,EAAE,kBAAkB;IACxB,IAAI,EAAE,mBAAmB;IACzB,IAAI,EAAE,kBAAkB;IACxB,IAAI,EAAE,cAAc;IACpB,IAAI,EAAE,eAAe;IACrB,IAAI,EAAE,eAAe;CACb;AAEV;AACA,MAAM,eAAe,GAAG,IAAI,QAAQ,CAA8B;AAChE,IAAA,OAAO,EAAE,GAAG;AACb,CAAA,CAAC;AAEF;;;;AAIG;AACH,SAAS,YAAY,CAAC,IAAY,EAAA;IAChC,MAAM,GAAG,GAAG,eAAe,CAAC,GAAG,CAAC,IAAI,CAAC;AACrC,IAAA,IAAI,GAAG;AAAE,QAAA,OAAO,GAAG;IACnB,MAAM,CAAC,GAAG,IAAI,IAAI,CAAC,cAAc,CAAC,OAAO,EAAE;AACzC,QAAA,QAAQ,EAAE,IAAI;AACd,QAAA,IAAI,EAAE,SAAS;AACf,QAAA,MAAM,EAAE,SAAS;AACjB,QAAA,MAAM,EAAE,KAAK;AACd,KAAA,CAAC;AACF,IAAA,eAAe,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC,CAAC;AAC5B,IAAA,OAAO,CAAC;AACV;AAEA,SAAS,iBAAiB,GAAA;AACxB,IAAA,KAAK,MAAM,KAAK,IAAI,UAAU,EAAE;QAC9B,MAAM,CAAC,QAAQ,EAAE,EAAE,EAAE,GA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AI,CAAC,EAAE;AAC3B,YAAA,OAAO,KAAK;QACd;AACA,QAAA,aAAa,CAAC,GAAG,CAAC,IAAI,EAAE,QAAQ,CAAC;AACjC,QAAA,OAAO,IAAI;IACb;AACD;;;;"}
@@ -1,4 +1,4 @@
1
- /*! @hebcal/core v6.5.1, distributed under GPLv2 https://www.gnu.org/licenses/gpl-2.0.txt */
1
+ /*! @hebcal/core v6.5.3, distributed under GPLv2 https://www.gnu.org/licenses/gpl-2.0.txt */
2
2
  import { months, HDate } from '@hebcal/hdate';
3
3
 
4
4
  const SUN = 0;
@@ -4,7 +4,20 @@ import { CalOptions } from './CalOptions';
4
4
  import { HDate } from '@hebcal/hdate';
5
5
  import './locale';
6
6
  /**
7
- * Represents a molad, the moment when the new moon is "born"
7
+ * Represents a *molad* the calculated moment when the new moon is "born"
8
+ * for a given Hebrew month.
9
+ *
10
+ * The molad is announced in synagogue on Shabbat Mevarchim (the Shabbat
11
+ * before Rosh Chodesh) and is the anchor point for Kiddush Levana zmanim.
12
+ * Calculations use the traditional chalakim arithmetic
13
+ * (1 hour = 1080 chalakim) anchored to *Molad Tohu BaHaRaD*.
14
+ *
15
+ * @example
16
+ * import {Molad, months} from '@hebcal/core';
17
+ * const m = new Molad(5784, months.NISAN);
18
+ * console.log(m.getMonthName()); // 'Nisan'
19
+ * console.log(m.getHour(), m.getMinutes(), m.getChalakim()); // e.g. 1 31 12
20
+ * console.log(m.render('en')); // 'Molad Nisan: Mon, 1:31am and 12 chalakim'
8
21
  */
9
22
  export declare class Molad {
10
23
  private readonly m;
@@ -12,9 +25,9 @@ export declare class Molad {
12
25
  private readonly month;
13
26
  private instant?;
14
27
  /**
15
- * Calculates the molad for a Hebrew month
16
- * @param year
17
- * @param month 1=NISSAN, 7=TISHREI
28
+ * Calculates the molad for a given Hebrew year and month.
29
+ * @param year Hebrew year
30
+ * @param month 1=NISAN, 7=TISHREI (uses Nisan-based numbering)
18
31
  */
19
32
  constructor(year: number, month: number);
20
33
  /**
@@ -56,12 +69,18 @@ export declare class Molad {
56
69
  */
57
70
  getChalakim(): number;
58
71
  /**
59
- * Returns the molad in Standard Time in Yerushalayim as a Temporal.ZonedDateTime.
72
+ * Returns the molad in Standard Time in Yerushalayim as a `Temporal.ZonedDateTime`.
60
73
  * This method subtracts 20.94 minutes (20 minutes and 56.496 seconds) from the computed time (Har Habayis with a longitude
61
74
  * of 35.2354&deg; is 5.2354&deg; away from the %15 timezone longitude) to get to standard time. This method
62
75
  * intentionally uses standard time and not daylight savings time.
63
76
  *
64
- * @return the Temporal.ZonedDateTime representing the moment of the molad in Yerushalayim standard time (GMT + 2)
77
+ * The returned value is cached after the first call.
78
+ * @example
79
+ * import {Molad, months} from '@hebcal/core';
80
+ * const m = new Molad(5784, months.NISAN);
81
+ * const zdt = m.getInstant();
82
+ * console.log(zdt.toString()); // e.g. '2024-04-08T17:21:13.333+00:00[UTC]'
83
+ * @return the `Temporal.ZonedDateTime` representing the moment of the molad
65
84
  */
66
85
  getInstant(): Temporal.ZonedDateTime;
67
86
  /**
@@ -109,8 +128,21 @@ export declare class Molad {
109
128
  */
110
129
  getSofZmanKidushLevana15Days(): Temporal.ZonedDateTime;
111
130
  /**
131
+ * Returns a human-readable, localized string announcing the molad —
132
+ * suitable for use on Shabbat Mevarchim. The format includes the Hebrew
133
+ * month name, day of week, hour : minute, and chalakim if non-zero.
134
+ *
135
+ * Time format honors `options.hour12` and `options.location` (12-hour vs.
136
+ * 24-hour); see {@link HebrewCalendar.reformatTimeStr}.
137
+ * @example
138
+ * import {Molad, months} from '@hebcal/core';
139
+ * const m = new Molad(5784, months.NISAN);
140
+ * m.render('en', {hour12: true});
141
+ * // => 'Molad Nisan: Mon, 7:21pm and 6 chalakim'
142
+ * m.render('he');
143
+ * // => 'מוֹלָד נִיסָן יִהְיֶה בַּיּוֹם שֵׁנִי בשָׁבוּעַ, …'
112
144
  * @param [locale] Optional locale name (defaults to empty locale)
113
- * @param options
145
+ * @param options used for time formatting (12-hour vs 24-hour)
114
146
  */
115
147
  render(locale?: string, options?: CalOptions): string;
116
148
  }
package/dist/esm/molad.js CHANGED
@@ -1,4 +1,4 @@
1
- /*! @hebcal/core v6.5.1, distributed under GPLv2 https://www.gnu.org/licenses/gpl-2.0.txt */
1
+ /*! @hebcal/core v6.5.3, distributed under GPLv2 https://www.gnu.org/licenses/gpl-2.0.txt */
2
2
  import './temporal-shim.js';
3
3
  import { Event, flags } from './event.js';
4
4
  import { HDate, Locale, pad2 } from '@hebcal/hdate';
@@ -56,7 +56,20 @@ function getHebrewTimeOfDay(hour) {
56
56
  return night;
57
57
  }
58
58
  /**
59
- * Represents a molad, the moment when the new moon is "born"
59
+ * Represents a *molad* the calculated moment when the new moon is "born"
60
+ * for a given Hebrew month.
61
+ *
62
+ * The molad is announced in synagogue on Shabbat Mevarchim (the Shabbat
63
+ * before Rosh Chodesh) and is the anchor point for Kiddush Levana zmanim.
64
+ * Calculations use the traditional chalakim arithmetic
65
+ * (1 hour = 1080 chalakim) anchored to *Molad Tohu BaHaRaD*.
66
+ *
67
+ * @example
68
+ * import {Molad, months} from '@hebcal/core';
69
+ * const m = new Molad(5784, months.NISAN);
70
+ * console.log(m.getMonthName()); // 'Nisan'
71
+ * console.log(m.getHour(), m.getMinutes(), m.getChalakim()); // e.g. 1 31 12
72
+ * console.log(m.render('en')); // 'Molad Nisan: Mon, 1:31am and 12 chalakim'
60
73
  */
61
74
  class Molad {
62
75
  m;
@@ -64,9 +77,9 @@ class Molad {
64
77
  month;
65
78
  instant;
66
79
  /**
67
- * Calculates the molad for a Hebrew month
68
- * @param year
69
- * @param month 1=NISSAN, 7=TISHREI
80
+ * Calculates the molad for a given Hebrew year and month.
81
+ * @param year Hebrew year
82
+ * @param month 1=NISAN, 7=TISHREI (uses Nisan-based numbering)
70
83
  */
71
84
  constructor(year, month) {
72
85
  this.m = calculateMolad(year, month);
@@ -128,12 +141,18 @@ class Molad {
128
141
  return this.m.chalakim;
129
142
  }
130
143
  /**
131
- * Returns the molad in Standard Time in Yerushalayim as a Temporal.ZonedDateTime.
144
+ * Returns the molad in Standard Time in Yerushalayim as a `Temporal.ZonedDateTime`.
132
145
  * This method subtracts 20.94 minutes (20 minutes and 56.496 seconds) from the computed time (Har Habayis with a longitude
133
146
  * of 35.2354&deg; is 5.2354&deg; away from the %15 timezone longitude) to get to standard time. This method
134
147
  * intentionally uses standard time and not daylight savings time.
135
148
  *
136
- * @return the Temporal.ZonedDateTime representing the moment of the molad in Yerushalayim standard time (GMT + 2)
149
+ * The returned value is cached after the first call.
150
+ * @example
151
+ * import {Molad, months} from '@hebcal/core';
152
+ * const m = new Molad(5784, months.NISAN);
153
+ * const zdt = m.getInstant();
154
+ * console.log(zdt.toString()); // e.g. '2024-04-08T17:21:13.333+00:00[UTC]'
155
+ * @return the `Temporal.ZonedDateTime` representing the moment of the molad
137
156
  */
138
157
  getInstant() {
139
158
  this.instant ??= getMoladAsDate(this.m);
@@ -205,8 +224,21 @@ class Molad {
205
224
  return zdt.add({ hours: 24 * 15 });
206
225
  }
207
226
  /**
227
+ * Returns a human-readable, localized string announcing the molad —
228
+ * suitable for use on Shabbat Mevarchim. The format includes the Hebrew
229
+ * month name, day of week, hour : minute, and chalakim if non-zero.
230
+ *
231
+ * Time format honors `options.hour12` and `options.location` (12-hour vs.
232
+ * 24-hour); see {@link HebrewCalendar.reformatTimeStr}.
233
+ * @example
234
+ * import {Molad, months} from '@hebcal/core';
235
+ * const m = new Molad(5784, months.NISAN);
236
+ * m.render('en', {hour12: true});
237
+ * // => 'Molad Nisan: Mon, 7:21pm and 6 chalakim'
238
+ * m.render('he');
239
+ * // => 'מוֹלָד נִיסָן יִהְיֶה בַּיּוֹם שֵׁנִי בשָׁבוּעַ, …'
208
240
  * @param [locale] Optional locale name (defaults to empty locale)
209
- * @param options
241
+ * @param options used for time formatting (12-hour vs 24-hour)
210
242
  */
211
243
  render(locale, options) {
212
244
  const monthName = Locale.gettext(this.getMonthName(), locale);
@@ -1 +1 @@
1
- {"version":3,"file":"molad.js","sources":["../../../src/molad.ts"],"sourcesContent":["import './temporal-shim';\nimport {Event, flags} from './event';\nimport {CalOptions} from './CalOptions';\nimport {HDate, Locale, pad2} from '@hebcal/hdate';\nimport {reformatTimeStr} from './reformatTimeStr';\nimport {MoladBase, calculateMolad} from './moladBase';\nimport {getMoladAsDate} from './moladDate';\nimport './locale'; // Adds Hebrew and Ashkenazic translations\n\nconst enDoW = [\n 'Sunday',\n 'Monday',\n 'Tuesday',\n 'Wednesday',\n 'Thursday',\n 'Friday',\n 'Saturday',\n] as const;\n\nconst heDayNames = [\n 'רִאשׁוֹן',\n 'שֵׁנִי',\n 'שְׁלִישִׁי',\n 'רְבִיעִי',\n 'חֲמִישִׁי',\n 'שִׁישִּׁי',\n 'שַׁבָּת',\n] as const;\n\nconst frDoW = [\n 'Dimanche',\n 'Lundi',\n 'Mardi',\n 'Mercredi',\n 'Jeudi',\n 'Vendredi',\n 'Samedi',\n] as const;\nconst night = 'בַּלַּ֥יְלָה';\n\nfunction getDayNames(locale?: string): readonly string[] {\n if (Locale.isHebrewLocale(locale)) {\n return heDayNames;\n } else if (locale === 'fr') {\n return frDoW;\n }\n return enDoW;\n}\n\nfunction getHebrewTimeOfDay(hour: number): string {\n if (hour < 5) return night;\n else if (hour < 12) return 'בַּבֹּקֶר';\n else if (hour < 17) return 'בַּצׇּהֳרַיִים';\n else if (hour < 21) return 'בָּעֶרֶב';\n return night;\n}\n\n/**\n * Represents a molad, the moment when the new moon is \"born\"\n */\nexport class Molad {\n private readonly m: MoladBase;\n private readonly year: number;\n private readonly month: number;\n private instant?: Temporal.ZonedDateTime;\n\n /**\n * Calculates the molad for a Hebrew month\n * @param year\n * @param month 1=NISSAN, 7=TISHREI\n */\n constructor(year: number, month: number) {\n this.m = calculateMolad(year, month);\n this.year = year;\n this.month = month;\n }\n /**\n * The exact Hebrew date of the molad, which often falls on the\n * 28th or 30th of the preceeding month, occasionally on the first of the\n * month, and in extremely rare circumstances the 27th of the month.\n * - Molad Shevat 5541 occured on 27 Tevet / 1781-01-24T19:57:20.170Z\n * - Molad Shevat 5788 will occur on 27 Tevet / 2028-01-26T19:07:03.504Z\n * - Molad Nissan 5866 will occur on 27 Adar II / 2106-04-03T21:08:46.837Z\n */\n getMoladDate(): HDate {\n return this.m.hdate;\n }\n /**\n * The year of the molad (as constructed)\n */\n getYear(): number {\n return this.year;\n }\n /**\n * The month (1=NISSAN, 7=TISHREI) as constructed\n */\n getMonth(): number {\n return this.month;\n }\n /**\n * Returns a transliterated string name of the molad's Hebrew month,\n * for example 'Elul' or 'Cheshvan'.\n */\n getMonthName(): string {\n return HDate.getMonthName(this.month, this.year);\n }\n /**\n * @returns Day of Week (0=Sunday, 6=Saturday)\n */\n getDow(): number {\n return this.m.hdate.getDay();\n }\n /**\n * @returns hour of day (0-23)\n */\n getHour(): number {\n return this.m.hour;\n }\n /**\n * @returns minutes past hour (0-59)\n */\n getMinutes(): number {\n return this.m.minutes;\n }\n /**\n * @returns parts of a minute (0-17)\n */\n getChalakim(): number {\n return this.m.chalakim;\n }\n /**\n * Returns the molad in Standard Time in Yerushalayim as a Temporal.ZonedDateTime.\n * This method subtracts 20.94 minutes (20 minutes and 56.496 seconds) from the computed time (Har Habayis with a longitude\n * of 35.2354&deg; is 5.2354&deg; away from the %15 timezone longitude) to get to standard time. This method\n * intentionally uses standard time and not daylight savings time.\n *\n * @return the Temporal.ZonedDateTime representing the moment of the molad in Yerushalayim standard time (GMT + 2)\n */\n getInstant(): Temporal.ZonedDateTime {\n this.instant ??= getMoladAsDate(this.m);\n return this.instant;\n }\n /**\n * Returns the earliest time of _Kiddush Levana_ calculated as 3 days after the molad. This method returns the time\n * even if it is during the day when _Kiddush Levana_ can't be said. Callers of this method should consider\n * displaying the next _tzais_ if the zman is between _alos_ and _tzais_.\n *\n * @return the Temporal.ZonedDateTime representing the moment 3 days after the molad.\n */\n getTchilasZmanKidushLevana3Days(): Temporal.ZonedDateTime {\n const zdt = this.getInstant();\n return zdt.add({hours: 72});\n }\n\n /**\n * Returns the earliest time of Kiddush Levana calculated as 7 days after the molad as mentioned by the <a\n * href=\"https://en.wikipedia.org/wiki/Yosef_Karo\">Mechaber</a>. See the <a\n * href=\"https://en.wikipedia.org/wiki/Yoel_Sirkis\">Bach's</a> opinion on this time. This method returns the time\n * even if it is during the day when _Kiddush Levana_ can't be said. Callers of this method should consider\n * displaying the next _tzais_ if the zman is between _alos_ and _tzais_.\n *\n * @return the Temporal.ZonedDateTime representing the moment 7 days after the molad.\n */\n getTchilasZmanKidushLevana7Days(): Temporal.ZonedDateTime {\n const zdt = this.getInstant();\n return zdt.add({hours: 168});\n }\n\n /**\n * Returns the latest time of Kiddush Levana according to the <a\n * href=\"https://en.wikipedia.org/wiki/Yaakov_ben_Moshe_Levi_Moelin\">Maharil's</a> opinion that it is calculated as\n * halfway between molad and molad. This adds half the 29 days, 12 hours and 793 chalakim time between molad and\n * molad (14 days, 18 hours, 22 minutes and 666 milliseconds) to the month's molad. This method returns the time\n * even if it is during the day when _Kiddush Levana_ can't be said. Callers of this method should consider\n * displaying _alos_ before this time if the zman is between _alos_ and _tzais_.\n *\n * @return the Temporal.ZonedDateTime representing the moment halfway between molad and molad.\n */\n getSofZmanKidushLevanaBetweenMoldos(): Temporal.ZonedDateTime {\n const zdt = this.getInstant();\n // add half the time between molad and molad (half of 29 days, 12 hours and 793 chalakim (44 minutes, 3.3\n // seconds), or 14 days, 18 hours, 22 minutes and 666 milliseconds). Add it as hours, not days, to avoid\n // DST/ST crossover issues.\n return zdt.add({\n hours: 24 * 14 + 18,\n minutes: 22,\n seconds: 1,\n milliseconds: 666,\n });\n }\n\n /**\n * Returns the latest time of Kiddush Levana calculated as 15 days after the molad. This is the opinion brought down\n * in the Shulchan Aruch (Orach Chaim 426). It should be noted that some opinions hold that the\n * <a href=\"https://en.wikipedia.org/wiki/Moses_Isserles\">Rema</a> who brings down the opinion of the <a\n * href=\"https://en.wikipedia.org/wiki/Yaakov_ben_Moshe_Levi_Moelin\">Maharil's</a> of calculating\n * {@link Molad.getSofZmanKidushLevanaBetweenMoldos() half way between molad and mold} is of the opinion that Mechaber\n * agrees to his opinion. Also see the Aruch Hashulchan. For additional details on the subject, See Rabbi Dovid\n * Heber's very detailed writeup in Siman Daled (chapter 4) of <a\n * href=\"https://www.worldcat.org/oclc/461326125\">Shaarei Zmanim</a>. This method returns the time even if it is during\n * the day when _Kiddush Levana_ can't be said. Callers of this method should consider displaying _alos_\n * before this time if the zman is between _alos_ and _tzais_.\n *\n * @return the Temporal.ZonedDateTime representing the moment 15 days after the molad.\n */\n getSofZmanKidushLevana15Days(): Temporal.ZonedDateTime {\n const zdt = this.getInstant();\n // 15 days after the molad. Add it as hours, not days, to avoid DST/ST crossover issues.\n return zdt.add({hours: 24 * 15});\n }\n\n /**\n * @param [locale] Optional locale name (defaults to empty locale)\n * @param options\n */\n render(locale?: string, options?: CalOptions): string {\n const monthName = Locale.gettext(this.getMonthName(), locale);\n const dayNames = getDayNames(locale);\n const dow = dayNames[this.getDow()];\n const minutes = this.getMinutes();\n const hour = this.getHour();\n const chalakim = this.getChalakim();\n const moladStr = Locale.gettext('Molad', locale);\n const minutesStr = Locale.lookupTranslation('min', locale) ?? 'minutes';\n const chalakimStr = Locale.gettext('chalakim', locale);\n const and = Locale.gettext('and', locale);\n if (Locale.isHebrewLocale(locale)) {\n const ampm = getHebrewTimeOfDay(hour);\n let result =\n `${moladStr} ${monthName} יִהְיֶה בַּיּוֹם ${dow} בשָׁבוּעַ, ` +\n `בְּשָׁעָה ${hour} ${ampm}, ` +\n `ו-${minutes} ${minutesStr}`;\n if (chalakim !== 0) {\n result += ` ו-${chalakim} ${chalakimStr}`;\n }\n if (locale!.toLocaleLowerCase() === 'he-x-nonikud') {\n return Locale.hebrewStripNikkud(result);\n }\n return result;\n }\n const fmtTime = reformatTimeStr(`${hour}:${pad2(minutes)}`, 'pm', options);\n const month = monthName.replace(/'/g, '’');\n const result = `${moladStr} ${month}: ${dow}, ${fmtTime}`;\n if (chalakim === 0) {\n return result;\n }\n return result + ` ${and} ${chalakim} ${chalakimStr}`;\n }\n}\n\n/** Represents a Molad announcement on Shabbat Mevarchim */\nexport class MoladEvent extends Event {\n readonly molad: Molad;\n private readonly options: CalOptions;\n /**\n * @param date Hebrew date event occurs\n * @param hyear molad year\n * @param hmonth molad month\n * @param options\n */\n constructor(date: HDate, hyear: number, hmonth: number, options: CalOptions) {\n const m = new Molad(hyear, hmonth);\n const monthName = m.getMonthName();\n super(date, `Molad ${monthName} ${hyear}`, flags.MOLAD);\n this.molad = m;\n this.options = options;\n }\n /**\n * @param [locale] Optional locale name (defaults to empty locale)\n */\n render(locale?: string): string {\n return this.molad.render(locale, this.options);\n }\n}\n"],"names":[],"mappings":";;;;;;;;;AASA,MAAM,KAAK,GAAG;IACZ,QAAQ;IACR,QAAQ;IACR,SAAS;IACT,WAAW;IACX,UAAU;IACV,QAAQ;IACR,UAAU;CACF;AAEV,MAAM,UAAU,GAAG;IACjB,UAAU;IACV,QAAQ;IACR,YAAY;IACZ,UAAU;IACV,WAAW;IACX,WAAW;IACX,SAAS;CACD;AAEV,MAAM,KAAK,GAAG;IACZ,UAAU;IACV,OAAO;IACP,OAAO;IACP,UAAU;IACV,OAAO;IACP,UAAU;IACV,QAAQ;CACA;AACV,MAAM,KAAK,GAAG,cAAc;AAE5B,SAAS,WAAW,CAAC,MAAe,EAAA;AAClC,IAAA,IAAI,MAAM,CAAC,cAAc,CAAC,MAAM,CAAC,EAAE;AACjC,QAAA,OAAO,UAAU;IACnB;AAAO,SAAA,IAAI,MAAM,KAAK,IAAI,EAAE;AAC1B,QAAA,OAAO,KAAK;IACd;AACA,IAAA,OAAO,KAAK;AACd;AAEA,SAAS,kBAAkB,CAAC,IAAY,EAAA;IACtC,IAAI,IAAI,GAAG,CAAC;AAAE,QAAA,OAAO,KAAK;SACrB,IAAI,IAAI,GAAG,EAAE;AAAE,QAAA,OAAO,WAAW;SACjC,IAAI,IAAI,GAAG,EAAE;AAAE,Q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AAC;QAC1C,MAAM,MAAM,GAAG,CAAA,EAAG,QAAQ,CAAA,CAAA,EAAI,KAAK,CAAA,EAAA,EAAK,GAAG,CAAA,EAAA,EAAK,OAAO,CAAA,CAAE;AACzD,QAAA,IAAI,QAAQ,KAAK,CAAC,EAAE;AAClB,YAAA,OAAO,MAAM;QACf;QACA,OAAO,MAAM,GAAG,CAAA,CAAA,EAAI,GAAG,IAAI,QAAQ,CAAA,CAAA,EAAI,WAAW,CAAA,CAAE;IACtD;AACD;AAED;AACM,MAAO,UAAW,SAAQ,KAAK,CAAA;AAC1B,IAAA,KAAK;AACG,IAAA,OAAO;AACxB;;;;;AAKG;AACH,IAAA,WAAA,CAAY,IAAW,EAAE,KAAa,EAAE,MAAc,EAAE,OAAmB,EAAA;QACzE,MAAM,CAAC,GAAG,IAAI,KAAK,CAAC,KAAK,EAAE,MAAM,CAAC;AAClC,QAAA,MAAM,SAAS,GAAG,CAAC,CAAC,YAAY,EAAE;AAClC,QAAA,KAAK,CAAC,IAAI,EAAE,CAAA,MAAA,EAAS,SAAS,CAAA,CAAA,EAAI,KAAK,CAAA,CAAE,EAAE,KAAK,CAAC,KAAK,CAAC;AACvD,QAAA,IAAI,CAAC,KAAK,GAAG,CAAC;AACd,QAAA,IAAI,CAAC,OAAO,GAAG,OAAO;IACxB;AACA;;AAEG;AACH,IAAA,MAAM,CAAC,MAAe,EAAA;AACpB,QAAA,OAAO,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC,OAAO,CAAC;IAChD;AACD;;;;"}
1
+ {"version":3,"file":"molad.js","sources":["../../../src/molad.ts"],"sourcesContent":["import './temporal-shim';\nimport {Event, flags} from './event';\nimport {CalOptions} from './CalOptions';\nimport {HDate, Locale, pad2} from '@hebcal/hdate';\nimport {reformatTimeStr} from './reformatTimeStr';\nimport {MoladBase, calculateMolad} from './moladBase';\nimport {getMoladAsDate} from './moladDate';\nimport './locale'; // Adds Hebrew and Ashkenazic translations\n\nconst enDoW = [\n 'Sunday',\n 'Monday',\n 'Tuesday',\n 'Wednesday',\n 'Thursday',\n 'Friday',\n 'Saturday',\n] as const;\n\nconst heDayNames = [\n 'רִאשׁוֹן',\n 'שֵׁנִי',\n 'שְׁלִישִׁי',\n 'רְבִיעִי',\n 'חֲמִישִׁי',\n 'שִׁישִּׁי',\n 'שַׁבָּת',\n] as const;\n\nconst frDoW = [\n 'Dimanche',\n 'Lundi',\n 'Mardi',\n 'Mercredi',\n 'Jeudi',\n 'Vendredi',\n 'Samedi',\n] as const;\nconst night = 'בַּלַּ֥יְלָה';\n\nfunction getDayNames(locale?: string): readonly string[] {\n if (Locale.isHebrewLocale(locale)) {\n return heDayNames;\n } else if (locale === 'fr') {\n return frDoW;\n }\n return enDoW;\n}\n\nfunction getHebrewTimeOfDay(hour: number): string {\n if (hour < 5) return night;\n else if (hour < 12) return 'בַּבֹּקֶר';\n else if (hour < 17) return 'בַּצׇּהֳרַיִים';\n else if (hour < 21) return 'בָּעֶרֶב';\n return night;\n}\n\n/**\n * Represents a *molad* — the calculated moment when the new moon is \"born\"\n * for a given Hebrew month.\n *\n * The molad is announced in synagogue on Shabbat Mevarchim (the Shabbat\n * before Rosh Chodesh) and is the anchor point for Kiddush Levana zmanim.\n * Calculations use the traditional chalakim arithmetic\n * (1 hour = 1080 chalakim) anchored to *Molad Tohu BaHaRaD*.\n *\n * @example\n * import {Molad, months} from '@hebcal/core';\n * const m = new Molad(5784, months.NISAN);\n * console.log(m.getMonthName()); // 'Nisan'\n * console.log(m.getHour(), m.getMinutes(), m.getChalakim()); // e.g. 1 31 12\n * console.log(m.render('en')); // 'Molad Nisan: Mon, 1:31am and 12 chalakim'\n */\nexport class Molad {\n private readonly m: MoladBase;\n private readonly year: number;\n private readonly month: number;\n private instant?: Temporal.ZonedDateTime;\n\n /**\n * Calculates the molad for a given Hebrew year and month.\n * @param year Hebrew year\n * @param month 1=NISAN, 7=TISHREI (uses Nisan-based numbering)\n */\n constructor(year: number, month: number) {\n this.m = calculateMolad(year, month);\n this.year = year;\n this.month = month;\n }\n /**\n * The exact Hebrew date of the molad, which often falls on the\n * 28th or 30th of the preceeding month, occasionally on the first of the\n * month, and in extremely rare circumstances the 27th of the month.\n * - Molad Shevat 5541 occured on 27 Tevet / 1781-01-24T19:57:20.170Z\n * - Molad Shevat 5788 will occur on 27 Tevet / 2028-01-26T19:07:03.504Z\n * - Molad Nissan 5866 will occur on 27 Adar II / 2106-04-03T21:08:46.837Z\n */\n getMoladDate(): HDate {\n return this.m.hdate;\n }\n /**\n * The year of the molad (as constructed)\n */\n getYear(): number {\n return this.year;\n }\n /**\n * The month (1=NISSAN, 7=TISHREI) as constructed\n */\n getMonth(): number {\n return this.month;\n }\n /**\n * Returns a transliterated string name of the molad's Hebrew month,\n * for example 'Elul' or 'Cheshvan'.\n */\n getMonthName(): string {\n return HDate.getMonthName(this.month, this.year);\n }\n /**\n * @returns Day of Week (0=Sunday, 6=Saturday)\n */\n getDow(): number {\n return this.m.hdate.getDay();\n }\n /**\n * @returns hour of day (0-23)\n */\n getHour(): number {\n return this.m.hour;\n }\n /**\n * @returns minutes past hour (0-59)\n */\n getMinutes(): number {\n return this.m.minutes;\n }\n /**\n * @returns parts of a minute (0-17)\n */\n getChalakim(): number {\n return this.m.chalakim;\n }\n /**\n * Returns the molad in Standard Time in Yerushalayim as a `Temporal.ZonedDateTime`.\n * This method subtracts 20.94 minutes (20 minutes and 56.496 seconds) from the computed time (Har Habayis with a longitude\n * of 35.2354&deg; is 5.2354&deg; away from the %15 timezone longitude) to get to standard time. This method\n * intentionally uses standard time and not daylight savings time.\n *\n * The returned value is cached after the first call.\n * @example\n * import {Molad, months} from '@hebcal/core';\n * const m = new Molad(5784, months.NISAN);\n * const zdt = m.getInstant();\n * console.log(zdt.toString()); // e.g. '2024-04-08T17:21:13.333+00:00[UTC]'\n * @return the `Temporal.ZonedDateTime` representing the moment of the molad\n */\n getInstant(): Temporal.ZonedDateTime {\n this.instant ??= getMoladAsDate(this.m);\n return this.instant;\n }\n /**\n * Returns the earliest time of _Kiddush Levana_ calculated as 3 days after the molad. This method returns the time\n * even if it is during the day when _Kiddush Levana_ can't be said. Callers of this method should consider\n * displaying the next _tzais_ if the zman is between _alos_ and _tzais_.\n *\n * @return the Temporal.ZonedDateTime representing the moment 3 days after the molad.\n */\n getTchilasZmanKidushLevana3Days(): Temporal.ZonedDateTime {\n const zdt = this.getInstant();\n return zdt.add({hours: 72});\n }\n\n /**\n * Returns the earliest time of Kiddush Levana calculated as 7 days after the molad as mentioned by the <a\n * href=\"https://en.wikipedia.org/wiki/Yosef_Karo\">Mechaber</a>. See the <a\n * href=\"https://en.wikipedia.org/wiki/Yoel_Sirkis\">Bach's</a> opinion on this time. This method returns the time\n * even if it is during the day when _Kiddush Levana_ can't be said. Callers of this method should consider\n * displaying the next _tzais_ if the zman is between _alos_ and _tzais_.\n *\n * @return the Temporal.ZonedDateTime representing the moment 7 days after the molad.\n */\n getTchilasZmanKidushLevana7Days(): Temporal.ZonedDateTime {\n const zdt = this.getInstant();\n return zdt.add({hours: 168});\n }\n\n /**\n * Returns the latest time of Kiddush Levana according to the <a\n * href=\"https://en.wikipedia.org/wiki/Yaakov_ben_Moshe_Levi_Moelin\">Maharil's</a> opinion that it is calculated as\n * halfway between molad and molad. This adds half the 29 days, 12 hours and 793 chalakim time between molad and\n * molad (14 days, 18 hours, 22 minutes and 666 milliseconds) to the month's molad. This method returns the time\n * even if it is during the day when _Kiddush Levana_ can't be said. Callers of this method should consider\n * displaying _alos_ before this time if the zman is between _alos_ and _tzais_.\n *\n * @return the Temporal.ZonedDateTime representing the moment halfway between molad and molad.\n */\n getSofZmanKidushLevanaBetweenMoldos(): Temporal.ZonedDateTime {\n const zdt = this.getInstant();\n // add half the time between molad and molad (half of 29 days, 12 hours and 793 chalakim (44 minutes, 3.3\n // seconds), or 14 days, 18 hours, 22 minutes and 666 milliseconds). Add it as hours, not days, to avoid\n // DST/ST crossover issues.\n return zdt.add({\n hours: 24 * 14 + 18,\n minutes: 22,\n seconds: 1,\n milliseconds: 666,\n });\n }\n\n /**\n * Returns the latest time of Kiddush Levana calculated as 15 days after the molad. This is the opinion brought down\n * in the Shulchan Aruch (Orach Chaim 426). It should be noted that some opinions hold that the\n * <a href=\"https://en.wikipedia.org/wiki/Moses_Isserles\">Rema</a> who brings down the opinion of the <a\n * href=\"https://en.wikipedia.org/wiki/Yaakov_ben_Moshe_Levi_Moelin\">Maharil's</a> of calculating\n * {@link Molad.getSofZmanKidushLevanaBetweenMoldos() half way between molad and mold} is of the opinion that Mechaber\n * agrees to his opinion. Also see the Aruch Hashulchan. For additional details on the subject, See Rabbi Dovid\n * Heber's very detailed writeup in Siman Daled (chapter 4) of <a\n * href=\"https://www.worldcat.org/oclc/461326125\">Shaarei Zmanim</a>. This method returns the time even if it is during\n * the day when _Kiddush Levana_ can't be said. Callers of this method should consider displaying _alos_\n * before this time if the zman is between _alos_ and _tzais_.\n *\n * @return the Temporal.ZonedDateTime representing the moment 15 days after the molad.\n */\n getSofZmanKidushLevana15Days(): Temporal.ZonedDateTime {\n const zdt = this.getInstant();\n // 15 days after the molad. Add it as hours, not days, to avoid DST/ST crossover issues.\n return zdt.add({hours: 24 * 15});\n }\n\n /**\n * Returns a human-readable, localized string announcing the molad —\n * suitable for use on Shabbat Mevarchim. The format includes the Hebrew\n * month name, day of week, hour : minute, and chalakim if non-zero.\n *\n * Time format honors `options.hour12` and `options.location` (12-hour vs.\n * 24-hour); see {@link HebrewCalendar.reformatTimeStr}.\n * @example\n * import {Molad, months} from '@hebcal/core';\n * const m = new Molad(5784, months.NISAN);\n * m.render('en', {hour12: true});\n * // => 'Molad Nisan: Mon, 7:21pm and 6 chalakim'\n * m.render('he');\n * // => 'מוֹלָד נִיסָן יִהְיֶה בַּיּוֹם שֵׁנִי בשָׁבוּעַ, …'\n * @param [locale] Optional locale name (defaults to empty locale)\n * @param options used for time formatting (12-hour vs 24-hour)\n */\n render(locale?: string, options?: CalOptions): string {\n const monthName = Locale.gettext(this.getMonthName(), locale);\n const dayNames = getDayNames(locale);\n const dow = dayNames[this.getDow()];\n const minutes = this.getMinutes();\n const hour = this.getHour();\n const chalakim = this.getChalakim();\n const moladStr = Locale.gettext('Molad', locale);\n const minutesStr = Locale.lookupTranslation('min', locale) ?? 'minutes';\n const chalakimStr = Locale.gettext('chalakim', locale);\n const and = Locale.gettext('and', locale);\n if (Locale.isHebrewLocale(locale)) {\n const ampm = getHebrewTimeOfDay(hour);\n let result =\n `${moladStr} ${monthName} יִהְיֶה בַּיּוֹם ${dow} בשָׁבוּעַ, ` +\n `בְּשָׁעָה ${hour} ${ampm}, ` +\n `ו-${minutes} ${minutesStr}`;\n if (chalakim !== 0) {\n result += ` ו-${chalakim} ${chalakimStr}`;\n }\n if (locale!.toLocaleLowerCase() === 'he-x-nonikud') {\n return Locale.hebrewStripNikkud(result);\n }\n return result;\n }\n const fmtTime = reformatTimeStr(`${hour}:${pad2(minutes)}`, 'pm', options);\n const month = monthName.replace(/'/g, '’');\n const result = `${moladStr} ${month}: ${dow}, ${fmtTime}`;\n if (chalakim === 0) {\n return result;\n }\n return result + ` ${and} ${chalakim} ${chalakimStr}`;\n }\n}\n\n/** Represents a Molad announcement on Shabbat Mevarchim */\nexport class MoladEvent extends Event {\n readonly molad: Molad;\n private readonly options: CalOptions;\n /**\n * @param date Hebrew date event occurs\n * @param hyear molad year\n * @param hmonth molad month\n * @param options\n */\n constructor(date: HDate, hyear: number, hmonth: number, options: CalOptions) {\n const m = new Molad(hyear, hmonth);\n const monthName = m.getMonthName();\n super(date, `Molad ${monthName} ${hyear}`, flags.MOLAD);\n this.molad = m;\n this.options = options;\n }\n /**\n * @param [locale] Optional locale name (defaults to empty locale)\n */\n render(locale?: string): string {\n return this.molad.render(locale, this.options);\n }\n}\n"],"names":[],"mappings":";;;;;;;;;AASA,MAAM,KAAK,GAAG;IACZ,QAAQ;IACR,QAAQ;IACR,SAAS;IACT,WAAW;IACX,UAAU;IACV,QAAQ;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KAAK,EAAE,MAAM,CAAC;AAClC,QAAA,MAAM,SAAS,GAAG,CAAC,CAAC,YAAY,EAAE;AAClC,QAAA,KAAK,CAAC,IAAI,EAAE,CAAA,MAAA,EAAS,SAAS,CAAA,CAAA,EAAI,KAAK,CAAA,CAAE,EAAE,KAAK,CAAC,KAAK,CAAC;AACvD,QAAA,IAAI,CAAC,KAAK,GAAG,CAAC;AACd,QAAA,IAAI,CAAC,OAAO,GAAG,OAAO;IACxB;AACA;;AAEG;AACH,IAAA,MAAM,CAAC,MAAe,EAAA;AACpB,QAAA,OAAO,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC,OAAO,CAAC;IAChD;AACD;;;;"}
@@ -1,4 +1,4 @@
1
- /*! @hebcal/core v6.5.1, distributed under GPLv2 https://www.gnu.org/licenses/gpl-2.0.txt */
1
+ /*! @hebcal/core v6.5.3, distributed under GPLv2 https://www.gnu.org/licenses/gpl-2.0.txt */
2
2
  import { HDate, isLeapYear } from '@hebcal/hdate';
3
3
 
4
4
  /*
@@ -1,4 +1,4 @@
1
- /*! @hebcal/core v6.5.1, distributed under GPLv2 https://www.gnu.org/licenses/gpl-2.0.txt */
1
+ /*! @hebcal/core v6.5.3, distributed under GPLv2 https://www.gnu.org/licenses/gpl-2.0.txt */
2
2
  import './temporal-shim.js';
3
3
  import { getTimezoneOffset } from '@hebcal/hdate';
4
4
 
@@ -6,21 +6,49 @@ import './locale';
6
6
  * Lang for the Sefira can be English, Hebrew, or Hebrew in Sephardic transliteration.
7
7
  */
8
8
  export type OmerLang = 'en' | 'he' | 'translit';
9
- /** Represents a day 1-49 of counting the Omer from Pesach to Shavuot */
9
+ /**
10
+ * Represents one of the 49 days of counting the Omer between Pesach and
11
+ * Shavuot (16 Nisan through 5 Sivan).
12
+ *
13
+ * Each day has an associated Sefirah pairing (e.g. *Chesed shebiGevurah*),
14
+ * a word from Psalm 67 (Lamnatzeach), a letter from verse 5 of Psalm 67,
15
+ * and a word/acrostic from the Ana BeKoach prayer — all accessible via
16
+ * the methods on this class.
17
+ *
18
+ * @example
19
+ * import {OmerEvent, HDate, months} from '@hebcal/core';
20
+ * const ev = new OmerEvent(new HDate(16, months.NISAN, 5784), 1);
21
+ * ev.render('en'); // '1st day of the Omer'
22
+ * ev.render('he'); // 'א׳ בָּעוֹמֶר'
23
+ * ev.sefira('translit'); // 'Chesed shebChesed'
24
+ * ev.getTodayIs('en'); // 'Today is 1 day of the Omer'
25
+ */
10
26
  export declare class OmerEvent extends Event {
11
27
  private readonly weekNumber;
12
28
  private readonly daysWithinWeeks;
13
29
  readonly omer: number;
14
30
  /**
15
- * @param date
16
- * @param omerDay
31
+ * Constructs an Omer event for a given day (1–49).
32
+ *
33
+ * Throws `RangeError` if `omerDay` is outside 1–49.
34
+ * @param date Hebrew date this Omer day is counted on (the evening of)
35
+ * @param omerDay day of the Omer, 1 through 49
17
36
  */
18
37
  constructor(date: HDate, omerDay: number);
19
38
  /**
20
- * Returns the sefira. For example, on day 8:
39
+ * Returns the Sefirah pairing associated with this Omer day
40
+ * one of the seven lower Sefirot within another, calculated as
41
+ * `day-within-week` of `week-within-cycle`. For example, on day 8
42
+ * (week 2, day 1):
21
43
  * * חֶֽסֶד שֶׁבִּגְבוּרָה
22
44
  * * Chesed shebiGevurah
23
45
  * * Lovingkindness within Might
46
+ * @example
47
+ * import {OmerEvent, HDate, months} from '@hebcal/core';
48
+ * const day8 = new OmerEvent(new HDate(23, months.NISAN, 5784), 8);
49
+ * day8.sefira('en'); // 'Lovingkindness within Might'
50
+ * day8.sefira('he'); // 'חֶֽסֶד שֶׁבִּגְבוּרָה'
51
+ * day8.sefira('translit'); // 'Chesed shebiGevurah'
24
52
  * @param lang `en` (English), `he` (Hebrew with nikud), or `translit` (Hebrew in Sephardic transliteration)
25
53
  * @returns a string such as `Lovingkindness within Might` or `חֶֽסֶד שֶׁבִּגְבוּרָה`
26
54
  */