@hebcal/core 6.11.1 → 6.13.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.
Files changed (91) hide show
  1. package/dist/bundle.js +1682 -1915
  2. package/dist/bundle.js.map +1 -1
  3. package/dist/bundle.min.js +18 -19
  4. package/dist/bundle.min.js.map +1 -1
  5. package/dist/esm/DailyLearning.js +5 -15
  6. package/dist/esm/DailyLearning.js.map +1 -1
  7. package/dist/esm/HebrewDateEvent.d.ts +0 -4
  8. package/dist/esm/HebrewDateEvent.js +2 -6
  9. package/dist/esm/HebrewDateEvent.js.map +1 -1
  10. package/dist/esm/HolidayEvent.js +6 -10
  11. package/dist/esm/HolidayEvent.js.map +1 -1
  12. package/dist/esm/MevarchimChodeshEvent.js +2 -2
  13. package/dist/esm/MevarchimChodeshEvent.js.map +1 -1
  14. package/dist/esm/ParshaEvent.js +4 -4
  15. package/dist/esm/ParshaEvent.js.map +1 -1
  16. package/dist/esm/TimedEvent.js +4 -5
  17. package/dist/esm/TimedEvent.js.map +1 -1
  18. package/dist/esm/YomKippurKatanEvent.js +2 -2
  19. package/dist/esm/YomKippurKatanEvent.js.map +1 -1
  20. package/dist/esm/ashkenazi.po.js +1 -1
  21. package/dist/esm/calendar.js +7 -40
  22. package/dist/esm/calendar.js.map +1 -1
  23. package/dist/esm/candles.d.ts +3 -5
  24. package/dist/esm/candles.js +6 -20
  25. package/dist/esm/candles.js.map +1 -1
  26. package/dist/esm/cities.json.js +1 -1
  27. package/dist/esm/event.js +4 -6
  28. package/dist/esm/event.js.map +1 -1
  29. package/dist/esm/getStartAndEnd.d.ts +1 -1
  30. package/dist/esm/getStartAndEnd.js +8 -9
  31. package/dist/esm/getStartAndEnd.js.map +1 -1
  32. package/dist/esm/hallel.d.ts +1 -3
  33. package/dist/esm/hallel.js +2 -4
  34. package/dist/esm/hallel.js.map +1 -1
  35. package/dist/esm/he-x-NoNikud.po.d.ts +1 -0
  36. package/dist/esm/he-x-NoNikud.po.js +2 -2
  37. package/dist/esm/he-x-NoNikud.po.js.map +1 -1
  38. package/dist/esm/he.po.d.ts +1 -0
  39. package/dist/esm/he.po.js +2 -2
  40. package/dist/esm/he.po.js.map +1 -1
  41. package/dist/esm/hebcal.js +6 -12
  42. package/dist/esm/hebcal.js.map +1 -1
  43. package/dist/esm/holidays.d.ts +1 -1
  44. package/dist/esm/holidays.js +111 -131
  45. package/dist/esm/holidays.js.map +1 -1
  46. package/dist/esm/index.js +1 -1
  47. package/dist/esm/isAssurBemlacha.js +5 -18
  48. package/dist/esm/isAssurBemlacha.js.map +1 -1
  49. package/dist/esm/isAveilut.js +2 -5
  50. package/dist/esm/isAveilut.js.map +1 -1
  51. package/dist/esm/isFastDay.js +3 -4
  52. package/dist/esm/isFastDay.js.map +1 -1
  53. package/dist/esm/locale.js +1 -1
  54. package/dist/esm/location.js +2 -7
  55. package/dist/esm/location.js.map +1 -1
  56. package/dist/esm/modern.d.ts +8 -13
  57. package/dist/esm/modern.js +142 -17
  58. package/dist/esm/modern.js.map +1 -1
  59. package/dist/esm/molad.js +2 -2
  60. package/dist/esm/molad.js.map +1 -1
  61. package/dist/esm/moladBase.js +2 -3
  62. package/dist/esm/moladBase.js.map +1 -1
  63. package/dist/esm/moladDate.js +1 -1
  64. package/dist/esm/moladDate.js.map +1 -1
  65. package/dist/esm/omer.js +22 -28
  66. package/dist/esm/omer.js.map +1 -1
  67. package/dist/esm/parshaName.d.ts +1 -1
  68. package/dist/esm/parshaName.js +3 -4
  69. package/dist/esm/parshaName.js.map +1 -1
  70. package/dist/esm/parshaYear.js +1 -1
  71. package/dist/esm/pkgVersion.d.ts +1 -1
  72. package/dist/esm/pkgVersion.js +2 -2
  73. package/dist/esm/pkgVersion.js.map +1 -1
  74. package/dist/esm/reformatTimeStr.js +17 -16
  75. package/dist/esm/reformatTimeStr.js.map +1 -1
  76. package/dist/esm/sedra.d.ts +0 -2
  77. package/dist/esm/sedra.js +19 -28
  78. package/dist/esm/sedra.js.map +1 -1
  79. package/dist/esm/sefira.json.js +1 -1
  80. package/dist/esm/staticHolidays.d.ts +8 -14
  81. package/dist/esm/staticHolidays.js +179 -470
  82. package/dist/esm/staticHolidays.js.map +1 -1
  83. package/dist/esm/string.js +1 -1
  84. package/dist/esm/tachanun.js +2 -6
  85. package/dist/esm/tachanun.js.map +1 -1
  86. package/dist/esm/zmanim.d.ts +0 -2
  87. package/dist/esm/zmanim.js +19 -22
  88. package/dist/esm/zmanim.js.map +1 -1
  89. package/package.json +7 -7
  90. package/po/he-x-NoNikud.po +3 -0
  91. package/po/he.po +3 -0
@@ -1,4 +1,4 @@
1
- /*! @hebcal/core v6.11.1, distributed under GPLv2 https://www.gnu.org/licenses/gpl-2.0.txt */
1
+ /*! @hebcal/core v6.13.1, distributed under GPLv2 https://www.gnu.org/licenses/gpl-2.0.txt */
2
2
  import { getHolidaysOnDate } from './holidays.js';
3
3
 
4
4
  /**
@@ -21,9 +21,8 @@ import { getHolidaysOnDate } from './holidays.js';
21
21
  * @return `true` if the date is a major or minor fast day
22
22
  */
23
23
  function isFastDay(date, il) {
24
- const events = getHolidaysOnDate(date, il) || [];
25
- const fastDay = events.find(ev => ev.hasAnyFlag('MAJOR_FAST', 'MINOR_FAST') && !ev.hasFlag('EREV'));
26
- return Boolean(fastDay);
24
+ const events = getHolidaysOnDate(date, il) ?? [];
25
+ return events.some(ev => ev.hasAnyFlag('MAJOR_FAST', 'MINOR_FAST') && !ev.hasFlag('EREV'));
27
26
  }
28
27
 
29
28
  export { isFastDay };
