@hebcal/core 6.5.3 → 6.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (163) hide show
  1. package/README.md +4 -4
  2. package/dist/bundle.js +6525 -5562
  3. package/dist/bundle.js.map +1 -1
  4. package/dist/bundle.min.js +18 -18
  5. package/dist/bundle.min.js.map +1 -1
  6. package/dist/esm/CalOptions.d.ts +15 -3
  7. package/dist/esm/DailyLearning.js +1 -1
  8. package/dist/esm/HebrewDateEvent.js +1 -1
  9. package/dist/esm/HolidayEvent.js +7 -6
  10. package/dist/esm/HolidayEvent.js.map +1 -1
  11. package/dist/esm/MevarchimChodeshEvent.js +3 -2
  12. package/dist/esm/MevarchimChodeshEvent.js.map +1 -1
  13. package/dist/esm/ParshaEvent.js +18 -7
  14. package/dist/esm/ParshaEvent.js.map +1 -1
  15. package/dist/esm/TimedEvent.js +1 -1
  16. package/dist/esm/TimedEvent.js.map +1 -1
  17. package/dist/esm/YomKippurKatanEvent.js +3 -2
  18. package/dist/esm/YomKippurKatanEvent.js.map +1 -1
  19. package/dist/esm/ashkenazi.po.js +2 -2
  20. package/dist/esm/ashkenazi.po.js.map +1 -1
  21. package/dist/esm/calendar.js +14 -20
  22. package/dist/esm/calendar.js.map +1 -1
  23. package/dist/esm/candles.d.ts +8 -3
  24. package/dist/esm/candles.js +65 -11
  25. package/dist/esm/candles.js.map +1 -1
  26. package/dist/esm/cities.json.js +1 -1
  27. package/dist/esm/event.js +1 -1
  28. package/dist/esm/getStartAndEnd.js +1 -1
  29. package/dist/esm/hallel.js +1 -1
  30. package/dist/esm/he-x-NoNikud.po.js +1 -1
  31. package/dist/esm/he.po.d.ts +0 -1
  32. package/dist/esm/he.po.js +2 -2
  33. package/dist/esm/he.po.js.map +1 -1
  34. package/dist/esm/hebcal.js +1 -1
  35. package/dist/esm/holidays.js +1 -1
  36. package/dist/esm/holidays.js.map +1 -1
  37. package/dist/esm/index.js +1 -1
  38. package/dist/esm/isAssurBemlacha.js +1 -1
  39. package/dist/esm/isAveilut.js +1 -1
  40. package/dist/esm/isFastDay.js +1 -1
  41. package/dist/esm/locale.js +1 -1
  42. package/dist/esm/location.js +1 -1
  43. package/dist/esm/location.js.map +1 -1
  44. package/dist/esm/modern.js +1 -1
  45. package/dist/esm/molad.d.ts +1 -1
  46. package/dist/esm/molad.js +4 -3
  47. package/dist/esm/molad.js.map +1 -1
  48. package/dist/esm/moladBase.js +1 -1
  49. package/dist/esm/moladDate.d.ts +1 -1
  50. package/dist/esm/moladDate.js +2 -2
  51. package/dist/esm/moladDate.js.map +1 -1
  52. package/dist/esm/omer.js +1 -1
  53. package/dist/esm/parshaName.js +3 -2
  54. package/dist/esm/parshaName.js.map +1 -1
  55. package/dist/esm/parshaYear.js +1 -1
  56. package/dist/esm/pkgVersion.d.ts +1 -1
  57. package/dist/esm/pkgVersion.js +2 -2
  58. package/dist/esm/pkgVersion.js.map +1 -1
  59. package/dist/esm/reformatTimeStr.js +1 -1
  60. package/dist/esm/reformatTimeStr.js.map +1 -1
  61. package/dist/esm/sedra.d.ts +14 -0
  62. package/dist/esm/sedra.js +62 -1
  63. package/dist/esm/sedra.js.map +1 -1
  64. package/dist/esm/sefira.json.js +1 -1
  65. package/dist/esm/staticHolidays.js +1 -1
  66. package/dist/esm/string.d.ts +2 -0
  67. package/dist/esm/string.js +10 -0
  68. package/dist/esm/string.js.map +1 -0
  69. package/dist/esm/tachanun.js +1 -1
  70. package/dist/esm/tachanun.js.map +1 -1
  71. package/dist/esm/zmanim.d.ts +1 -1
  72. package/dist/esm/zmanim.js +3 -4
  73. package/dist/esm/zmanim.js.map +1 -1
  74. package/package.json +18 -21
  75. package/po/ashkenazi.po +1 -12
  76. package/po/he.po +0 -3
  77. package/dist/eslint.config.d.mts +0 -83
  78. package/dist/eslint.config.mjs +0 -29
  79. package/dist/esm/temporal-shim.d.ts +0 -1
  80. package/dist/esm/temporal-shim.js +0 -11
  81. package/dist/esm/temporal-shim.js.map +0 -1
  82. package/dist/po2json.d.ts +0 -1
  83. package/dist/po2json.js +0 -40
  84. package/dist/src/CalOptions.d.ts +0 -171
  85. package/dist/src/CalOptions.js +0 -1
  86. package/dist/src/DailyLearning.d.ts +0 -69
  87. package/dist/src/DailyLearning.js +0 -92
  88. package/dist/src/HebrewDateEvent.d.ts +0 -37
  89. package/dist/src/HebrewDateEvent.js +0 -72
  90. package/dist/src/HolidayEvent.d.ts +0 -117
  91. package/dist/src/HolidayEvent.js +0 -235
  92. package/dist/src/MevarchimChodeshEvent.d.ts +0 -26
  93. package/dist/src/MevarchimChodeshEvent.js +0 -51
  94. package/dist/src/ParshaEvent.d.ts +0 -24
  95. package/dist/src/ParshaEvent.js +0 -49
  96. package/dist/src/TimedEvent.d.ts +0 -76
  97. package/dist/src/TimedEvent.js +0 -134
  98. package/dist/src/YomKippurKatanEvent.d.ts +0 -23
  99. package/dist/src/YomKippurKatanEvent.js +0 -39
  100. package/dist/src/ashkenazi.po.d.ts +0 -84
  101. package/dist/src/ashkenazi.po.js +0 -1
  102. package/dist/src/calendar.d.ts +0 -112
  103. package/dist/src/calendar.js +0 -721
  104. package/dist/src/candles.d.ts +0 -57
  105. package/dist/src/candles.js +0 -185
  106. package/dist/src/cities.json +0 -67
  107. package/dist/src/event.d.ts +0 -233
  108. package/dist/src/event.js +0 -295
  109. package/dist/src/getStartAndEnd.d.ts +0 -6
  110. package/dist/src/getStartAndEnd.js +0 -105
  111. package/dist/src/hallel.d.ts +0 -6
  112. package/dist/src/hallel.js +0 -39
  113. package/dist/src/he-x-NoNikud.po.d.ts +0 -28
  114. package/dist/src/he-x-NoNikud.po.js +0 -1
  115. package/dist/src/he.po.d.ts +0 -218
  116. package/dist/src/he.po.js +0 -1
  117. package/dist/src/hebcal.d.ts +0 -338
  118. package/dist/src/hebcal.js +0 -413
  119. package/dist/src/holidays.d.ts +0 -41
  120. package/dist/src/holidays.js +0 -324
  121. package/dist/src/index.d.ts +0 -30
  122. package/dist/src/index.js +0 -29
  123. package/dist/src/isAssurBemlacha.d.ts +0 -29
  124. package/dist/src/isAssurBemlacha.js +0 -82
  125. package/dist/src/isAveilut.d.ts +0 -22
  126. package/dist/src/isAveilut.js +0 -48
  127. package/dist/src/isFastDay.d.ts +0 -21
  128. package/dist/src/isFastDay.js +0 -31
  129. package/dist/src/locale.d.ts +0 -1
  130. package/dist/src/locale.js +0 -11
  131. package/dist/src/location.d.ts +0 -167
  132. package/dist/src/location.js +0 -342
  133. package/dist/src/modern.d.ts +0 -18
  134. package/dist/src/modern.js +0 -59
  135. package/dist/src/molad.d.ts +0 -164
  136. package/dist/src/molad.js +0 -297
  137. package/dist/src/moladBase.d.ts +0 -15
  138. package/dist/src/moladBase.js +0 -78
  139. package/dist/src/moladDate.d.ts +0 -12
  140. package/dist/src/moladDate.js +0 -58
  141. package/dist/src/omer.d.ts +0 -128
  142. package/dist/src/omer.js +0 -385
  143. package/dist/src/parshaName.d.ts +0 -2
  144. package/dist/src/parshaName.js +0 -12
  145. package/dist/src/parshaYear.d.ts +0 -20
  146. package/dist/src/parshaYear.js +0 -35
  147. package/dist/src/pkgVersion.d.ts +0 -2
  148. package/dist/src/pkgVersion.js +0 -2
  149. package/dist/src/reformatTimeStr.d.ts +0 -8
  150. package/dist/src/reformatTimeStr.js +0 -47
  151. package/dist/src/sedra.d.ts +0 -175
  152. package/dist/src/sedra.js +0 -563
  153. package/dist/src/sefira.json +0 -63
  154. package/dist/src/staticHolidays.d.ts +0 -192
  155. package/dist/src/staticHolidays.js +0 -637
  156. package/dist/src/tachanun.d.ts +0 -29
  157. package/dist/src/tachanun.js +0 -120
  158. package/dist/src/temporal-shim.d.ts +0 -1
  159. package/dist/src/temporal-shim.js +0 -8
  160. package/dist/src/zmanim.d.ts +0 -620
  161. package/dist/src/zmanim.js +0 -1003
  162. package/dist/version.d.ts +0 -1
  163. package/dist/version.js +0 -8