@@ -1 +1 @@
1
- {"version":3,"file":"isFastDay.js","sources":["../../../src/isFastDay.ts"],"sourcesContent":["import {HDate} from '@hebcal/hdate';\nimport {getHolidaysOnDate} from './holidays.js';\n\n/**\n * Returns `true` if the given date is observed as a major or minor fast day.\n *\n * Major fasts: Yom Kippur, Tish'a B'Av.\n * Minor fasts: Tzom Gedaliah, Asara B'Tevet, Ta'anit Esther, Ta'anit\n * Bechorot, Tzom Tammuz (plus BeHaB fasts when enabled).\n *\n * Erev Tish'a B'Av — even though the fast begins at sunset — is *not*\n * counted here: only the actual fast day itself returns `true`.\n * Postponed fasts return `true` on the actual observed date (e.g. when\n * 17 Tammuz falls on Shabbat and is observed on the 18th).\n * @example\n * import {isFastDay, HDate, months} from '@hebcal/core';\n * isFastDay(new HDate(10, months.TISHREI, 5784)); // true (Yom Kippur)\n * isFastDay(new HDate(11, months.TISHREI, 5784)); // false\n * @param date Hebrew Date, Gregorian date, or absolute R.D. day number\n * @param il optional; use the Israeli schedule for holidays (default Diaspora)\n * @return `true` if the date is a major or minor fast day\n */\nexport function isFastDay(date: HDate | Date | number, il?: boolean): boolean {\n const events = getHolidaysOnDate(date, il) || [];\n const fastDay = events.find(\n ev => ev.hasAnyFlag('MAJOR_FAST', 'MINOR_FAST') && !ev.hasFlag('EREV')\n );\n return Boolean(fastDay);\n}\n"],"names":[],"mappings":";;;AAGA;;;;;;;;;;;;;;;;;;AAkBG;AACG,SAAU,SAAS,CAAC,IAA2B,EAAE,EAAY,EAAA;IACjE,MAAM,MAAM,GAAG,iBAAiB,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,EAAE;IAChD,MAAM,OAAO,GAAG,MAAM,CAAC,IAAI,CACzB,EAAE,IAAI,EAAE,CAAC,UAAU,CAAC,YAAY,EAAE,YAAY,CAAC,IAAI,CAAC,EAAE,CAAC,OAAO,CAAC,MAAM,CAAC,CACvE;AACD,IAAA,OAAO,OAAO,CAAC,OAAO,CAAC;AACzB;;"}
1
+ {"version":3,"file":"isFastDay.js","sources":["../../../src/isFastDay.ts"],"sourcesContent":["import {HDate} from '@hebcal/hdate';\nimport {getHolidaysOnDate} from './holidays.js';\n\n/**\n * Returns `true` if the given date is observed as a major or minor fast day.\n *\n * Major fasts: Yom Kippur, Tish'a B'Av.\n * Minor fasts: Tzom Gedaliah, Asara B'Tevet, Ta'anit Esther, Ta'anit\n * Bechorot, Tzom Tammuz (plus BeHaB fasts when enabled).\n *\n * Erev Tish'a B'Av — even though the fast begins at sunset — is *not*\n * counted here: only the actual fast day itself returns `true`.\n * Postponed fasts return `true` on the actual observed date (e.g. when\n * 17 Tammuz falls on Shabbat and is observed on the 18th).\n * @example\n * import {isFastDay, HDate, months} from '@hebcal/core';\n * isFastDay(new HDate(10, months.TISHREI, 5784)); // true (Yom Kippur)\n * isFastDay(new HDate(11, months.TISHREI, 5784)); // false\n * @param date Hebrew Date, Gregorian date, or absolute R.D. day number\n * @param il optional; use the Israeli schedule for holidays (default Diaspora)\n * @return `true` if the date is a major or minor fast day\n */\nexport function isFastDay(date: HDate | Date | number, il?: boolean): boolean {\n const events = getHolidaysOnDate(date, il) ?? [];\n return events.some(\n ev => ev.hasAnyFlag('MAJOR_FAST', 'MINOR_FAST') && !ev.hasFlag('EREV')\n );\n}\n"],"names":[],"mappings":";;;AAGA;;;;;;;;;;;;;;;;;;AAkBG;AACG,SAAU,SAAS,CAAC,IAA2B,EAAE,EAAY,EAAA;IACjE,MAAM,MAAM,GAAG,iBAAiB,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,EAAE;IAChD,OAAO,MAAM,CAAC,IAAI,CAChB,EAAE,IAAI,EAAE,CAAC,UAAU,CAAC,YAAY,EAAE,YAAY,CAAC,IAAI,CAAC,EAAE,CAAC,OAAO,CAAC,MAAM,CAAC,CACvE;AACH;;"}
@@ -1,4 +1,4 @@
1
- /*! @hebcal/core v6.11.1, distributed under GPLv2 https://www.gnu.org/licenses/gpl-2.0.txt */
1
+ /*! @hebcal/core v6.13.1, distributed under GPLv2 https://www.gnu.org/licenses/gpl-2.0.txt */
2
2
  import { Locale } from '@hebcal/hdate';
3
3
  export { Locale } from '@hebcal/hdate';
4
4
  import poAshkenazi from './ashkenazi.po.js';
@@ -1,4 +1,4 @@
1
- /*! @hebcal/core v6.11.1, distributed under GPLv2 https://www.gnu.org/licenses/gpl-2.0.txt */
1
+ /*! @hebcal/core v6.13.1, 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
4
  import QuickLRU from 'quick-lru';
@@ -40,14 +40,12 @@ const ZIPCODES_TZ_MAP = {
40
40
  '15': 'Pacific/Palau', // Palau (GMT +9:00)
41
41
  '16': 'Pacific/Chuuk', // Micronesia (GMT +11:00)
42
42
  };
43
- /** @private */
44
43
  const timeFormatCache = new QuickLRU({
45
44
  maxSize: 120,
46
45
  });
47
46
  /**
48
47
  * Gets a 24-hour time formatter (e.g. 07:41 or 20:03) from cache
49
48
  * or makes a new one if needed
50
- * @private
51
49
  */
52
50
  function getFormatter(tzid) {
53
51
  const fmt = timeFormatCache.get(tzid);
@@ -148,11 +146,8 @@ class Location extends GeoLocation {
148
146
  cityName = String(cityName);
149
147
  }
150
148
  super(cityName || null, lat, long, elev, tzid);
151
- this.il = Boolean(il);
149
+ this.il = Boolean(il) || countryCode === 'IL';
152
150
  this.cc = countryCode;
153
- if (countryCode === 'IL') {
154
- this.il = true;
155
- }
156
151
  this.geoid = geoid;
157
152
  }
158
153
  /**
@@ -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.js';\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 the 65\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 /**\n * First-level administrative division (e.g. a US state or a French\n * region) as an abbreviation, such as `\"CA\"`. Not set by this package;\n * populated by callers that hydrate a `Location` from a geo database.\n */\n admin1?: string;\n /**\n * Full name of the first-level administrative division, such as\n * `\"California\"`. Not set by this package.\n */\n stateName?: string;\n /**\n * Which kind of lookup produced this location: `'zip'` for a US Zip Code\n * or `'geoname'` for a GeoNames city. Not set by this package.\n */\n geo?: 'zip' | 'geoname';\n /** US Zip Code, such as `\"02912\"`. Not set by this package. */\n zip?: string;\n /** Approximate population of the city. Not set by this package. */\n population?: number;\n /** City name in plain ASCII, for sorting or URL generation. Not set by this package. */\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 = 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 if (countryCode === 'IL') {\n this.il = true;\n }\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 *\n * Note that the built-in classic cities are named by city alone, so\n * `getName()` and {@link getShortName} return the same string for them.\n * @example\n * const loc = new Location(41.85003, -87.65005, false,\n * 'America/Chicago', 'Chicago, Illinois, USA', 'US');\n * loc.getName(); // 'Chicago, Illinois, USA'\n * Location.lookup('San Francisco')?.getName(); // 'San Francisco'\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 * const chi = new Location(41.85003, -87.65005, false,\n * 'America/Chicago', 'Chicago, Illinois, USA', 'US');\n * chi.getShortName(); // 'Chicago'\n * const dc = new Location(38.89511, -77.03637, false,\n * 'America/New_York', 'Washington, D.C., USA', 'US');\n * dc.getShortName(); // 'Washington, D.C.'\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 }\n 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 65 \"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 }\n const plus = tz > 0 ? '+' : '';\n return `Etc/GMT${plus}${tz}`;\n }\n if (tz === 2 && dst === 'israel') {\n return 'Asia/Jerusalem';\n }\n 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 }\n 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 }\n if (tz === 7 && state === 'AZ') {\n return dst === 'Y' ? 'America/Denver' : 'America/Phoenix';\n }\n return ZIPCODES_TZ_MAP[tz];\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 65 classic Hebcal cities with\n * your own custom locations.\n * @example\n * const tlv = new Location(32.0853, 34.7818, true,\n * 'Asia/Jerusalem', 'My Office, Tel Aviv', 'IL');\n * Location.addLocation('My Office', tlv); // true\n * Location.lookup('my office')?.getTzid(); // 'Asia/Jerusalem'\n * @param cityName name to register the location under (case insensitive)\n * @param location the `Location` instance to register\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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B;AAC1B,gBAAA,KAAK,CAAC;AACJ,oBAAA,OAAO,eAAe;AACxB,gBAAA,KAAK,CAAC;AACJ,oBAAA,OAAO,cAAc;AACvB,gBAAA,KAAK,CAAC;AACJ,oBAAA,OAAO,eAAe;;QAI5B;AACA,QAAA,IAAI,GAAG,KAAK,KAAK,EAAE;YACjB,OAAO,eAAe,CAAC,MAAM,CAAC,EAAE,GAAG,EAAE,CAAC,CAAC;QACzC;AACA,QAAA,OAAO,SAAS;IAClB;AAEA;;;;;;;AAOG;AACH,IAAA,OAAO,UAAU,CAAC,KAAa,EAAE,EAAU,EAAE,GAAW,EAAA;QACtD,EAAE,GAAG,CAAC,EAAE;QACR,IAAI,EAAE,KAAK,EAAE,IAAI,KAAK,KAAK,IAAI,EAAE;AAC/B,YAAA,OAAO,cAAc;QACvB;QACA,IAAI,EAAE,KAAK,CAAC,IAAI,KAAK,KAAK,IAAI,EAAE;YAC9B,OAAO,GAAG,KAAK,GAAG,GAAG,gBAAgB,GAAG,iBAAiB;QAC3D;AACA,QAAA,OAAO,eAAe,CAAC,EAAE,CAAC;IAC5B;AAEA;;;;;;;;;;;;;;;AAeG;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.js';\nimport QuickLRU from 'quick-lru';\n\nconst classicCities = new Map<string, Location>();\n\n// Zip-Codes.com TimeZone IDs\nconst ZIPCODES_TZ_MAP: Readonly<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};\n\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 */\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 the 65\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 /**\n * First-level administrative division (e.g. a US state or a French\n * region) as an abbreviation, such as `\"CA\"`. Not set by this package;\n * populated by callers that hydrate a `Location` from a geo database.\n */\n admin1?: string;\n /**\n * Full name of the first-level administrative division, such as\n * `\"California\"`. Not set by this package.\n */\n stateName?: string;\n /**\n * Which kind of lookup produced this location: `'zip'` for a US Zip Code\n * or `'geoname'` for a GeoNames city. Not set by this package.\n */\n geo?: 'zip' | 'geoname';\n /** US Zip Code, such as `\"02912\"`. Not set by this package. */\n zip?: string;\n /** Approximate population of the city. Not set by this package. */\n population?: number;\n /** City name in plain ASCII, for sorting or URL generation. Not set by this package. */\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 = 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) || countryCode === '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 *\n * Note that the built-in classic cities are named by city alone, so\n * `getName()` and {@link getShortName} return the same string for them.\n * @example\n * const loc = new Location(41.85003, -87.65005, false,\n * 'America/Chicago', 'Chicago, Illinois, USA', 'US');\n * loc.getName(); // 'Chicago, Illinois, USA'\n * Location.lookup('San Francisco')?.getName(); // 'San Francisco'\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 * const chi = new Location(41.85003, -87.65005, false,\n * 'America/Chicago', 'Chicago, Illinois, USA', 'US');\n * chi.getShortName(); // 'Chicago'\n * const dc = new Location(38.89511, -77.03637, false,\n * 'America/New_York', 'Washington, D.C., USA', 'US');\n * dc.getShortName(); // 'Washington, D.C.'\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 }\n 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 65 \"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 }\n const plus = tz > 0 ? '+' : '';\n return `Etc/GMT${plus}${tz}`;\n }\n if (tz === 2 && dst === 'israel') {\n return 'Asia/Jerusalem';\n }\n 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 }\n 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 }\n if (tz === 7 && state === 'AZ') {\n return dst === 'Y' ? 'America/Denver' : 'America/Phoenix';\n }\n return ZIPCODES_TZ_MAP[tz];\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 65 classic Hebcal cities with\n * your own custom locations.\n * @example\n * const tlv = new Location(32.0853, 34.7818, true,\n * 'Asia/Jerusalem', 'My Office, Tel Aviv', 'IL');\n * Location.addLocation('My Office', tlv); // true\n * Location.lookup('my office')?.getTzid(); // 'Asia/Jerusalem'\n * @param cityName name to register the location under (case insensitive)\n * @param location the `Location` instance to register\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;A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"}
@@ -1,18 +1,13 @@
1
1
  import { HDate } from '@hebcal/hdate';
2
- /**
3
- * Yom HaShoah first observed in 1951.
4
- * When the actual date of Yom Hashoah falls on a Friday, the
5
- * state of Israel observes Yom Hashoah on the preceding
6
- * Thursday. When it falls on a Sunday, Yom Hashoah is observed
7
- * on the following Monday.
8
- * http://www.ushmm.org/remembrance/dor/calendar/
9
- * @private
10
- * @param year
11
- */
12
- export declare function dateYomHaShoah(year: number): HDate | null;
2
+ import { HolidayEvent } from './HolidayEvent.js';
13
3
  /**
14
4
  * Yom HaAtzma'ut only celebrated after 1948
15
- * @private
16
- * @param year
5
+ * @internal
17
6
  */
18
7
  export declare function dateYomHaZikaron(year: number): HDate | null;
8
+ /**
9
+ * Generates the modern Israeli holidays and memorial days for a Hebrew year.
10
+ * @internal
11
+ * @param year Hebrew year
12
+ */
13
+ export declare function modernHolidaysForYear(year: number): HolidayEvent[];
@@ -1,12 +1,18 @@
1
- /*! @hebcal/core v6.11.1, distributed under GPLv2 https://www.gnu.org/licenses/gpl-2.0.txt */
1
+ /*! @hebcal/core v6.13.1, distributed under GPLv2 https://www.gnu.org/licenses/gpl-2.0.txt */
2
2
  import { months, HDate } from '@hebcal/hdate';
3
+ import { flags } from './event.js';
4
+ import { HolidayEvent } from './HolidayEvent.js';
5
+ import { holidayDesc } from './staticHolidays.js';
3
6
 
4
- const SUN = 0;
5
- const TUE = 2;
6
- const FRI = 5;
7
- const SAT = 6;
8
- const NISAN = months.NISAN;
9
- const IYYAR = months.IYYAR;
7
+ var Day;
8
+ (function (Day) {
9
+ Day[Day["SUN"] = 0] = "SUN";
10
+ Day[Day["TUE"] = 2] = "TUE";
11
+ Day[Day["THU"] = 4] = "THU";
12
+ Day[Day["FRI"] = 5] = "FRI";
13
+ Day[Day["SAT"] = 6] = "SAT";
14
+ })(Day || (Day = {}));
15
+ const { NISAN, IYYAR, CHESHVAN } = months;
10
16
  /**
11
17
  * Yom HaShoah first observed in 1951.
12
18
  * When the actual date of Yom Hashoah falls on a Friday, the
@@ -14,26 +20,23 @@ const IYYAR = months.IYYAR;
14
20
  * Thursday. When it falls on a Sunday, Yom Hashoah is observed
15
21
  * on the following Monday.
16
22
  * http://www.ushmm.org/remembrance/dor/calendar/
17
- * @private
18
- * @param year
19
23
  */