@@ -1,167 +0,0 @@
1
- import { GeoLocation } from '@hebcal/noaa';
2
- /**
3
- * Class representing a geographic location for use with candle-lighting,
4
- * havdalah, and zmanim calculations.
5
- *
6
- * Extends {@link GeoLocation} from `@hebcal/noaa` with Jewish-calendar
7
- * specific data: an Israel/Diaspora flag, ISO country code, and an optional
8
- * geographic identifier. Also provides {@link Location.lookup} for ~60
9
- * built-in "classic" Hebcal cities.
10
- *
11
- * @example
12
- * import {Location} from '@hebcal/core';
13
- *
14
- * // Create a location for a custom address
15
- * const loc = new Location(
16
- * 41.85003, // latitude
17
- * -87.65005, // longitude
18
- * false, // not in Israel
19
- * 'America/Chicago',
20
- * 'Chicago, Illinois, USA',
21
- * 'US'
22
- * );
23
- *
24
- * // Or look up a built-in classic city
25
- * const tlv = Location.lookup('Tel Aviv');
26
- */
27
- export declare class Location extends GeoLocation {
28
- private readonly il;
29
- private readonly cc?;
30
- private readonly geoid?;
31
- admin1?: string;
32
- stateName?: string;
33
- geo?: 'zip' | 'geoname';
34
- zip?: string;
35
- population?: number;
36
- asciiname?: string;
37
- /**
38
- * Initialize a Location instance
39
- * @param latitude - Latitude as a decimal, valid range -90 thru +90 (e.g. 41.85003)
40
- * @param longitude - Longitude as a decimal, valid range -180 thru +180 (e.g. -87.65005)
41
- * @param il - in Israel (true) or Diaspora (false)
42
- * @param tzid - Olson timezone ID, e.g. "America/Chicago"
43
- * @param [cityName] - optional descriptive city name
44
- * @param [countryCode] - ISO 3166 alpha-2 country code (e.g. "FR")
45
- * @param [geoid] - optional string or numeric geographic ID
46
- * @param [elevation] - in meters (default `0`)
47
- */
48
- constructor(latitude: number, longitude: number, il: boolean, tzid: string, cityName?: string, countryCode?: string, geoid?: string | number, elevation?: number);
49
- /**
50
- * Returns `true` if this location is in Israel (uses the Israeli holiday
51
- * and Torah-reading schedule), `false` for the Diaspora.
52
- */
53
- getIsrael(): boolean;
54
- /**
55
- * Returns the full descriptive location name passed to the constructor,
56
- * or `null` if no name was provided.
57
- * @example
58
- * Location.lookup('San Francisco')?.getName(); // 'San Francisco, California, USA'
59
- */
60
- getName(): string | null;
61
- /**
62
- * Returns the location name truncated at the first comma. Useful for
63
- * compact display where only the city name is desired.
64
- *
65
- * Special-cased so that US locations of the form `"Washington, DC"` or
66
- * `"Washington, D.C., ..."` keep the `DC` / `D.C.` suffix attached.
67
- * @example
68
- * Location.lookup('San Francisco')?.getShortName(); // 'San Francisco'
69
- * Location.lookup('Washington DC')?.getShortName(); // 'Washington, DC'
70
- */
71
- getShortName(): string | null;
72
- /**
73
- * Returns the ISO 3166 alpha-2 country code (e.g. `"US"`, `"IL"`, `"FR"`)
74
- * passed to the constructor, or `undefined` if none was provided.
75
- */
76
- getCountryCode(): string | undefined;
77
- /**
78
- * Returns the Olson timezone identifier (e.g. `"America/Chicago"`).
79
- * Alias for `getTimeZone()` from the parent `GeoLocation` class.
80
- */
81
- getTzid(): string;
82
- /**
83
- * Returns a cached 24-hour `Intl.DateTimeFormat` (e.g. `07:41` or `20:03`)
84
- * configured for this location's timezone. Formatters are memoized by
85
- * timezone so repeated calls do not allocate.
86
- * @example
87
- * const loc = Location.lookup('Tel Aviv')!;
88
- * const fmt = loc.getTimeFormatter();
89
- * fmt.format(new Date()); // e.g. '18:42'
90
- */
91
- getTimeFormatter(): Intl.DateTimeFormat;
92
- /**
93
- * Returns the optional geographic identifier passed to the constructor
94
- * (typically a GeoNames numeric ID or a US Zip Code string), or
95
- * `undefined` if none was provided.
96
- */
97
- getGeoId(): string | number | undefined;
98
- /**
99
- * Creates a location object from one of 60 "classic" Hebcal city names.
100
- * The following city names are supported:
101
- * 'Ashdod', 'Atlanta', 'Austin', 'Baghdad', 'Beer Sheva',
102
- * 'Berlin', 'Baltimore', 'Bogota', 'Boston', 'Budapest',
103
- * 'Buenos Aires', 'Buffalo', 'Chicago', 'Cincinnati', 'Cleveland',
104
- * 'Dallas', 'Denver', 'Detroit', 'Eilat', 'Gibraltar', 'Haifa',
105
- * 'Hawaii', 'Helsinki', 'Houston', 'Jerusalem', 'Johannesburg',
106
- * 'Kiev', 'La Paz', 'Livingston', 'Las Vegas', 'London', 'Los Angeles',
107
- * 'Marseilles', 'Miami', 'Minneapolis', 'Melbourne', 'Mexico City',
108
- * 'Montreal', 'Moscow', 'New York', 'Omaha', 'Ottawa', 'Panama City',
109
- * 'Paris', 'Pawtucket', 'Petach Tikvah', 'Philadelphia', 'Phoenix',
110
- * 'Pittsburgh', 'Providence', 'Portland', 'Saint Louis', 'Saint Petersburg',
111
- * 'San Diego', 'San Francisco', 'Sao Paulo', 'Seattle', 'Sydney',
112
- * 'Tel Aviv', 'Tiberias', 'Toronto', 'Vancouver', 'White Plains',
113
- * 'Washington DC', 'Worcester'
114
- *
115
- * Lookups are case-insensitive. Returns `undefined` if the name is not
116
- * recognized. The list can be extended with {@link Location.addLocation}.
117
- * @example
118
- * const loc = Location.lookup('San Francisco');
119
- * console.log(loc?.getTzid()); // 'America/Los_Angeles'
120
- * @param name case-insensitive classic city name
121
- */
122
- static lookup(name: string): Location | undefined;
123
- /**
124
- * Returns a JSON-serialized representation of this Location.
125
- * Useful for debugging and structured logging.
126
- */
127
- toString(): string;
128
- /**
129
- * Converts a legacy Hebcal-style timezone (a numeric GMT offset plus a
130
- * coarse DST region) to a standard IANA/Olson timezone ID.
131
- *
132
- * This exists to migrate data from older Hebcal versions that stored
133
- * timezones as GMT offset + DST scheme rather than as a full tzid.
134
- * @example
135
- * Location.legacyTzToTzid(2, 'israel'); // 'Asia/Jerusalem'
136
- * Location.legacyTzToTzid(0, 'eu'); // 'Europe/London'
137
- * Location.legacyTzToTzid(0, 'none'); // 'UTC'
138
- * Location.legacyTzToTzid(-5, 'none'); // 'Etc/GMT-5'
139
- * @param tz integer, GMT offset in hours
140
- * @param dst 'none', 'eu', 'usa', or 'israel'
141
- */
142
- static legacyTzToTzid(tz: number, dst: string): string | undefined;
143
- /**
144
- * Converts timezone info from Zip-Codes.com to a standard Olson tzid.
145
- * @example
146
- * Location.getUsaTzid('AZ', 7, 'Y') // 'America/Denver'
147
- * @param state two-letter all-caps US state abbreviation like 'CA'
148
- * @param tz positive number, 5=America/New_York, 8=America/Los_Angeles
149
- * @param dst single char 'Y' or 'N'
150
- */
151
- static getUsaTzid(state: string, tz: number, dst: string): string;
152
- /**
153
- * Registers a new named location with the built-in `Location.lookup()`
154
- * registry. Names are stored case-insensitively. Returns `false` if a
155
- * location with the same (lower-cased) name is already registered, and
156
- * `true` if successfully added.
157
- *
158
- * Use this to extend the built-in set of ~60 classic Hebcal cities with
159
- * your own custom locations.
160
- * @example
161
- * const tlv = new Location(32.0853, 34.7818, true,
162
- * 'Asia/Tel_Aviv', 'My Office, Tel Aviv', 'IL');
163
- * Location.addLocation('My Office', tlv); // true
164
- * Location.lookup('my office')?.getTzid(); // 'Asia/Tel_Aviv'
165
- */
166
- static addLocation(cityName: string, location: Location): boolean;
167
- }
@@ -1,342 +0,0 @@
1
- /*
2
- Hebcal - A Jewish Calendar Generator
3
- Copyright (c) 1994-2020 Danny Sadinoff
4
- Portions copyright Eyal Schachter and Michael J. Radwin
5
-
6
- https://github.com/hebcal/hebcal-es6
7
-
8
- This program is free software; you can redistribute it and/or
9
- modify it under the terms of the GNU General Public License
10
- as published by the Free Software Foundation; either version 2
11
- of the License, or (at your option) any later version.
12
-
13
- This program is distributed in the hope that it will be useful,
14
- but WITHOUT ANY WARRANTY; without even the implied warranty of
15
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
- GNU General Public License for more details.
17
-
18
- You should have received a copy of the GNU General Public License
19
- along with this program. If not, see <http://www.gnu.org/licenses/>.
20
- */
21
- import { GeoLocation } from '@hebcal/noaa';
22
- import citiesJson from './cities.json';
23
- import QuickLRU from 'quick-lru';
24
- const classicCities = new Map();
25
- // Zip-Codes.com TimeZone IDs
26
- const ZIPCODES_TZ_MAP = {
27
- '0': 'UTC',
28
- '4': 'America/Puerto_Rico', // Atlantic (GMT -04:00)
29
- '5': 'America/New_York', // Eastern (GMT -05:00)
30
- '6': 'America/Chicago', // Central (GMT -06:00)
31
- '7': 'America/Denver', // Mountain (GMT -07:00)
32
- '8': 'America/Los_Angeles', // Pacific (GMT -08:00)
33
- '9': 'America/Anchorage', // Alaska (GMT -09:00)
34
- '10': 'Pacific/Honolulu', // Hawaii-Aleutian Islands (GMT -10:00)
35
- '11': 'Pacific/Pago_Pago', // American Samoa (GMT -11:00)
36
- '13': 'Pacific/Funafuti', // Marshall Islands (GMT +12:00)
37
- '14': 'Pacific/Guam', // Guam (GMT +10:00)
38
- '15': 'Pacific/Palau', // Palau (GMT +9:00)
39
- '16': 'Pacific/Chuuk', // Micronesia (GMT +11:00)
40
- };
41
- /** @private */
42
- const timeFormatCache = new QuickLRU({
43
- maxSize: 120,
44
- });
45
- /**
46
- * Gets a 24-hour time formatter (e.g. 07:41 or 20:03) from cache
47
- * or makes a new one if needed
48
- * @private
49
- */
50
- function getFormatter(tzid) {
51
- const fmt = timeFormatCache.get(tzid);
52
- if (fmt)
53
- return fmt;
54
- const f = new Intl.DateTimeFormat('en-US', {
55
- timeZone: tzid,
56
- hour: 'numeric',
57
- minute: 'numeric',
58
- hour12: false,
59
- });
60
- timeFormatCache.set(tzid, f);
61
- return f;
62
- }
63
- function initClassicCities() {
64
- for (const entry of citiesJson) {
65
- const [cityName, cc, lat, lng, tzid, elev] = entry.split('|');
66
- const location = new Location(+lat, +lng, cc === 'IL', tzid, cityName, cc, undefined, +elev);
67
- Location.addLocation(cityName, location);
68
- }
69
- }
70
- /**
71
- * Class representing a geographic location for use with candle-lighting,
72
- * havdalah, and zmanim calculations.
73
- *
74
- * Extends {@link GeoLocation} from `@hebcal/noaa` with Jewish-calendar
75
- * specific data: an Israel/Diaspora flag, ISO country code, and an optional
76
- * geographic identifier. Also provides {@link Location.lookup} for ~60
77
- * built-in "classic" Hebcal cities.
78
- *
79
- * @example
80
- * import {Location} from '@hebcal/core';
81
- *
82
- * // Create a location for a custom address
83
- * const loc = new Location(
84
- * 41.85003, // latitude
85
- * -87.65005, // longitude
86
- * false, // not in Israel
87
- * 'America/Chicago',
88
- * 'Chicago, Illinois, USA',
89
- * 'US'
90
- * );
91
- *
92
- * // Or look up a built-in classic city
93
- * const tlv = Location.lookup('Tel Aviv');
94
- */
95
- export class Location extends GeoLocation {
96
- il;
97
- cc;
98
- geoid;
99
- admin1;
100
- stateName;
101
- geo;
102
- zip;
103
- population;
104
- asciiname;
105
- /**
106
- * Initialize a Location instance
107
- * @param latitude - Latitude as a decimal, valid range -90 thru +90 (e.g. 41.85003)
108
- * @param longitude - Longitude as a decimal, valid range -180 thru +180 (e.g. -87.65005)
109
- * @param il - in Israel (true) or Diaspora (false)
110
- * @param tzid - Olson timezone ID, e.g. "America/Chicago"
111
- * @param [cityName] - optional descriptive city name
112
- * @param [countryCode] - ISO 3166 alpha-2 country code (e.g. "FR")
113
- * @param [geoid] - optional string or numeric geographic ID
114
- * @param [elevation] - in meters (default `0`)
115
- */
116
- constructor(latitude, longitude, il, tzid, cityName, countryCode, geoid, elevation) {
117
- const lat = typeof latitude === 'number' ? latitude : parseFloat(latitude);
118
- if (isNaN(lat) || lat < -90 || lat > 90) {
119
- throw new RangeError(`Latitude ${latitude} out of range [-90,90]`);
120
- }
121
- const long = typeof longitude === 'number' ? longitude : parseFloat(longitude);
122
- if (isNaN(long) || long < -180 || long > 180) {
123
- throw new RangeError(`Longitude ${longitude} out of range [-180,180]`);
124
- }
125
- if (!tzid) {
126
- throw new RangeError('Invalid timezone');
127
- }
128
- const elev = typeof elevation === 'number' && elevation > 0 ? elevation : 0;
129
- if (cityName && typeof cityName !== 'string') {
130
- cityName = String(cityName);
131
- }
132
- super(cityName || null, lat, long, elev, tzid);
133
- this.il = Boolean(il);
134
- this.cc = countryCode;
135
- this.geoid = geoid;
136
- }
137
- /**
138
- * Returns `true` if this location is in Israel (uses the Israeli holiday
139
- * and Torah-reading schedule), `false` for the Diaspora.
140
- */
141
- getIsrael() {
142
- return this.il;
143
- }
144
- /**
145
- * Returns the full descriptive location name passed to the constructor,
146
- * or `null` if no name was provided.
147
- * @example
148
- * Location.lookup('San Francisco')?.getName(); // 'San Francisco, California, USA'
149
- */
150
- getName() {
151
- return this.getLocationName();
152
- }
153
- /**
154
- * Returns the location name truncated at the first comma. Useful for
155
- * compact display where only the city name is desired.
156
- *
157
- * Special-cased so that US locations of the form `"Washington, DC"` or
158
- * `"Washington, D.C., ..."` keep the `DC` / `D.C.` suffix attached.
159
- * @example
160
- * Location.lookup('San Francisco')?.getShortName(); // 'San Francisco'
161
- * Location.lookup('Washington DC')?.getShortName(); // 'Washington, DC'
162
- */
163
- getShortName() {
164
- const name = this.getLocationName();
165
- if (!name)
166
- return name;
167
- const comma = name.indexOf(', ');
168
- if (comma === -1)
169
- return name;
170
- if (this.cc === 'US' && name[comma + 2] === 'D') {
171
- if (name[comma + 3] === 'C') {
172
- return name.substring(0, comma + 4);
173
- }
174
- else if (name[comma + 3] === '.' && name[comma + 4] === 'C') {
175
- return name.substring(0, comma + 6);
176
- }
177
- }
178
- return name.substring(0, comma);
179
- }
180
- /**
181
- * Returns the ISO 3166 alpha-2 country code (e.g. `"US"`, `"IL"`, `"FR"`)
182
- * passed to the constructor, or `undefined` if none was provided.
183
- */
184
- getCountryCode() {
185
- return this.cc;
186
- }
187
- /**
188
- * Returns the Olson timezone identifier (e.g. `"America/Chicago"`).
189
- * Alias for `getTimeZone()` from the parent `GeoLocation` class.
190
- */
191
- getTzid() {
192
- return this.getTimeZone();
193
- }
194
- /**
195
- * Returns a cached 24-hour `Intl.DateTimeFormat` (e.g. `07:41` or `20:03`)
196
- * configured for this location's timezone. Formatters are memoized by
197
- * timezone so repeated calls do not allocate.
198
- * @example
199
- * const loc = Location.lookup('Tel Aviv')!;
200
- * const fmt = loc.getTimeFormatter();
201
- * fmt.format(new Date()); // e.g. '18:42'
202
- */
203
- getTimeFormatter() {
204
- return getFormatter(this.getTimeZone());
205
- }
206
- /**
207
- * Returns the optional geographic identifier passed to the constructor
208
- * (typically a GeoNames numeric ID or a US Zip Code string), or
209
- * `undefined` if none was provided.
210
- */
211
- getGeoId() {
212
- return this.geoid;
213
- }
214
- /**
215
- * Creates a location object from one of 60 "classic" Hebcal city names.
216
- * The following city names are supported:
217
- * 'Ashdod', 'Atlanta', 'Austin', 'Baghdad', 'Beer Sheva',
218
- * 'Berlin', 'Baltimore', 'Bogota', 'Boston', 'Budapest',
219
- * 'Buenos Aires', 'Buffalo', 'Chicago', 'Cincinnati', 'Cleveland',
220
- * 'Dallas', 'Denver', 'Detroit', 'Eilat', 'Gibraltar', 'Haifa',
221
- * 'Hawaii', 'Helsinki', 'Houston', 'Jerusalem', 'Johannesburg',
222
- * 'Kiev', 'La Paz', 'Livingston', 'Las Vegas', 'London', 'Los Angeles',
223
- * 'Marseilles', 'Miami', 'Minneapolis', 'Melbourne', 'Mexico City',
224
- * 'Montreal', 'Moscow', 'New York', 'Omaha', 'Ottawa', 'Panama City',
225
- * 'Paris', 'Pawtucket', 'Petach Tikvah', 'Philadelphia', 'Phoenix',
226
- * 'Pittsburgh', 'Providence', 'Portland', 'Saint Louis', 'Saint Petersburg',
227
- * 'San Diego', 'San Francisco', 'Sao Paulo', 'Seattle', 'Sydney',
228
- * 'Tel Aviv', 'Tiberias', 'Toronto', 'Vancouver', 'White Plains',
229
- * 'Washington DC', 'Worcester'
230
- *
231
- * Lookups are case-insensitive. Returns `undefined` if the name is not
232
- * recognized. The list can be extended with {@link Location.addLocation}.
233
- * @example
234
- * const loc = Location.lookup('San Francisco');
235
- * console.log(loc?.getTzid()); // 'America/Los_Angeles'
236
- * @param name case-insensitive classic city name
237
- */
238
- static lookup(name) {
239
- if (classicCities.size === 0) {
240
- initClassicCities();
241
- }
242
- return classicCities.get(name.toLowerCase());
243
- }
244
- /**
245
- * Returns a JSON-serialized representation of this Location.
246
- * Useful for debugging and structured logging.
247
- */
248
- toString() {
249
- return JSON.stringify(this);
250
- }
251
- /**
252
- * Converts a legacy Hebcal-style timezone (a numeric GMT offset plus a
253
- * coarse DST region) to a standard IANA/Olson timezone ID.
254
- *
255
- * This exists to migrate data from older Hebcal versions that stored
256
- * timezones as GMT offset + DST scheme rather than as a full tzid.
257
- * @example
258
- * Location.legacyTzToTzid(2, 'israel'); // 'Asia/Jerusalem'
259
- * Location.legacyTzToTzid(0, 'eu'); // 'Europe/London'
260
- * Location.legacyTzToTzid(0, 'none'); // 'UTC'
261
- * Location.legacyTzToTzid(-5, 'none'); // 'Etc/GMT-5'
262
- * @param tz integer, GMT offset in hours
263
- * @param dst 'none', 'eu', 'usa', or 'israel'
264
- */
265
- static legacyTzToTzid(tz, dst) {
266
- tz = +tz;
267
- if (dst === 'none') {
268
- if (tz === 0) {
269
- return 'UTC';
270
- }
271
- else {
272
- const plus = tz > 0 ? '+' : '';
273
- return `Etc/GMT${plus}${tz}`;
274
- }
275
- }
276
- else if (tz === 2 && dst === 'israel') {
277
- return 'Asia/Jerusalem';
278
- }
279
- else if (dst === 'eu') {
280
- switch (tz) {
281
- case -2:
282
- return 'Atlantic/Cape_Verde';
283
- case -1:
284
- return 'Atlantic/Azores';
285
- case 0:
286
- return 'Europe/London';
287
- case 1:
288
- return 'Europe/Paris';
289
- case 2:
290
- return 'Europe/Athens';
291
- default:
292
- break;
293
- }
294
- }
295
- else if (dst === 'usa') {
296
- return ZIPCODES_TZ_MAP[String(tz * -1)];
297
- }
298
- return undefined;
299
- }
300
- /**
301
- * Converts timezone info from Zip-Codes.com to a standard Olson tzid.
302
- * @example
303
- * Location.getUsaTzid('AZ', 7, 'Y') // 'America/Denver'
304
- * @param state two-letter all-caps US state abbreviation like 'CA'
305
- * @param tz positive number, 5=America/New_York, 8=America/Los_Angeles
306
- * @param dst single char 'Y' or 'N'
307
- */
308
- static getUsaTzid(state, tz, dst) {
309
- tz = +tz;
310
- if (tz === 10 && state === 'AK') {
311
- return 'America/Adak';
312
- }
313
- else if (tz === 7 && state === 'AZ') {
314
- return dst === 'Y' ? 'America/Denver' : 'America/Phoenix';
315
- }
316
- else {
317
- return ZIPCODES_TZ_MAP[tz];
318
- }
319
- }
320
- /**
321
- * Registers a new named location with the built-in `Location.lookup()`
322
- * registry. Names are stored case-insensitively. Returns `false` if a
323
- * location with the same (lower-cased) name is already registered, and
324
- * `true` if successfully added.
325
- *
326
- * Use this to extend the built-in set of ~60 classic Hebcal cities with
327
- * your own custom locations.
328
- * @example
329
- * const tlv = new Location(32.0853, 34.7818, true,
330
- * 'Asia/Tel_Aviv', 'My Office, Tel Aviv', 'IL');
331
- * Location.addLocation('My Office', tlv); // true
332
- * Location.lookup('my office')?.getTzid(); // 'Asia/Tel_Aviv'
333
- */
334
- static addLocation(cityName, location) {
335
- const name = cityName.toLowerCase();
336
- if (classicCities.has(name)) {
337
- return false;
338
- }
339
- classicCities.set(name, location);
340
- return true;
341
- }
342
- }
@@ -1,18 +0,0 @@
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;
13
- /**
14
- * Yom HaAtzma'ut only celebrated after 1948
15
- * @private
16
- * @param year
17
- */
18
- export declare function dateYomHaZikaron(year: number): HDate | null;
@@ -1,59 +0,0 @@
1
- import { HDate, months } from '@hebcal/hdate';
2
- const SUN = 0;
3
- const TUE = 2;
4
- const FRI = 5;
5
- const SAT = 6;
6
- const NISAN = months.NISAN;
7
- const IYYAR = months.IYYAR;
8
- /**
9
- * Yom HaShoah first observed in 1951.
10
- * When the actual date of Yom Hashoah falls on a Friday, the
11
- * state of Israel observes Yom Hashoah on the preceding
12
- * Thursday. When it falls on a Sunday, Yom Hashoah is observed
13
- * on the following Monday.
14
- * http://www.ushmm.org/remembrance/dor/calendar/
15
- * @private
16
- * @param year
17
- */
18
- export function dateYomHaShoah(year) {
19
- if (year < 5711) {
20
- return null;
21
- }
22
- let nisan27dt = new HDate(27, NISAN, year);
23
- if (nisan27dt.getDay() === FRI) {
24
- nisan27dt = new HDate(26, NISAN, year);
25
- }
26
- else if (nisan27dt.getDay() === SUN) {
27
- nisan27dt = new HDate(28, NISAN, year);
28
- }
29
- return nisan27dt;
30
- }
31
- /**
32
- * Yom HaAtzma'ut only celebrated after 1948
33
- * @private
34
- * @param year
35
- */
36
- export function dateYomHaZikaron(year) {
37
- if (year < 5708) {
38
- return null;
39
- }
40
- let day;
41
- const pesach = new HDate(15, NISAN, year);
42
- const pdow = pesach.getDay();
43
- if (pdow === SUN) {
44
- day = 2;
45
- }
46
- else if (pdow === SAT) {
47
- day = 3;
48
- }
49
- else if (year < 5764) {
50
- day = 4;
51
- }
52
- else if (pdow === TUE) {
53
- day = 5;
54
- }
55
- else {
56
- day = 4;
57
- }
58
- return new HDate(day, IYYAR, year);
59
- }