20
24
  function dateYomHaShoah(year) {
21
25
  if (year < 5711) {
22
26
  return null;
23
27
  }
24
28
  let nisan27dt = new HDate(27, NISAN, year);
25
- if (nisan27dt.getDay() === FRI) {
29
+ if (nisan27dt.getDay() === Day.FRI) {
26
30
  nisan27dt = new HDate(26, NISAN, year);
27
31
  }
28
- else if (nisan27dt.getDay() === SUN) {
32
+ else if (nisan27dt.getDay() === Day.SUN) {
29
33
  nisan27dt = new HDate(28, NISAN, year);
30
34
  }
31
35
  return nisan27dt;
32
36
  }
33
37
  /**
34
38
  * Yom HaAtzma'ut only celebrated after 1948
35
- * @private
36
- * @param year
39
+ * @internal
37
40
  */
38
41
  function dateYomHaZikaron(year) {
39
42
  if (year < 5708) {
@@ -42,16 +45,16 @@ function dateYomHaZikaron(year) {
42
45
  let day;
43
46
  const pesach = new HDate(15, NISAN, year);
44
47
  const pdow = pesach.getDay();
45
- if (pdow === SUN) {
48
+ if (pdow === Day.SUN) {
46
49
  day = 2;
47
50
  }
48
- else if (pdow === SAT) {
51
+ else if (pdow === Day.SAT) {
49
52
  day = 3;
50
53
  }
51
54
  else if (year < 5764) {
52
55
  day = 4;
53
56
  }
54
- else if (pdow === TUE) {
57
+ else if (pdow === Day.TUE) {
55
58
  day = 5;
56
59
  }
57
60
  else {
@@ -59,6 +62,128 @@ function dateYomHaZikaron(year) {
59
62
  }
60
63
  return new HDate(day, IYYAR, year);
61
64
  }
65
+ function postpone(hd, rule) {
66
+ const dow = hd.getDay();
67
+ switch (rule) {
68
+ case 'friSatToThu':
69
+ return dow === Day.FRI || dow === Day.SAT ? hd.onOrBefore(Day.THU) : hd;
70
+ case 'friSatToSun':
71
+ if (dow === Day.FRI)
72
+ return hd.next().next();
73
+ return dow === Day.SAT ? hd.next() : hd;
74
+ case 'satToSun':
75
+ return dow === Day.SAT ? hd.next() : hd;
76
+ case undefined:
77
+ return hd;
78
+ default:
79
+ return rule;
80
+ }
81
+ }
82
+ const staticModernHolidays = [
83
+ {
84
+ firstYear: 5727,
85
+ mm: IYYAR,
86
+ dd: 28,
87
+ desc: holidayDesc.YOM_YERUSHALAYIM,
88
+ chul: true,
89
+ },
90
+ {
91
+ firstYear: 5737,
92
+ mm: months.KISLEV,
93
+ dd: 6,
94
+ desc: holidayDesc.BEN_GURION_DAY,
95
+ postpone: 'friSatToSun',
96
+ },
97
+ { firstYear: 5750, mm: months.SHVAT, dd: 30, desc: holidayDesc.FAMILY_DAY },
98
+ {
99
+ firstYear: 5758,
100
+ mm: CHESHVAN,
101
+ dd: 12,
102
+ desc: holidayDesc.YITZHAK_RABIN_MEMORIAL_DAY,
103
+ postpone: 'friSatToThu',
104
+ },
105
+ {
106
+ firstYear: 5764,
107
+ mm: IYYAR,
108
+ dd: 10,
109
+ desc: holidayDesc.HERZL_DAY,
110
+ postpone: 'satToSun',
111
+ },
112
+ {
113
+ firstYear: 5765,
114
+ mm: months.TAMUZ,
115
+ dd: 29,
116
+ desc: holidayDesc.JABOTINSKY_DAY,
117
+ postpone: 'satToSun',
118
+ },
119
+ {
120
+ firstYear: 5769,
121
+ mm: CHESHVAN,
122
+ dd: 29,
123
+ desc: holidayDesc.SIGD,
124
+ chul: true,
125
+ suppressEmoji: true,
126
+ postpone: 'friSatToThu',
127
+ },
128
+ { firstYear: 5777, mm: NISAN, dd: 10, desc: holidayDesc.YOM_HAALIYAH, chul: true },
129
+ {
130
+ firstYear: 5777,
131
+ mm: CHESHVAN,
132
+ dd: 7,
133
+ desc: holidayDesc.YOM_HAALIYAH_SCHOOL_OBSERVANCE,
134
+ },
135
+ // https://www.gov.il/he/departments/policies/2012_des5234
136
+ {
137
+ firstYear: 5773,
138
+ mm: months.TEVET,
139
+ dd: 21,
140
+ desc: holidayDesc.HEBREW_LANGUAGE_DAY,
141
+ postpone: 'friSatToThu',
142
+ },
143
+ /**
144
+ * https://fs.knesset.gov.il/25/law/25_lsr_14184773.pdf
145
+ * (Published in Sefer HaChukim No. 3567 on 8 Av 5786 / July 22, 2026)
146
+ */
147
+ {
148
+ firstYear: 5786,
149
+ mm: months.TISHREI,
150
+ dd: 24,
151
+ desc: holidayDesc.SWORDS_OF_IRON_WAR_MEMORIAL,
152
+ chul: true,
153
+ postpone: 'satToSun',
154
+ },
155
+ ];
156
+ const { MODERN_HOLIDAY, IL_ONLY } = flags;
157
+ const ISRAEL_FLAG = '🇮🇱';
158
+ const emojiIsraelFlag = { emoji: ISRAEL_FLAG };
159
+ /**
160
+ * Generates the modern Israeli holidays and memorial days for a Hebrew year.
161
+ * @internal
162
+ * @param year Hebrew year
163
+ */
164
+ function modernHolidaysForYear(year) {
165
+ const events = [];
166
+ const nisan27dt = dateYomHaShoah(year);
167
+ if (nisan27dt) {
168
+ events.push(new HolidayEvent(nisan27dt, holidayDesc.YOM_HASHOAH, MODERN_HOLIDAY));
169
+ }
170
+ const yomHaZikaronDt = dateYomHaZikaron(year);
171
+ if (yomHaZikaronDt) {
172
+ events.push(new HolidayEvent(yomHaZikaronDt, holidayDesc.YOM_HAZIKARON, MODERN_HOLIDAY, emojiIsraelFlag), new HolidayEvent(yomHaZikaronDt.next(), holidayDesc.YOM_HAATZMA_UT, MODERN_HOLIDAY, emojiIsraelFlag));
173
+ }
174
+ for (const h of staticModernHolidays) {
175
+ if (year >= h.firstYear) {
176
+ const hd = postpone(new HDate(h.dd, h.mm, year), h.postpone);
177
+ const mask = h.chul ? MODERN_HOLIDAY : MODERN_HOLIDAY | IL_ONLY;
178
+ const ev = new HolidayEvent(hd, h.desc, mask);
179
+ if (!h.suppressEmoji) {
180
+ ev.emoji = ISRAEL_FLAG;
181
+ }
182
+ events.push(ev);
183
+ }
184
+ }
185
+ return events;
186
+ }
62
187
 
63
- export { dateYomHaShoah, dateYomHaZikaron };
188
+ export { dateYomHaZikaron, modernHolidaysForYear };
64
189
  //# sourceMappingURL=modern.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"modern.js","sources":["../../../src/modern.ts"],"sourcesContent":["import {HDate, months} from '@hebcal/hdate';\n\nconst SUN = 0;\nconst TUE = 2;\nconst FRI = 5;\nconst SAT = 6;\n\nconst NISAN = months.NISAN;\nconst IYYAR = months.IYYAR;\n\n/**\n * Yom HaShoah first observed in 1951.\n * When the actual date of Yom Hashoah falls on a Friday, the\n * state of Israel observes Yom Hashoah on the preceding\n * Thursday. When it falls on a Sunday, Yom Hashoah is observed\n * on the following Monday.\n * http://www.ushmm.org/remembrance/dor/calendar/\n * @private\n * @param year\n */\nexport function dateYomHaShoah(year: number): HDate | null {\n if (year < 5711) {\n return null;\n }\n let nisan27dt = new HDate(27, NISAN, year);\n if (nisan27dt.getDay() === FRI) {\n nisan27dt = new HDate(26, NISAN, year);\n } else if (nisan27dt.getDay() === SUN) {\n nisan27dt = new HDate(28, NISAN, year);\n }\n return nisan27dt;\n}\n\n/**\n * Yom HaAtzma'ut only celebrated after 1948\n * @private\n * @param year\n */\nexport function dateYomHaZikaron(year: number): HDate | null {\n if (year < 5708) {\n return null;\n }\n let day;\n const pesach = new HDate(15, NISAN, year);\n const pdow = pesach.getDay();\n if (pdow === SUN) {\n day = 2;\n } else if (pdow === SAT) {\n day = 3;\n } else if (year < 5764) {\n day = 4;\n } else if (pdow === TUE) {\n day = 5;\n } else {\n day = 4;\n }\n return new HDate(day, IYYAR, year);\n}\n"],"names":[],"mappings":";;;AAEA,MAAM,GAAG,GAAG,CAAC;AACb,MAAM,GAAG,GAAG,CAAC;AACb,MAAM,GAAG,GAAG,CAAC;AACb,MAAM,GAAG,GAAG,CAAC;AAEb,MAAM,KAAK,GAAG,MAAM,CAAC,KAAK;AAC1B,MAAM,KAAK,GAAG,MAAM,CAAC,KAAK;AAE1B;;;;;;;;;AASG;AACG,SAAU,cAAc,CAAC,IAAY,EAAA;AACzC,IAAA,IAAI,IAAI,GAAG,IAAI,EAAE;AACf,QAAA,OAAO,IAAI;IACb;IACA,IAAI,SAAS,GAAG,IAAI,KAAK,CAAC,EAAE,EAAE,KAAK,EAAE,IAAI,CAAC;AAC1C,IAAA,IAAI,SAAS,CAAC,MAAM,EAAE,KAAK,GAAG,EAAE;QAC9B,SAAS,GAAG,IAAI,KAAK,CAAC,EAAE,EAAE,KAAK,EAAE,IAAI,CAAC;IACxC;AAAO,SAAA,IAAI,SAAS,CAAC,MAAM,EAAE,KAAK,GAAG,EAAE;QACrC,SAAS,GAAG,IAAI,KAAK,CAAC,EAAE,EAAE,KAAK,EAAE,IAAI,CAAC;IACxC;AACA,IAAA,OAAO,SAAS;AAClB;AAEA;;;;AAIG;AACG,SAAU,gBAAgB,CAAC,IAAY,EAAA;AAC3C,IAAA,IAAI,IAAI,GAAG,IAAI,EAAE;AACf,QAAA,OAAO,IAAI;IACb;AACA,IAAA,IAAI,GAAG;IACP,MAAM,MAAM,GAAG,IAAI,KAAK,CAAC,EAAE,EAAE,KAAK,EAAE,IAAI,CAAC;AACzC,IAAA,MAAM,IAAI,GAAG,MAAM,CAAC,MAAM,EAAE;AAC5B,IAAA,IAAI,IAAI,KAAK,GAAG,EAAE;QAChB,GAAG,GAAG,CAAC;IACT;AAAO,SAAA,IAAI,IAAI,KAAK,GAAG,EAAE;QACvB,GAAG,GAAG,CAAC;IACT;AAAO,SAAA,IAAI,IAAI,GAAG,IAAI,EAAE;QACtB,GAAG,GAAG,CAAC;IACT;AAAO,SAAA,IAAI,IAAI,KAAK,GAAG,EAAE;QACvB,GAAG,GAAG,CAAC;IACT;SAAO;QACL,GAAG,GAAG,CAAC;IACT;IACA,OAAO,IAAI,KAAK,CAAC,GAAG,EAAE,KAAK,EAAE,IAAI,CAAC;AACpC;;"}
1
+ {"version":3,"file":"modern.js","sources":["../../../src/modern.ts"],"sourcesContent":["import {HDate, months} from '@hebcal/hdate';\nimport {flags} from './event.js';\nimport {HolidayEvent} from './HolidayEvent.js';\nimport {holidayDesc as hdesc} from './staticHolidays.js';\n\nconst enum Day {\n SUN = 0,\n TUE = 2,\n THU = 4,\n FRI = 5,\n SAT = 6,\n}\n\nconst {NISAN, IYYAR, CHESHVAN} = months;\n\n/**\n * Yom HaShoah first observed in 1951.\n * When the actual date of Yom Hashoah falls on a Friday, the\n * state of Israel observes Yom Hashoah on the preceding\n * Thursday. When it falls on a Sunday, Yom Hashoah is observed\n * on the following Monday.\n * http://www.ushmm.org/remembrance/dor/calendar/\n */\nfunction dateYomHaShoah(year: number): HDate | null {\n if (year < 5711) {\n return null;\n }\n let nisan27dt = new HDate(27, NISAN, year);\n if (nisan27dt.getDay() === Day.FRI) {\n nisan27dt = new HDate(26, NISAN, year);\n } else if (nisan27dt.getDay() === Day.SUN) {\n nisan27dt = new HDate(28, NISAN, year);\n }\n return nisan27dt;\n}\n\n/**\n * Yom HaAtzma'ut only celebrated after 1948\n * @internal\n */\nexport function dateYomHaZikaron(year: number): HDate | null {\n if (year < 5708) {\n return null;\n }\n let day: number;\n const pesach = new HDate(15, NISAN, year);\n const pdow = pesach.getDay();\n if (pdow === Day.SUN) {\n day = 2;\n } else if (pdow === Day.SAT) {\n day = 3;\n } else if (year < 5764) {\n day = 4;\n } else if (pdow === Day.TUE) {\n day = 5;\n } else {\n day = 4;\n }\n return new HDate(day, IYYAR, year);\n}\n\n/**\n * How to move a holiday that would otherwise fall on Shabbat (or Friday).\n * - `friSatToThu`: Friday or Shabbat moves back to the preceding Thursday\n * - `friSatToSun`: Friday or Shabbat moves forward to Sunday\n * - `satToSun`: Shabbat moves forward to Sunday\n */\ntype Postponement = 'friSatToThu' | 'friSatToSun' | 'satToSun';\n\ninterface ModernHoliday {\n readonly firstYear: number;\n readonly mm: number; // This should be an enum `Month` eventually\n readonly dd: number;\n readonly desc: string;\n /** Observed outside Israel too */\n readonly chul?: boolean;\n readonly suppressEmoji?: boolean;\n readonly postpone?: Postponement;\n}\n\nfunction postpone(hd: HDate, rule: Postponement | undefined): HDate {\n const dow = hd.getDay();\n switch (rule) {\n case 'friSatToThu':\n return dow === Day.FRI || dow === Day.SAT ? hd.onOrBefore(Day.THU) : hd;\n case 'friSatToSun':\n if (dow === Day.FRI) return hd.next().next();\n return dow === Day.SAT ? hd.next() : hd;\n case 'satToSun':\n return dow === Day.SAT ? hd.next() : hd;\n case undefined:\n return hd;\n default:\n return rule satisfies never;\n }\n}\n\nconst staticModernHolidays: readonly ModernHoliday[] = [\n {\n firstYear: 5727,\n mm: IYYAR,\n dd: 28,\n desc: hdesc.YOM_YERUSHALAYIM,\n chul: true,\n },\n {\n firstYear: 5737,\n mm: months.KISLEV,\n dd: 6,\n desc: hdesc.BEN_GURION_DAY,\n postpone: 'friSatToSun',\n },\n {firstYear: 5750, mm: months.SHVAT, dd: 30, desc: hdesc.FAMILY_DAY},\n {\n firstYear: 5758,\n mm: CHESHVAN,\n dd: 12,\n desc: hdesc.YITZHAK_RABIN_MEMORIAL_DAY,\n postpone: 'friSatToThu',\n },\n {\n firstYear: 5764,\n mm: IYYAR,\n dd: 10,\n desc: hdesc.HERZL_DAY,\n postpone: 'satToSun',\n },\n {\n firstYear: 5765,\n mm: months.TAMUZ,\n dd: 29,\n desc: hdesc.JABOTINSKY_DAY,\n postpone: 'satToSun',\n },\n {\n firstYear: 5769,\n mm: CHESHVAN,\n dd: 29,\n desc: hdesc.SIGD,\n chul: true,\n suppressEmoji: true,\n postpone: 'friSatToThu',\n },\n {firstYear: 5777, mm: NISAN, dd: 10, desc: hdesc.YOM_HAALIYAH, chul: true},\n {\n firstYear: 5777,\n mm: CHESHVAN,\n dd: 7,\n desc: hdesc.YOM_HAALIYAH_SCHOOL_OBSERVANCE,\n },\n // https://www.gov.il/he/departments/policies/2012_des5234\n {\n firstYear: 5773,\n mm: months.TEVET,\n dd: 21,\n desc: hdesc.HEBREW_LANGUAGE_DAY,\n postpone: 'friSatToThu',\n },\n /**\n * https://fs.knesset.gov.il/25/law/25_lsr_14184773.pdf\n * (Published in Sefer HaChukim No. 3567 on 8 Av 5786 / July 22, 2026)\n */\n {\n firstYear: 5786,\n mm: months.TISHREI,\n dd: 24,\n desc: hdesc.SWORDS_OF_IRON_WAR_MEMORIAL,\n chul: true,\n postpone: 'satToSun',\n },\n];\n\nconst {MODERN_HOLIDAY, IL_ONLY} = flags;\nconst ISRAEL_FLAG = '🇮🇱';\nconst emojiIsraelFlag = {emoji: ISRAEL_FLAG} as const;\n\n/**\n * Generates the modern Israeli holidays and memorial days for a Hebrew year.\n * @internal\n * @param year Hebrew year\n */\nexport function modernHolidaysForYear(year: number): HolidayEvent[] {\n const events: HolidayEvent[] = [];\n const nisan27dt = dateYomHaShoah(year);\n if (nisan27dt) {\n events.push(new HolidayEvent(nisan27dt, hdesc.YOM_HASHOAH, MODERN_HOLIDAY));\n }\n\n const yomHaZikaronDt = dateYomHaZikaron(year);\n if (yomHaZikaronDt) {\n events.push(\n new HolidayEvent(\n yomHaZikaronDt,\n hdesc.YOM_HAZIKARON,\n MODERN_HOLIDAY,\n emojiIsraelFlag\n ),\n new HolidayEvent(\n yomHaZikaronDt.next(),\n hdesc.YOM_HAATZMA_UT,\n MODERN_HOLIDAY,\n emojiIsraelFlag\n )\n );\n }\n\n for (const h of staticModernHolidays) {\n if (year >= h.firstYear) {\n const hd = postpone(new HDate(h.dd, h.mm, year), h.postpone);\n const mask = h.chul ? MODERN_HOLIDAY : MODERN_HOLIDAY | IL_ONLY;\n const ev = new HolidayEvent(hd, h.desc, mask);\n if (!h.suppressEmoji) {\n ev.emoji = ISRAEL_FLAG;\n }\n events.push(ev);\n }\n }\n return events;\n}\n"],"names":["hdesc"],"mappings":";;;;;;AAKA,IAAW,GAMV;AAND,CAAA,UAAW,GAAG,EAAA;AACZ,IAAA,GAAA,CAAA,GAAA,CAAA,KAAA,CAAA,GAAA,CAAA,CAAA,GAAA,KAAO;AACP,IAAA,GAAA,CAAA,GAAA,CAAA,KAAA,CAAA,GAAA,CAAA,CAAA,GAA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ACnB,cAAc,EACd,eAAe,CAChB,EACD,IAAI,YAAY,CACd,cAAc,CAAC,IAAI,EAAE,EACrBA,WAAK,CAAC,cAAc,EACpB,cAAc,EACd,eAAe,CAChB,CACF;IACH;AAEA,IAAA,KAAK,MAAM,CAAC,IAAI,oBAAoB,EAAE;AACpC,QAAA,IAAI,IAAI,IAAI,CAAC,CAAC,SAAS,EAAE;YACvB,MAAM,EAAE,GAAG,QAAQ,CAAC,IAAI,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,EAAE,IAAI,CAAC,EAAE,CAAC,CAAC,QAAQ,CAAC;AAC5D,YAAA,MAAM,IAAI,GAAG,CAAC,CAAC,IAAI,GAAG,cAAc,GAAG,cAAc,GAAG,OAAO;AAC/D,YAAA,MAAM,EAAE,GAAG,IAAI,YAAY,CAAC,EAAE,EAAE,CAAC,CAAC,IAAI,EAAE,IAAI,CAAC;AAC7C,YAAA,IAAI,CAAC,CAAC,CAAC,aAAa,EAAE;AACpB,gBAAA,EAAE,CAAC,KAAK,GAAG,WAAW;YACxB;AACA,YAAA,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC;QACjB;IACF;AACA,IAAA,OAAO,MAAM;AACf;;"}
package/dist/esm/molad.js CHANGED
@@ -1,4 +1,4 @@
1
- /*! @hebcal/core v6.11.1, distributed under GPLv2 https://www.gnu.org/licenses/gpl-2.0.txt */
1
+ /*! @hebcal/core v6.13.1, distributed under GPLv2 https://www.gnu.org/licenses/gpl-2.0.txt */
2
2
  import 'temporal-polyfill/global';
3
3
  import { Event, flags } from './event.js';
4
4
  import { HDate, Locale, pad2 } from '@hebcal/hdate';
@@ -277,7 +277,7 @@ class Molad {
277
277
  if (chalakim === 0) {
278
278
  return result;
279
279
  }
280
- return result + ` ${and} ${chalakim} ${chalakimStr}`;
280
+ return `${result} ${and} ${chalakim} ${chalakimStr}`;
281
281
  }
282
282
  }
283
283
  /** Represents a Molad announcement on Shabbat Mevarchim */
@@ -1 +1 @@
1
- {"version":3,"file":"molad.js","sources":["../../../src/molad.ts"],"sourcesContent":["import 'temporal-polyfill/global';\nimport {Event, flags} from './event.js';\nimport {CalOptions} from './CalOptions.js';\nimport {HDate, Locale, pad2} from '@hebcal/hdate';\nimport {reformatTimeStr} from './reformatTimeStr.js';\nimport {MoladBase, calculateMolad} from './moladBase.js';\nimport {getMoladAsDate} from './moladDate.js';\nimport {smartApostrophe} from './string.js';\nimport './locale.js'; // 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 }\n if (locale === 'fr') {\n return frDoW;\n }\n return enDoW;\n}\n\nfunction getHebrewTimeOfDay(hour: number): string {\n if (hour < 5) return night;\n if (hour < 12) return 'בַּבֹּקֶר';\n if (hour < 17) return 'בַּצׇּהֳרַיִים';\n 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()); // 22 57 7\n * console.log(m.render('en')); // 'Molad Nisan: Monday, 10:57pm and 7 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 moment of the molad as a `Temporal.ZonedDateTime` in the `UTC` zone.\n *\n * The molad is computed in Jerusalem *standard* time and then converted, so the\n * returned instant is correct year-round; only the zone of the returned object\n * is `UTC`. This method subtracts 20.94 minutes (20 minutes and 56.496 seconds)\n * from the computed time — Har Habayis, at longitude 35.2354°, is 5.2354° away\n * from the multiple-of-15 timezone longitude — to get to standard time. Daylight\n * savings time is intentionally not applied; adjust when formatting for display.\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()); // '2024-04-08T20:36:26.837+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\n * [Mechaber](https://en.wikipedia.org/wiki/Yosef_Karo). See the\n * [Bach's](https://en.wikipedia.org/wiki/Yoel_Sirkis) 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\n * [Maharil's](https://en.wikipedia.org/wiki/Yaakov_ben_Moshe_Levi_Moelin) 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 * [Rema](https://en.wikipedia.org/wiki/Moses_Isserles) who brings down the opinion of the\n * [Maharil's](https://en.wikipedia.org/wiki/Yaakov_ben_Moshe_Levi_Moelin) of calculating\n * {@link Molad.getSofZmanKidushLevanaBetweenMoldos | half way between molad and molad} 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\n * [Shaarei Zmanim](https://www.worldcat.org/oclc/461326125). 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 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: Monday, 10:57pm and 7 chalakim'\n * m.render('en', {hour12: false});\n * // => 'Molad Nisan: Monday, 22:57 and 7 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 = smartApostrophe(monthName);\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":";;;;;;;;;;AAUA,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;AACA,IAAA,IAAI,MAAM,KAAK,IAAI,EAAE;AACnB,QAAA,OAAO,KAAK;IACd;AACA,IAAA,OAAO,KAAK;AACd;AAEA,SAAS,kBAAkB,CAAC,IAAY,EAAA;IACtC,IAAI,IAAI,GAAG,CAAC;AAAE,QAAA,OAAO,KAAK;IAC1B,IAAI,IAAI,GAAG,EAAE;AAAE,QAAA,OAAO,WAAW;IACjC,IAAI,IAAI,GAAG,EAAE;AAAE,QAAA,OAAO,gBAAgB;IACtC,IAAI,IAAI,GAAG,EAAE;AAAE,QAAA,OAAO,UAAU;AAChC,IAAA,OAAO,KAAK;AACd;AAEA;;;;;;;;;;;;;;;AAeG;MACU,KAAK,CAAA;AACC,IAAA,CAAC;AACD,IAAA,IAAI;AAC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Q,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-polyfill/global';\nimport {Event, flags} from './event.js';\nimport {CalOptions} from './CalOptions.js';\nimport {HDate, Locale, pad2} from '@hebcal/hdate';\nimport {reformatTimeStr} from './reformatTimeStr.js';\nimport {MoladBase, calculateMolad} from './moladBase.js';\nimport {getMoladAsDate} from './moladDate.js';\nimport {smartApostrophe} from './string.js';\nimport './locale.js'; // 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 }\n if (locale === 'fr') {\n return frDoW;\n }\n return enDoW;\n}\n\nfunction getHebrewTimeOfDay(hour: number): string {\n if (hour < 5) return night;\n if (hour < 12) return 'בַּבֹּקֶר';\n if (hour < 17) return 'בַּצׇּהֳרַיִים';\n 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()); // 22 57 7\n * console.log(m.render('en')); // 'Molad Nisan: Monday, 10:57pm and 7 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 moment of the molad as a `Temporal.ZonedDateTime` in the `UTC` zone.\n *\n * The molad is computed in Jerusalem *standard* time and then converted, so the\n * returned instant is correct year-round; only the zone of the returned object\n * is `UTC`. This method subtracts 20.94 minutes (20 minutes and 56.496 seconds)\n * from the computed time — Har Habayis, at longitude 35.2354°, is 5.2354° away\n * from the multiple-of-15 timezone longitude — to get to standard time. Daylight\n * savings time is intentionally not applied; adjust when formatting for display.\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()); // '2024-04-08T20:36:26.837+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\n * [Mechaber](https://en.wikipedia.org/wiki/Yosef_Karo). See the\n * [Bach's](https://en.wikipedia.org/wiki/Yoel_Sirkis) 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\n * [Maharil's](https://en.wikipedia.org/wiki/Yaakov_ben_Moshe_Levi_Moelin) 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 * [Rema](https://en.wikipedia.org/wiki/Moses_Isserles) who brings down the opinion of the\n * [Maharil's](https://en.wikipedia.org/wiki/Yaakov_ben_Moshe_Levi_Moelin) of calculating\n * {@link Molad.getSofZmanKidushLevanaBetweenMoldos | half way between molad and molad} 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\n * [Shaarei Zmanim](https://www.worldcat.org/oclc/461326125). 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 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: Monday, 10:57pm and 7 chalakim'\n * m.render('en', {hour12: false});\n * // => 'Molad Nisan: Monday, 22:57 and 7 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 = smartApostrophe(monthName);\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":";;;;;;;;;;AAUA,MAAM,KAAK,GAAG;IACZ,QAAQ;IACR,QAAQ;IACR,SAAS;IACT,WAAW;IACX,UAAU;IACV,QAAQ;IACR,UAAU;CACF;AAEV,MAAM,UAAU,GAAG;IACjB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AG,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.11.1, distributed under GPLv2 https://www.gnu.org/licenses/gpl-2.0.txt */
1
+ /*! @hebcal/core v6.13.1, distributed under GPLv2 https://www.gnu.org/licenses/gpl-2.0.txt */
2
2
  import { HDate, isLeapYear } from '@hebcal/hdate';
3
3
 
4
4
  /*
@@ -81,13 +81,12 @@ function calculateMolad(year, month) {
81
81
  hd = hd.next();
82
82
  }
83
83
  hour = (hour + 18) % 24;
84
- const m = {
84
+ return {
85
85
  hdate: hd,
86
86
  hour,
87
87
  minutes,
88
88
  chalakim: adjustedChalakim - minutes * CHALAKIM_PER_MINUTE,
89
89
  };
90
- return m;
91
90
  }
92
91
 
93
92
  export { calculateMolad };
@@ -1 +1 @@
1
- {"version":3,"file":"moladBase.js","sources":["../../../src/moladBase.ts"],"sourcesContent":["import {HDate, isLeapYear} from '@hebcal/hdate';\n\n/**\n * Represents a molad, the moment when the new moon is \"born\"\n */\nexport type MoladBase = {\n /** Hebrew date */\n readonly hdate: HDate;\n /** hour of day (0-23) */\n readonly hour: number;\n /** minutes past hour (0-59) */\n readonly minutes: number;\n /** parts of a minute (0-17) */\n readonly chalakim: number;\n};\n\n/*\n * Includes code ported from KosherJava, copyright 2004 Eliyahu Hershfeld,\n * released under LGPL 2.1.\n */\n\n/**\n * the Jewish epoch using the RD (Rata Die/Fixed Date or Reingold Dershowitz) day used in Calendrical Calculations.\n * Day 1 is January 1, 0001 of the Gregorian calendar\n */\nconst JEWISH_EPOCH: number = -1373429;\n\n/** The number of _chalakim_ (18) in a minute. */\nconst CHALAKIM_PER_MINUTE: number = 18;\n\n/** The number of _chalakim_ (1080) in an hour. */\nconst CHALAKIM_PER_HOUR: number = 1080;\n\n/** The number of _chalakim_ (25,920) in a 24-hour day. */\nconst CHALAKIM_PER_DAY: number = 25920; // 24 * 1080\n\n/** The number of _chalakim_ in an average Jewish month. A month has 29 days, 12 hours and 793\n * _chalakim_ (44 minutes and 3.3 seconds) for a total of 765,433 _chalakim_ */\nconst CHALAKIM_PER_MONTH: number = 765433; // (29 * 24 + 12) * 1080 + 793\n\n/**\n * Days from the beginning of Sunday till _molad BaHaRaD_. Calculated as 1 day, 5 hours and 204 _chalakim_ =\n * (24 + 5) * 1080 + 204 = 31524\n */\nconst CHALAKIM_MOLAD_TOHU: number = 31524;\n\n/**\n * Converts the NISSAN-based constants used by this class to numeric month starting from\n * TISHREI. This is required for _molad_ calculations.\n */\nfunction getJewishMonthOfYear(year: number, month: number): number {\n const leap: boolean = isLeapYear(year);\n return ((month + (leap ? 6 : 5)) % (leap ? 13 : 12)) + 1;\n}\n\n/**\n * Returns the number of _chalakim_ (parts - 1080 to the hour) from\n * the original hypothetical _Molad Tohu_ to the year and month\n * passed in.\n */\nfunction getChalakimSinceMoladTohu(year: number, month: number): number {\n // Jewish lunar month = 29 days, 12 hours and 793 chalakim\n // chalakim since Molad Tohu BeHaRaD - 1 day, 5 hours and 204 chalakim\n const monthOfYear: number = getJewishMonthOfYear(year, month);\n const monthsElapsed: number =\n 235 * Math.trunc((year - 1) / 19) + // Months in complete 19-year lunar (Metonic) cycles so far\n 12 * ((year - 1) % 19) + // Regular months in this cycle\n Math.trunc((7 * ((year - 1) % 19) + 1) / 19) + // Leap months this cycle\n (monthOfYear - 1); // add elapsed months till the start of the molad of the month\n // return chalakim prior to BeHaRaD + number of chalakim since\n return CHALAKIM_MOLAD_TOHU + CHALAKIM_PER_MONTH * monthsElapsed;\n}\n\n/**\n * Returns the number of days from the Jewish epoch from the number of chalakim from the epoch passed in.\n * @param chalakim the number of _chalakim_ since the beginning of Sunday prior to BaHaRaD\n * @return the number of days from the Jewish epoch\n */\nfunction moladToAbsDate(chalakim: number): number {\n return Math.trunc(chalakim / CHALAKIM_PER_DAY) + JEWISH_EPOCH;\n}\n\n/**\n * Calculates the molad (birth of the new moon) for a Hebrew month using\n * traditional chalakim arithmetic.\n *\n * Returns the raw components — day of week, hour, minutes and chalakim. Use\n * {@link Molad} for a higher-level interface with rendering and Kiddush Levana\n * times.\n * @param year Hebrew year\n * @param month Hebrew month (see `months` from `@hebcal/hdate`)\n * @return the components of the molad for that month\n */\nexport function calculateMolad(year: number, month: number): MoladBase {\n const chalakim = getChalakimSinceMoladTohu(year, month);\n const absDate = moladToAbsDate(chalakim);\n let hd = new HDate(absDate);\n const conjunctionDay: number = Math.trunc(chalakim / CHALAKIM_PER_DAY);\n const conjunctionParts: number = Math.trunc(\n chalakim - conjunctionDay * CHALAKIM_PER_DAY\n );\n\n let adjustedChalakim: number = conjunctionParts;\n let hour = Math.trunc(adjustedChalakim / CHALAKIM_PER_HOUR);\n adjustedChalakim = adjustedChalakim - hour * CHALAKIM_PER_HOUR;\n const minutes = Math.trunc(adjustedChalakim / CHALAKIM_PER_MINUTE);\n\n if (hour >= 6) {\n hd = hd.next();\n }\n hour = (hour + 18) % 24;\n\n const m: MoladBase = {\n hdate: hd,\n hour,\n minutes,\n chalakim: adjustedChalakim - minutes * CHALAKIM_PER_MINUTE,\n };\n\n return m;\n}\n"],"names":[],"mappings":";;;AAgBA;;;AAGG;AAEH;;;AAGG;AACH,MAAM,YAAY,GAAW,QAAQ;AAErC;AACA,MAAM,mBAAmB,GAAW,EAAE;AAEtC;AACA,MAAM,iBAAiB,GAAW,IAAI;AAEtC;AACA,MAAM,gBAAgB,GAAW,KAAK,CAAC;AAEvC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,IAAI,KAAK,CAAC,OAAO,CAAC;IAC3B,MAAM,cAAc,GAAW,IAAI,CAAC,KAAK,CAAC,QAAQ,GAAG,gBAAgB,CAAC;AACtE,IAAA,MAAM,gBAAgB,GAAW,IAAI,CAAC,KAAK,CACzC,QAAQ,GAAG,cAAc,GAAG,gBAAgB,CAC7C;IAED,IAAI,gBAAgB,GAAW,gBAAgB;IAC/C,IAAI,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,gBAAgB,GAAG,iBAAiB,CAAC;AAC3D,IAAA,gBAAgB,GAAG,gBAAgB,GAAG,IAAI,GAAG,iBAAiB;IAC9D,MAAM,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,gBAAgB,GAAG,mBAAmB,CAAC;AAElE,IAAA,IAAI,IAAI,IAAI,CAAC,EAAE;AACb,QAAA,EAAE,GAAG,EAAE,CAAC,IAAI,EAAE;IAChB;IACA,IAAI,GAAG,CAAC,IAAI,GAAG,EAAE,IAAI,EAAE;AAEvB,IAAA,MAAM,CAAC,GAAc;AACnB,QAAA,KAAK,EAAE,EAAE;QACT,IAAI;QACJ,OAAO;AACP,QAAA,QAAQ,EAAE,gBAAgB,GAAG,OAAO,GAAG,mBAAmB;KAC3D;AAED,IAAA,OAAO,CAAC;AACV;;"}
1
+ {"version":3,"file":"moladBase.js","sources":["../../../src/moladBase.ts"],"sourcesContent":["import {HDate, isLeapYear} from '@hebcal/hdate';\n\n/**\n * Represents a molad, the moment when the new moon is \"born\"\n */\nexport type MoladBase = {\n /** Hebrew date */\n readonly hdate: HDate;\n /** hour of day (0-23) */\n readonly hour: number;\n /** minutes past hour (0-59) */\n readonly minutes: number;\n /** parts of a minute (0-17) */\n readonly chalakim: number;\n};\n\n/*\n * Includes code ported from KosherJava, copyright 2004 Eliyahu Hershfeld,\n * released under LGPL 2.1.\n */\n\n/**\n * the Jewish epoch using the RD (Rata Die/Fixed Date or Reingold Dershowitz) day used in Calendrical Calculations.\n * Day 1 is January 1, 0001 of the Gregorian calendar\n */\nconst JEWISH_EPOCH = -1373429;\n\n/** The number of _chalakim_ (18) in a minute. */\nconst CHALAKIM_PER_MINUTE = 18;\n\n/** The number of _chalakim_ (1080) in an hour. */\nconst CHALAKIM_PER_HOUR = 1080;\n\n/** The number of _chalakim_ (25,920) in a 24-hour day. */\nconst CHALAKIM_PER_DAY = 25920; // 24 * 1080\n\n/** The number of _chalakim_ in an average Jewish month. A month has 29 days, 12 hours and 793\n * _chalakim_ (44 minutes and 3.3 seconds) for a total of 765,433 _chalakim_ */\nconst CHALAKIM_PER_MONTH = 765433; // (29 * 24 + 12) * 1080 + 793\n\n/**\n * Days from the beginning of Sunday till _molad BaHaRaD_. Calculated as 1 day, 5 hours and 204 _chalakim_ =\n * (24 + 5) * 1080 + 204 = 31524\n */\nconst CHALAKIM_MOLAD_TOHU = 31524;\n\n/**\n * Converts the NISSAN-based constants used by this class to numeric month starting from\n * TISHREI. This is required for _molad_ calculations.\n */\nfunction getJewishMonthOfYear(year: number, month: number): number {\n const leap = isLeapYear(year);\n return ((month + (leap ? 6 : 5)) % (leap ? 13 : 12)) + 1;\n}\n\n/**\n * Returns the number of _chalakim_ (parts - 1080 to the hour) from\n * the original hypothetical _Molad Tohu_ to the year and month\n * passed in.\n */\nfunction getChalakimSinceMoladTohu(year: number, month: number): number {\n // Jewish lunar month = 29 days, 12 hours and 793 chalakim\n // chalakim since Molad Tohu BeHaRaD - 1 day, 5 hours and 204 chalakim\n const monthOfYear = getJewishMonthOfYear(year, month);\n const monthsElapsed: number =\n 235 * Math.trunc((year - 1) / 19) + // Months in complete 19-year lunar (Metonic) cycles so far\n 12 * ((year - 1) % 19) + // Regular months in this cycle\n Math.trunc((7 * ((year - 1) % 19) + 1) / 19) + // Leap months this cycle\n (monthOfYear - 1); // add elapsed months till the start of the molad of the month\n // return chalakim prior to BeHaRaD + number of chalakim since\n return CHALAKIM_MOLAD_TOHU + CHALAKIM_PER_MONTH * monthsElapsed;\n}\n\n/**\n * Returns the number of days from the Jewish epoch from the number of chalakim from the epoch passed in.\n * @param chalakim the number of _chalakim_ since the beginning of Sunday prior to BaHaRaD\n * @return the number of days from the Jewish epoch\n */\nfunction moladToAbsDate(chalakim: number): number {\n return Math.trunc(chalakim / CHALAKIM_PER_DAY) + JEWISH_EPOCH;\n}\n\n/**\n * Calculates the molad (birth of the new moon) for a Hebrew month using\n * traditional chalakim arithmetic.\n *\n * Returns the raw components — day of week, hour, minutes and chalakim. Use\n * {@link Molad} for a higher-level interface with rendering and Kiddush Levana\n * times.\n * @param year Hebrew year\n * @param month Hebrew month (see `months` from `@hebcal/hdate`)\n * @return the components of the molad for that month\n */\nexport function calculateMolad(year: number, month: number): MoladBase {\n const chalakim = getChalakimSinceMoladTohu(year, month);\n const absDate = moladToAbsDate(chalakim);\n let hd = new HDate(absDate);\n const conjunctionDay = Math.trunc(chalakim / CHALAKIM_PER_DAY);\n const conjunctionParts = Math.trunc(chalakim - conjunctionDay * CHALAKIM_PER_DAY);\n\n let adjustedChalakim = conjunctionParts;\n let hour = Math.trunc(adjustedChalakim / CHALAKIM_PER_HOUR);\n adjustedChalakim = adjustedChalakim - hour * CHALAKIM_PER_HOUR;\n const minutes = Math.trunc(adjustedChalakim / CHALAKIM_PER_MINUTE);\n\n if (hour >= 6) {\n hd = hd.next();\n }\n hour = (hour + 18) % 24;\n\n return {\n hdate: hd,\n hour,\n minutes,\n chalakim: adjustedChalakim - minutes * CHALAKIM_PER_MINUTE,\n };\n}\n"],"names":[],"mappings":";;;AAgBA;;;AAGG;AAEH;;;AAGG;AACH,MAAM,YAAY,GAAG,QAAQ;AAE7B;AACA,MAAM,mBAAmB,GAAG,EAAE;AAE9B;AACA,MAAM,iBAAiB,GAAG,IAAI;AAE9B;AACA,MAAM,gBAAgB,GAAG,KAAK,CAAC;AAE/B;AAC+E;AAC/E,MAAM,kBAAkB,GAAG,MAAM,CAAC;AAElC;;;AAGG;AACH,MAAM,mBAAmB,GAAG,KAAK;AAEjC;;;AAGG;AACH,SAAS,o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AAM,gBAAgB,GAAG,IAAI,CAAC,KAAK,CAAC,QAAQ,GAAG,cAAc,GAAG,gBAAgB,CAAC;IAEjF,IAAI,gBAAgB,GAAG,gBAAgB;IACvC,IAAI,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,gBAAgB,GAAG,iBAAiB,CAAC;AAC3D,IAAA,gBAAgB,GAAG,gBAAgB,GAAG,IAAI,GAAG,iBAAiB;IAC9D,MAAM,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,gBAAgB,GAAG,mBAAmB,CAAC;AAElE,IAAA,IAAI,IAAI,IAAI,CAAC,EAAE;AACb,QAAA,EAAE,GAAG,EAAE,CAAC,IAAI,EAAE;IAChB;IACA,IAAI,GAAG,CAAC,IAAI,GAAG,EAAE,IAAI,EAAE;IAEvB,OAAO;AACL,QAAA,KAAK,EAAE,EAAE;QACT,IAAI;QACJ,OAAO;AACP,QAAA,QAAQ,EAAE,gBAAgB,GAAG,OAAO,GAAG,mBAAmB;KAC3D;AACH;;"}
@@ -1,4 +1,4 @@
1
- /*! @hebcal/core v6.11.1, distributed under GPLv2 https://www.gnu.org/licenses/gpl-2.0.txt */
1
+ /*! @hebcal/core v6.13.1, distributed under GPLv2 https://www.gnu.org/licenses/gpl-2.0.txt */
2
2
  import 'temporal-polyfill/global';
3
3
  import { getTimezoneOffset } from '@hebcal/hdate';
4
4