@hebcal/core 6.8.1 → 6.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +262 -4
- package/dist/bundle.js +1401 -943
- package/dist/bundle.js.map +1 -1
- package/dist/bundle.min.js +18 -17
- package/dist/bundle.min.js.map +1 -1
- package/dist/esm/CalOptions.d.ts +11 -1
- package/dist/esm/DailyLearning.d.ts +4 -4
- package/dist/esm/DailyLearning.js +5 -5
- package/dist/esm/DailyLearning.js.map +1 -1
- package/dist/esm/HebrewDateEvent.js +1 -1
- package/dist/esm/HolidayEvent.d.ts +7 -2
- package/dist/esm/HolidayEvent.js +8 -3
- package/dist/esm/HolidayEvent.js.map +1 -1
- package/dist/esm/MevarchimChodeshEvent.d.ts +2 -1
- package/dist/esm/MevarchimChodeshEvent.js +3 -2
- package/dist/esm/MevarchimChodeshEvent.js.map +1 -1
- package/dist/esm/ParshaEvent.d.ts +13 -0
- package/dist/esm/ParshaEvent.js +14 -1
- package/dist/esm/ParshaEvent.js.map +1 -1
- package/dist/esm/TimedEvent.d.ts +12 -4
- package/dist/esm/TimedEvent.js +13 -5
- package/dist/esm/TimedEvent.js.map +1 -1
- package/dist/esm/YomKippurKatanEvent.d.ts +2 -1
- package/dist/esm/YomKippurKatanEvent.js +3 -2
- package/dist/esm/YomKippurKatanEvent.js.map +1 -1
- package/dist/esm/ashkenazi.po.js +1 -1
- package/dist/esm/calendar.d.ts +17 -7
- package/dist/esm/calendar.js +23 -10
- package/dist/esm/calendar.js.map +1 -1
- package/dist/esm/candles.d.ts +19 -1
- package/dist/esm/candles.js +20 -2
- package/dist/esm/candles.js.map +1 -1
- package/dist/esm/cities.json.js +1 -1
- package/dist/esm/event.d.ts +2 -4
- package/dist/esm/event.js +3 -5
- package/dist/esm/event.js.map +1 -1
- package/dist/esm/getStartAndEnd.js +1 -1
- package/dist/esm/hallel.js +1 -1
- package/dist/esm/he-x-NoNikud.po.js +1 -1
- package/dist/esm/he.po.js +2 -2
- package/dist/esm/he.po.js.map +1 -1
- package/dist/esm/hebcal.d.ts +31 -96
- package/dist/esm/hebcal.js +34 -107
- package/dist/esm/hebcal.js.map +1 -1
- package/dist/esm/holidays.d.ts +8 -1
- package/dist/esm/holidays.js +2 -2
- package/dist/esm/holidays.js.map +1 -1
- package/dist/esm/index.d.ts +3 -1
- package/dist/esm/index.js +3 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/isAssurBemlacha.js +6 -3
- package/dist/esm/isAssurBemlacha.js.map +1 -1
- package/dist/esm/isAveilut.js +1 -1
- package/dist/esm/isFastDay.d.ts +1 -1
- package/dist/esm/isFastDay.js +2 -2
- package/dist/esm/isFastDay.js.map +1 -1
- package/dist/esm/locale.js +1 -1
- package/dist/esm/location.d.ts +37 -9
- package/dist/esm/location.js +38 -10
- package/dist/esm/location.js.map +1 -1
- package/dist/esm/modern.js +1 -1
- package/dist/esm/molad.d.ts +26 -20
- package/dist/esm/molad.js +27 -21
- package/dist/esm/molad.js.map +1 -1
- package/dist/esm/moladBase.d.ts +11 -0
- package/dist/esm/moladBase.js +12 -1
- package/dist/esm/moladBase.js.map +1 -1
- package/dist/esm/moladDate.d.ts +10 -6
- package/dist/esm/moladDate.js +25 -18
- package/dist/esm/moladDate.js.map +1 -1
- package/dist/esm/omer.d.ts +19 -3
- package/dist/esm/omer.js +20 -4
- package/dist/esm/omer.js.map +1 -1
- package/dist/esm/parshaName.js +1 -1
- package/dist/esm/parshaYear.d.ts +2 -2
- package/dist/esm/parshaYear.js +3 -3
- package/dist/esm/parshaYear.js.map +1 -1
- package/dist/esm/pkgVersion.d.ts +1 -1
- package/dist/esm/pkgVersion.js +2 -2
- package/dist/esm/pkgVersion.js.map +1 -1
- package/dist/esm/reformatTimeStr.d.ts +14 -2
- package/dist/esm/reformatTimeStr.js +15 -3
- package/dist/esm/reformatTimeStr.js.map +1 -1
- package/dist/esm/sedra.d.ts +44 -18
- package/dist/esm/sedra.js +39 -17
- package/dist/esm/sedra.js.map +1 -1
- package/dist/esm/sefira.json.js +1 -1
- package/dist/esm/staticHolidays.d.ts +0 -2
- package/dist/esm/staticHolidays.js +1 -3
- package/dist/esm/staticHolidays.js.map +1 -1
- package/dist/esm/string.js +1 -1
- package/dist/esm/tachanun.js +1 -1
- package/dist/esm/zmanim.d.ts +177 -142
- package/dist/esm/zmanim.js +183 -148
- package/dist/esm/zmanim.js.map +1 -1
- package/package.json +9 -10
- package/po/he.po +4 -2
package/dist/esm/isFastDay.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! @hebcal/core v6.
|
|
1
|
+
/*! @hebcal/core v6.9.0, distributed under GPLv2 https://www.gnu.org/licenses/gpl-2.0.txt */
|
|
2
2
|
import { flags } from './event.js';
|
|
3
3
|
import { getHolidaysOnDate } from './holidays.js';
|
|
4
4
|
|
|
@@ -20,7 +20,7 @@ const EREV = flags.EREV;
|
|
|
20
20
|
* isFastDay(new HDate(10, months.TISHREI, 5784)); // true (Yom Kippur)
|
|
21
21
|
* isFastDay(new HDate(11, months.TISHREI, 5784)); // false
|
|
22
22
|
* @param date Hebrew Date, Gregorian date, or absolute R.D. day number
|
|
23
|
-
* @param il use the Israeli schedule for holidays
|
|
23
|
+
* @param il optional; use the Israeli schedule for holidays (default Diaspora)
|
|
24
24
|
* @return `true` if the date is a major or minor fast day
|
|
25
25
|
*/
|
|
26
26
|
function isFastDay(date, il) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"isFastDay.js","sources":["../../../src/isFastDay.ts"],"sourcesContent":["import {HDate} from '@hebcal/hdate';\nimport {flags} from './event';\nimport {getHolidaysOnDate} from './holidays';\n\nconst FAST_DAY = flags.MAJOR_FAST | flags.MINOR_FAST;\nconst EREV = flags.EREV;\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 use the Israeli schedule for holidays\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(ev => {\n const mask = ev.getFlags();\n return mask & FAST_DAY && !(mask & EREV);\n });\n return Boolean(fastDay);\n}\n"],"names":[],"mappings":";;;;AAIA,MAAM,QAAQ,GAAG,KAAK,CAAC,UAAU,GAAG,KAAK,CAAC,UAAU;AACpD,MAAM,IAAI,GAAG,KAAK,CAAC,IAAI;AAEvB;;;;;;;;;;;;;;;;;;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,CAAC,EAAE,IAAG;AAC/B,QAAA,MAAM,IAAI,GAAG,EAAE,CAAC,QAAQ,EAAE;QAC1B,OAAO,IAAI,GAAG,QAAQ,IAAI,EAAE,IAAI,GAAG,IAAI,CAAC;AAC1C,IAAA,CAAC,CAAC;AACF,IAAA,OAAO,OAAO,CAAC,OAAO,CAAC;AACzB;;;;"}
|
|
1
|
+
{"version":3,"file":"isFastDay.js","sources":["../../../src/isFastDay.ts"],"sourcesContent":["import {HDate} from '@hebcal/hdate';\nimport {flags} from './event';\nimport {getHolidaysOnDate} from './holidays';\n\nconst FAST_DAY = flags.MAJOR_FAST | flags.MINOR_FAST;\nconst EREV = flags.EREV;\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(ev => {\n const mask = ev.getFlags();\n return mask & FAST_DAY && !(mask & EREV);\n });\n return Boolean(fastDay);\n}\n"],"names":[],"mappings":";;;;AAIA,MAAM,QAAQ,GAAG,KAAK,CAAC,UAAU,GAAG,KAAK,CAAC,UAAU;AACpD,MAAM,IAAI,GAAG,KAAK,CAAC,IAAI;AAEvB;;;;;;;;;;;;;;;;;;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,CAAC,EAAE,IAAG;AAC/B,QAAA,MAAM,IAAI,GAAG,EAAE,CAAC,QAAQ,EAAE;QAC1B,OAAO,IAAI,GAAG,QAAQ,IAAI,EAAE,IAAI,GAAG,IAAI,CAAC;AAC1C,IAAA,CAAC,CAAC;AACF,IAAA,OAAO,OAAO,CAAC,OAAO,CAAC;AACzB;;;;"}
|
package/dist/esm/locale.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! @hebcal/core v6.
|
|
1
|
+
/*! @hebcal/core v6.9.0, 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';
|
package/dist/esm/location.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ import { GeoLocation } from '@hebcal/noaa';
|
|
|
5
5
|
*
|
|
6
6
|
* Extends {@link GeoLocation} from `@hebcal/noaa` with Jewish-calendar
|
|
7
7
|
* specific data: an Israel/Diaspora flag, ISO country code, and an optional
|
|
8
|
-
* geographic identifier. Also provides {@link Location.lookup} for
|
|
8
|
+
* geographic identifier. Also provides {@link Location.lookup} for the 65
|
|
9
9
|
* built-in "classic" Hebcal cities.
|
|
10
10
|
*
|
|
11
11
|
* @example
|
|
@@ -28,11 +28,27 @@ export declare class Location extends GeoLocation {
|
|
|
28
28
|
private readonly il;
|
|
29
29
|
private readonly cc?;
|
|
30
30
|
private readonly geoid?;
|
|
31
|
+
/**
|
|
32
|
+
* First-level administrative division (e.g. a US state or a French
|
|
33
|
+
* region) as an abbreviation, such as `"CA"`. Not set by this package;
|
|
34
|
+
* populated by callers that hydrate a `Location` from a geo database.
|
|
35
|
+
*/
|
|
31
36
|
admin1?: string;
|
|
37
|
+
/**
|
|
38
|
+
* Full name of the first-level administrative division, such as
|
|
39
|
+
* `"California"`. Not set by this package.
|
|
40
|
+
*/
|
|
32
41
|
stateName?: string;
|
|
42
|
+
/**
|
|
43
|
+
* Which kind of lookup produced this location: `'zip'` for a US Zip Code
|
|
44
|
+
* or `'geoname'` for a GeoNames city. Not set by this package.
|
|
45
|
+
*/
|
|
33
46
|
geo?: 'zip' | 'geoname';
|
|
47
|
+
/** US Zip Code, such as `"02912"`. Not set by this package. */
|
|
34
48
|
zip?: string;
|
|
49
|
+
/** Approximate population of the city. Not set by this package. */
|
|
35
50
|
population?: number;
|
|
51
|
+
/** City name in plain ASCII, for sorting or URL generation. Not set by this package. */
|
|
36
52
|
asciiname?: string;
|
|
37
53
|
/**
|
|
38
54
|
* Initialize a Location instance
|
|
@@ -54,19 +70,29 @@ export declare class Location extends GeoLocation {
|
|
|
54
70
|
/**
|
|
55
71
|
* Returns the full descriptive location name passed to the constructor,
|
|
56
72
|
* or `null` if no name was provided.
|
|
73
|
+
*
|
|
74
|
+
* Note that the built-in classic cities are named by city alone, so
|
|
75
|
+
* `getName()` and {@link getShortName} return the same string for them.
|
|
57
76
|
* @example
|
|
58
|
-
*
|
|
77
|
+
* const loc = new Location(41.85003, -87.65005, false,
|
|
78
|
+
* 'America/Chicago', 'Chicago, Illinois, USA', 'US');
|
|
79
|
+
* loc.getName(); // 'Chicago, Illinois, USA'
|
|
80
|
+
* Location.lookup('San Francisco')?.getName(); // 'San Francisco'
|
|
59
81
|
*/
|
|
60
82
|
getName(): string | null;
|
|
61
83
|
/**
|
|
62
84
|
* Returns the location name truncated at the first comma. Useful for
|
|
63
85
|
* compact display where only the city name is desired.
|
|
64
86
|
*
|
|
65
|
-
* Special-cased so that US locations of the form `"Washington, DC"` or
|
|
87
|
+
* Special-cased so that US locations of the form `"Washington, DC ..."` or
|
|
66
88
|
* `"Washington, D.C., ..."` keep the `DC` / `D.C.` suffix attached.
|
|
67
89
|
* @example
|
|
68
|
-
* Location.
|
|
69
|
-
*
|
|
90
|
+
* const chi = new Location(41.85003, -87.65005, false,
|
|
91
|
+
* 'America/Chicago', 'Chicago, Illinois, USA', 'US');
|
|
92
|
+
* chi.getShortName(); // 'Chicago'
|
|
93
|
+
* const dc = new Location(38.89511, -77.03637, false,
|
|
94
|
+
* 'America/New_York', 'Washington, D.C., USA', 'US');
|
|
95
|
+
* dc.getShortName(); // 'Washington, D.C.'
|
|
70
96
|
*/
|
|
71
97
|
getShortName(): string | null;
|
|
72
98
|
/**
|
|
@@ -96,7 +122,7 @@ export declare class Location extends GeoLocation {
|
|
|
96
122
|
*/
|
|
97
123
|
getGeoId(): string | number | undefined;
|
|
98
124
|
/**
|
|
99
|
-
* Creates a location object from one of
|
|
125
|
+
* Creates a location object from one of 65 "classic" Hebcal city names.
|
|
100
126
|
* The following city names are supported:
|
|
101
127
|
* 'Ashdod', 'Atlanta', 'Austin', 'Baghdad', 'Beer Sheva',
|
|
102
128
|
* 'Berlin', 'Baltimore', 'Bogota', 'Boston', 'Budapest',
|
|
@@ -155,13 +181,15 @@ export declare class Location extends GeoLocation {
|
|
|
155
181
|
* location with the same (lower-cased) name is already registered, and
|
|
156
182
|
* `true` if successfully added.
|
|
157
183
|
*
|
|
158
|
-
* Use this to extend the built-in set of
|
|
184
|
+
* Use this to extend the built-in set of 65 classic Hebcal cities with
|
|
159
185
|
* your own custom locations.
|
|
160
186
|
* @example
|
|
161
187
|
* const tlv = new Location(32.0853, 34.7818, true,
|
|
162
|
-
* 'Asia/
|
|
188
|
+
* 'Asia/Jerusalem', 'My Office, Tel Aviv', 'IL');
|
|
163
189
|
* Location.addLocation('My Office', tlv); // true
|
|
164
|
-
* Location.lookup('my office')?.getTzid(); // 'Asia/
|
|
190
|
+
* Location.lookup('my office')?.getTzid(); // 'Asia/Jerusalem'
|
|
191
|
+
* @param cityName name to register the location under (case insensitive)
|
|
192
|
+
* @param location the `Location` instance to register
|
|
165
193
|
*/
|
|
166
194
|
static addLocation(cityName: string, location: Location): boolean;
|
|
167
195
|
}
|
package/dist/esm/location.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! @hebcal/core v6.
|
|
1
|
+
/*! @hebcal/core v6.9.0, 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';
|
|
@@ -75,7 +75,7 @@ function initClassicCities() {
|
|
|
75
75
|
*
|
|
76
76
|
* Extends {@link GeoLocation} from `@hebcal/noaa` with Jewish-calendar
|
|
77
77
|
* specific data: an Israel/Diaspora flag, ISO country code, and an optional
|
|
78
|
-
* geographic identifier. Also provides {@link Location.lookup} for
|
|
78
|
+
* geographic identifier. Also provides {@link Location.lookup} for the 65
|
|
79
79
|
* built-in "classic" Hebcal cities.
|
|
80
80
|
*
|
|
81
81
|
* @example
|
|
@@ -98,11 +98,27 @@ class Location extends GeoLocation {
|
|
|
98
98
|
il;
|
|
99
99
|
cc;
|
|
100
100
|
geoid;
|
|
101
|
+
/**
|
|
102
|
+
* First-level administrative division (e.g. a US state or a French
|
|
103
|
+
* region) as an abbreviation, such as `"CA"`. Not set by this package;
|
|
104
|
+
* populated by callers that hydrate a `Location` from a geo database.
|
|
105
|
+
*/
|
|
101
106
|
admin1;
|
|
107
|
+
/**
|
|
108
|
+
* Full name of the first-level administrative division, such as
|
|
109
|
+
* `"California"`. Not set by this package.
|
|
110
|
+
*/
|
|
102
111
|
stateName;
|
|
112
|
+
/**
|
|
113
|
+
* Which kind of lookup produced this location: `'zip'` for a US Zip Code
|
|
114
|
+
* or `'geoname'` for a GeoNames city. Not set by this package.
|
|
115
|
+
*/
|
|
103
116
|
geo;
|
|
117
|
+
/** US Zip Code, such as `"02912"`. Not set by this package. */
|
|
104
118
|
zip;
|
|
119
|
+
/** Approximate population of the city. Not set by this package. */
|
|
105
120
|
population;
|
|
121
|
+
/** City name in plain ASCII, for sorting or URL generation. Not set by this package. */
|
|
106
122
|
asciiname;
|
|
107
123
|
/**
|
|
108
124
|
* Initialize a Location instance
|
|
@@ -149,8 +165,14 @@ class Location extends GeoLocation {
|
|
|
149
165
|
/**
|
|
150
166
|
* Returns the full descriptive location name passed to the constructor,
|
|
151
167
|
* or `null` if no name was provided.
|
|
168
|
+
*
|
|
169
|
+
* Note that the built-in classic cities are named by city alone, so
|
|
170
|
+
* `getName()` and {@link getShortName} return the same string for them.
|
|
152
171
|
* @example
|
|
153
|
-
*
|
|
172
|
+
* const loc = new Location(41.85003, -87.65005, false,
|
|
173
|
+
* 'America/Chicago', 'Chicago, Illinois, USA', 'US');
|
|
174
|
+
* loc.getName(); // 'Chicago, Illinois, USA'
|
|
175
|
+
* Location.lookup('San Francisco')?.getName(); // 'San Francisco'
|
|
154
176
|
*/
|
|
155
177
|
getName() {
|
|
156
178
|
return this.getLocationName();
|
|
@@ -159,11 +181,15 @@ class Location extends GeoLocation {
|
|
|
159
181
|
* Returns the location name truncated at the first comma. Useful for
|
|
160
182
|
* compact display where only the city name is desired.
|
|
161
183
|
*
|
|
162
|
-
* Special-cased so that US locations of the form `"Washington, DC"` or
|
|
184
|
+
* Special-cased so that US locations of the form `"Washington, DC ..."` or
|
|
163
185
|
* `"Washington, D.C., ..."` keep the `DC` / `D.C.` suffix attached.
|
|
164
186
|
* @example
|
|
165
|
-
* Location.
|
|
166
|
-
*
|
|
187
|
+
* const chi = new Location(41.85003, -87.65005, false,
|
|
188
|
+
* 'America/Chicago', 'Chicago, Illinois, USA', 'US');
|
|
189
|
+
* chi.getShortName(); // 'Chicago'
|
|
190
|
+
* const dc = new Location(38.89511, -77.03637, false,
|
|
191
|
+
* 'America/New_York', 'Washington, D.C., USA', 'US');
|
|
192
|
+
* dc.getShortName(); // 'Washington, D.C.'
|
|
167
193
|
*/
|
|
168
194
|
getShortName() {
|
|
169
195
|
const name = this.getLocationName();
|
|
@@ -217,7 +243,7 @@ class Location extends GeoLocation {
|
|
|
217
243
|
return this.geoid;
|
|
218
244
|
}
|
|
219
245
|
/**
|
|
220
|
-
* Creates a location object from one of
|
|
246
|
+
* Creates a location object from one of 65 "classic" Hebcal city names.
|
|
221
247
|
* The following city names are supported:
|
|
222
248
|
* 'Ashdod', 'Atlanta', 'Austin', 'Baghdad', 'Beer Sheva',
|
|
223
249
|
* 'Berlin', 'Baltimore', 'Bogota', 'Boston', 'Budapest',
|
|
@@ -322,13 +348,15 @@ class Location extends GeoLocation {
|
|
|
322
348
|
* location with the same (lower-cased) name is already registered, and
|
|
323
349
|
* `true` if successfully added.
|
|
324
350
|
*
|
|
325
|
-
* Use this to extend the built-in set of
|
|
351
|
+
* Use this to extend the built-in set of 65 classic Hebcal cities with
|
|
326
352
|
* your own custom locations.
|
|
327
353
|
* @example
|
|
328
354
|
* const tlv = new Location(32.0853, 34.7818, true,
|
|
329
|
-
* 'Asia/
|
|
355
|
+
* 'Asia/Jerusalem', 'My Office, Tel Aviv', 'IL');
|
|
330
356
|
* Location.addLocation('My Office', tlv); // true
|
|
331
|
-
* Location.lookup('my office')?.getTzid(); // 'Asia/
|
|
357
|
+
* Location.lookup('my office')?.getTzid(); // 'Asia/Jerusalem'
|
|
358
|
+
* @param cityName name to register the location under (case insensitive)
|
|
359
|
+
* @param location the `Location` instance to register
|
|
332
360
|
*/
|
|
333
361
|
static addLocation(cityName, location) {
|
|
334
362
|
const name = cityName.toLowerCase();
|
package/dist/esm/location.js.map
CHANGED
|
@@ -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';\nimport QuickLRU from 'quick-lru';\n\nconst classicCities = new Map<string, Location>();\n\n// Zip-Codes.com TimeZone IDs\nconst ZIPCODES_TZ_MAP: Record<string, string> = {\n '0': 'UTC',\n '4': 'America/Puerto_Rico', // Atlantic (GMT -04:00)\n '5': 'America/New_York', // Eastern (GMT -05:00)\n '6': 'America/Chicago', // Central (GMT -06:00)\n '7': 'America/Denver', // Mountain (GMT -07:00)\n '8': 'America/Los_Angeles', // Pacific (GMT -08:00)\n '9': 'America/Anchorage', // Alaska (GMT -09:00)\n '10': 'Pacific/Honolulu', // Hawaii-Aleutian Islands (GMT -10:00)\n '11': 'Pacific/Pago_Pago', // American Samoa (GMT -11:00)\n '13': 'Pacific/Funafuti', // Marshall Islands (GMT +12:00)\n '14': 'Pacific/Guam', // Guam (GMT +10:00)\n '15': 'Pacific/Palau', // Palau (GMT +9:00)\n '16': 'Pacific/Chuuk', // Micronesia (GMT +11:00)\n} as const;\n\n/** @private */\nconst timeFormatCache = new QuickLRU<string, Intl.DateTimeFormat>({\n maxSize: 120,\n});\n\n/**\n * Gets a 24-hour time formatter (e.g. 07:41 or 20:03) from cache\n * or makes a new one if needed\n * @private\n */\nfunction getFormatter(tzid: string): Intl.DateTimeFormat {\n const fmt = timeFormatCache.get(tzid);\n if (fmt) return fmt;\n const f = new Intl.DateTimeFormat('en-US', {\n timeZone: tzid,\n hour: 'numeric',\n minute: 'numeric',\n hour12: false,\n });\n timeFormatCache.set(tzid, f);\n return f;\n}\n\nfunction initClassicCities() {\n for (const entry of citiesJson) {\n const [cityName, cc, lat, lng, tzid, elev] = entry.split('|');\n const location = new Location(\n +lat,\n +lng,\n cc === 'IL',\n tzid,\n cityName,\n cc,\n undefined,\n +elev\n );\n Location.addLocation(cityName, location);\n }\n}\n\n/**\n * Class representing a geographic location for use with candle-lighting,\n * havdalah, and zmanim calculations.\n *\n * Extends {@link GeoLocation} from `@hebcal/noaa` with Jewish-calendar\n * specific data: an Israel/Diaspora flag, ISO country code, and an optional\n * geographic identifier. Also provides {@link Location.lookup} for ~60\n * built-in \"classic\" Hebcal cities.\n *\n * @example\n * import {Location} from '@hebcal/core';\n *\n * // Create a location for a custom address\n * const loc = new Location(\n * 41.85003, // latitude\n * -87.65005, // longitude\n * false, // not in Israel\n * 'America/Chicago',\n * 'Chicago, Illinois, USA',\n * 'US'\n * );\n *\n * // Or look up a built-in classic city\n * const tlv = Location.lookup('Tel Aviv');\n */\nexport class Location extends GeoLocation {\n private readonly il: boolean;\n private readonly cc?: string;\n private readonly geoid?: string | number;\n admin1?: string;\n stateName?: string;\n geo?: 'zip' | 'geoname';\n zip?: string;\n population?: number;\n asciiname?: string;\n\n /**\n * Initialize a Location instance\n * @param latitude - Latitude as a decimal, valid range -90 thru +90 (e.g. 41.85003)\n * @param longitude - Longitude as a decimal, valid range -180 thru +180 (e.g. -87.65005)\n * @param il - in Israel (true) or Diaspora (false)\n * @param tzid - Olson timezone ID, e.g. \"America/Chicago\"\n * @param [cityName] - optional descriptive city name\n * @param [countryCode] - ISO 3166 alpha-2 country code (e.g. \"FR\")\n * @param [geoid] - optional string or numeric geographic ID\n * @param [elevation] - in meters (default `0`)\n */\n constructor(\n latitude: number,\n longitude: number,\n il: boolean,\n tzid: string,\n cityName?: string,\n countryCode?: string,\n geoid?: string | number,\n elevation?: number\n ) {\n const lat = typeof latitude === 'number' ? latitude : parseFloat(latitude);\n if (isNaN(lat) || lat < -90 || lat > 90) {\n throw new RangeError(`Latitude ${latitude} out of range [-90,90]`);\n }\n const long = 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 * @example\n * Location.lookup('San Francisco')?.getName(); // 'San Francisco, California, USA'\n */\n getName(): string | null {\n return this.getLocationName();\n }\n\n /**\n * Returns the location name truncated at the first comma. Useful for\n * compact display where only the city name is desired.\n *\n * Special-cased so that US locations of the form `\"Washington, DC\"` or\n * `\"Washington, D.C., ...\"` keep the `DC` / `D.C.` suffix attached.\n * @example\n * Location.lookup('San Francisco')?.getShortName(); // 'San Francisco'\n * Location.lookup('Washington DC')?.getShortName(); // 'Washington, DC'\n */\n getShortName(): string | null {\n const name = this.getLocationName();\n if (!name) return name;\n const comma = name.indexOf(', ');\n if (comma === -1) return name;\n if (this.cc === 'US' && name[comma + 2] === 'D') {\n if (name[comma + 3] === 'C') {\n return name.substring(0, comma + 4);\n }\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 60 \"classic\" Hebcal city names.\n * The following city names are supported:\n * 'Ashdod', 'Atlanta', 'Austin', 'Baghdad', 'Beer Sheva',\n * 'Berlin', 'Baltimore', 'Bogota', 'Boston', 'Budapest',\n * 'Buenos Aires', 'Buffalo', 'Chicago', 'Cincinnati', 'Cleveland',\n * 'Dallas', 'Denver', 'Detroit', 'Eilat', 'Gibraltar', 'Haifa',\n * 'Hawaii', 'Helsinki', 'Houston', 'Jerusalem', 'Johannesburg',\n * 'Kiev', 'La Paz', 'Livingston', 'Las Vegas', 'London', 'Los Angeles',\n * 'Marseilles', 'Miami', 'Minneapolis', 'Melbourne', 'Mexico City',\n * 'Montreal', 'Moscow', 'New York', 'Omaha', 'Ottawa', 'Panama City',\n * 'Paris', 'Pawtucket', 'Petach Tikvah', 'Philadelphia', 'Phoenix',\n * 'Pittsburgh', 'Providence', 'Portland', 'Saint Louis', 'Saint Petersburg',\n * 'San Diego', 'San Francisco', 'Sao Paulo', 'Seattle', 'Sydney',\n * 'Tel Aviv', 'Tiberias', 'Toronto', 'Vancouver', 'White Plains',\n * 'Washington DC', 'Worcester'\n *\n * Lookups are case-insensitive. Returns `undefined` if the name is not\n * recognized. The list can be extended with {@link Location.addLocation}.\n * @example\n * const loc = Location.lookup('San Francisco');\n * console.log(loc?.getTzid()); // 'America/Los_Angeles'\n * @param name case-insensitive classic city name\n */\n static lookup(name: string): Location | undefined {\n if (classicCities.size === 0) {\n initClassicCities();\n }\n return classicCities.get(name.toLowerCase());\n }\n\n /**\n * Returns a JSON-serialized representation of this Location.\n * Useful for debugging and structured logging.\n */\n toString(): string {\n return JSON.stringify(this);\n }\n\n /**\n * Converts a legacy Hebcal-style timezone (a numeric GMT offset plus a\n * coarse DST region) to a standard IANA/Olson timezone ID.\n *\n * This exists to migrate data from older Hebcal versions that stored\n * timezones as GMT offset + DST scheme rather than as a full tzid.\n * @example\n * Location.legacyTzToTzid(2, 'israel'); // 'Asia/Jerusalem'\n * Location.legacyTzToTzid(0, 'eu'); // 'Europe/London'\n * Location.legacyTzToTzid(0, 'none'); // 'UTC'\n * Location.legacyTzToTzid(-5, 'none'); // 'Etc/GMT-5'\n * @param tz integer, GMT offset in hours\n * @param dst 'none', 'eu', 'usa', or 'israel'\n */\n static legacyTzToTzid(tz: number, dst: string): string | undefined {\n tz = +tz;\n if (dst === 'none') {\n if (tz === 0) {\n return 'UTC';\n }\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 ~60 classic Hebcal cities with\n * your own custom locations.\n * @example\n * const tlv = new Location(32.0853, 34.7818, true,\n * 'Asia/Tel_Aviv', 'My Office, Tel Aviv', 'IL');\n * Location.addLocation('My Office', tlv); // true\n * Location.lookup('my office')?.getTzid(); // 'Asia/Tel_Aviv'\n */\n static addLocation(cityName: string, location: Location): boolean {\n const name = cityName.toLowerCase();\n if (classicCities.has(name)) {\n return false;\n }\n classicCities.set(name, location);\n return true;\n }\n}\n"],"names":[],"mappings":";;;;;AAAA;;;;;;;;;;;;;;;;;;;AAmBG;AAKH,MAAM,aAAa,GAAG,IAAI,GAAG,EAAoB;AAEjD;AACA,MAAM,eAAe,GAA2B;AAC9C,IAAA,GAAG,EAAE,KAAK;IACV,GAAG,EAAE,qBAAqB;IAC1B,GAAG,EAAE,kBAAkB;IACvB,GAAG,EAAE,iBAAiB;IACtB,GAAG,EAAE,gBAAgB;IACrB,GAAG,EAAE,qBAAqB;IAC1B,GAAG,EAAE,mBAAmB;IACxB,IAAI,EAAE,kBAAkB;IACxB,IAAI,EAAE,mBAAmB;IACzB,IAAI,EAAE,kBAAkB;IACxB,IAAI,EAAE,cAAc;IACpB,IAAI,EAAE,eAAe;IACrB,IAAI,EAAE,eAAe;CACb;AAEV;AACA,MAAM,eAAe,GAAG,IAAI,QAAQ,CAA8B;AAChE,IAAA,OAAO,EAAE,GAAG;AACb,CAAA,CAAC;AAEF;;;;AAIG;AACH,SAAS,YAAY,CAAC,IAAY,EAAA;IAChC,MAAM,GAAG,GAAG,eAAe,CAAC,GAAG,CAAC,IAAI,CAAC;AACrC,IAAA,IAAI,GAAG;AAAE,QAAA,OAAO,GAAG;IACnB,MAAM,CAAC,GAAG,IAAI,IAAI,CAAC,cAAc,CAAC,OAAO,EAAE;AACzC,QAAA,QAAQ,EAAE,IAAI;AACd,QAAA,IAAI,EAAE,SAAS;AACf,QAAA,MAAM,EAAE,SAAS;AACjB,QAAA,MAAM,EAAE,KAAK;AACd,KAAA,CAAC;AACF,IAAA,eAAe,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC,CAAC;AAC5B,IAAA,OAAO,CAAC;AAC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;AAEA;;;;;;;;;;;;;AAaG;AACH,IAAA,OAAO,WAAW,CAAC,QAAgB,EAAE,QAAkB,EAAA;AACrD,QAAA,MAAM,IAAI,GAAG,QAAQ,CAAC,WAAW,EAAE;AACnC,QAAA,IAAI,aAAa,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE;AAC3B,YAAA,OAAO,KAAK;QACd;AACA,QAAA,aAAa,CAAC,GAAG,CAAC,IAAI,EAAE,QAAQ,CAAC;AACjC,QAAA,OAAO,IAAI;IACb;AACD;;;;"}
|
|
1
|
+
{"version":3,"file":"location.js","sources":["../../../src/location.ts"],"sourcesContent":["/*\n Hebcal - A Jewish Calendar Generator\n Copyright (c) 1994-2020 Danny Sadinoff\n Portions copyright Eyal Schachter and Michael J. Radwin\n\n https://github.com/hebcal/hebcal-es6\n\n This program is free software; you can redistribute it and/or\n modify it under the terms of the GNU General Public License\n as published by the Free Software Foundation; either version 2\n of the License, or (at your option) any later version.\n\n This program is distributed in the hope that it will be useful,\n but WITHOUT ANY WARRANTY; without even the implied warranty of\n MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n GNU General Public License for more details.\n\n You should have received a copy of the GNU General Public License\n along with this program. If not, see <http://www.gnu.org/licenses/>.\n */\nimport {GeoLocation} from '@hebcal/noaa';\nimport citiesJson from './cities.json';\nimport QuickLRU from 'quick-lru';\n\nconst classicCities = new Map<string, Location>();\n\n// Zip-Codes.com TimeZone IDs\nconst ZIPCODES_TZ_MAP: Record<string, string> = {\n '0': 'UTC',\n '4': 'America/Puerto_Rico', // Atlantic (GMT -04:00)\n '5': 'America/New_York', // Eastern (GMT -05:00)\n '6': 'America/Chicago', // Central (GMT -06:00)\n '7': 'America/Denver', // Mountain (GMT -07:00)\n '8': 'America/Los_Angeles', // Pacific (GMT -08:00)\n '9': 'America/Anchorage', // Alaska (GMT -09:00)\n '10': 'Pacific/Honolulu', // Hawaii-Aleutian Islands (GMT -10:00)\n '11': 'Pacific/Pago_Pago', // American Samoa (GMT -11:00)\n '13': 'Pacific/Funafuti', // Marshall Islands (GMT +12:00)\n '14': 'Pacific/Guam', // Guam (GMT +10:00)\n '15': 'Pacific/Palau', // Palau (GMT +9:00)\n '16': 'Pacific/Chuuk', // Micronesia (GMT +11:00)\n} as const;\n\n/** @private */\nconst timeFormatCache = new QuickLRU<string, Intl.DateTimeFormat>({\n maxSize: 120,\n});\n\n/**\n * Gets a 24-hour time formatter (e.g. 07:41 or 20:03) from cache\n * or makes a new one if needed\n * @private\n */\nfunction getFormatter(tzid: string): Intl.DateTimeFormat {\n const fmt = timeFormatCache.get(tzid);\n if (fmt) return fmt;\n const f = new Intl.DateTimeFormat('en-US', {\n timeZone: tzid,\n hour: 'numeric',\n minute: 'numeric',\n hour12: false,\n });\n timeFormatCache.set(tzid, f);\n return f;\n}\n\nfunction initClassicCities() {\n for (const entry of citiesJson) {\n const [cityName, cc, lat, lng, tzid, elev] = entry.split('|');\n const location = new Location(\n +lat,\n +lng,\n cc === 'IL',\n tzid,\n cityName,\n cc,\n undefined,\n +elev\n );\n Location.addLocation(cityName, location);\n }\n}\n\n/**\n * Class representing a geographic location for use with candle-lighting,\n * havdalah, and zmanim calculations.\n *\n * Extends {@link GeoLocation} from `@hebcal/noaa` with Jewish-calendar\n * specific data: an Israel/Diaspora flag, ISO country code, and an optional\n * geographic identifier. Also provides {@link Location.lookup} for 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;IACxB,IAAI,EAAE,cAAc;IACpB,IAAI,EAAE,eAAe;IACrB,IAAI,EAAE,eAAe;CACb;AAEV;AACA,MAAM,eAAe,GAAG,IAAI,QAAQ,CAA8B;AAChE,IAAA,OAAO,EAAE,GAAG;AACb,CAAA,CAAC;AAEF;;;;AAIG;AACH,SAAS,YAAY,CAAC,IAAY,EAAA;IAChC,MAAM,GAAG,GAAG,eAAe,CAAC,GAAG,CAAC,IAAI,CAAC;AACrC,IAAA,IAAI,GAAG;AAAE,QAAA,OAAO,GAAG;IACnB,MAAM,CAAC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AC,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;;;;"}
|
package/dist/esm/modern.js
CHANGED
package/dist/esm/molad.d.ts
CHANGED
|
@@ -16,8 +16,8 @@ import './locale';
|
|
|
16
16
|
* import {Molad, months} from '@hebcal/core';
|
|
17
17
|
* const m = new Molad(5784, months.NISAN);
|
|
18
18
|
* console.log(m.getMonthName()); // 'Nisan'
|
|
19
|
-
* console.log(m.getHour(), m.getMinutes(), m.getChalakim()); //
|
|
20
|
-
* console.log(m.render('en')); // 'Molad Nisan:
|
|
19
|
+
* console.log(m.getHour(), m.getMinutes(), m.getChalakim()); // 22 57 7
|
|
20
|
+
* console.log(m.render('en')); // 'Molad Nisan: Monday, 10:57pm and 7 chalakim'
|
|
21
21
|
*/
|
|
22
22
|
export declare class Molad {
|
|
23
23
|
private readonly m;
|
|
@@ -69,17 +69,21 @@ export declare class Molad {
|
|
|
69
69
|
*/
|
|
70
70
|
getChalakim(): number;
|
|
71
71
|
/**
|
|
72
|
-
* Returns the
|
|
73
|
-
*
|
|
74
|
-
*
|
|
75
|
-
*
|
|
72
|
+
* Returns the moment of the molad as a `Temporal.ZonedDateTime` in the `UTC` zone.
|
|
73
|
+
*
|
|
74
|
+
* The molad is computed in Jerusalem *standard* time and then converted, so the
|
|
75
|
+
* returned instant is correct year-round; only the zone of the returned object
|
|
76
|
+
* is `UTC`. This method subtracts 20.94 minutes (20 minutes and 56.496 seconds)
|
|
77
|
+
* from the computed time — Har Habayis, at longitude 35.2354°, is 5.2354° away
|
|
78
|
+
* from the multiple-of-15 timezone longitude — to get to standard time. Daylight
|
|
79
|
+
* savings time is intentionally not applied; adjust when formatting for display.
|
|
76
80
|
*
|
|
77
81
|
* The returned value is cached after the first call.
|
|
78
82
|
* @example
|
|
79
83
|
* import {Molad, months} from '@hebcal/core';
|
|
80
84
|
* const m = new Molad(5784, months.NISAN);
|
|
81
85
|
* const zdt = m.getInstant();
|
|
82
|
-
* console.log(zdt.toString()); //
|
|
86
|
+
* console.log(zdt.toString()); // '2024-04-08T20:36:26.837+00:00[UTC]'
|
|
83
87
|
* @return the `Temporal.ZonedDateTime` representing the moment of the molad
|
|
84
88
|
*/
|
|
85
89
|
getInstant(): Temporal.ZonedDateTime;
|
|
@@ -92,9 +96,9 @@ export declare class Molad {
|
|
|
92
96
|
*/
|
|
93
97
|
getTchilasZmanKidushLevana3Days(): Temporal.ZonedDateTime;
|
|
94
98
|
/**
|
|
95
|
-
* Returns the earliest time of Kiddush Levana calculated as 7 days after the molad as mentioned by the
|
|
96
|
-
*
|
|
97
|
-
*
|
|
99
|
+
* Returns the earliest time of Kiddush Levana calculated as 7 days after the molad as mentioned by the
|
|
100
|
+
* [Mechaber](https://en.wikipedia.org/wiki/Yosef_Karo). See the
|
|
101
|
+
* [Bach's](https://en.wikipedia.org/wiki/Yoel_Sirkis) opinion on this time. This method returns the time
|
|
98
102
|
* even if it is during the day when _Kiddush Levana_ can't be said. Callers of this method should consider
|
|
99
103
|
* displaying the next _tzais_ if the zman is between _alos_ and _tzais_.
|
|
100
104
|
*
|
|
@@ -102,8 +106,8 @@ export declare class Molad {
|
|
|
102
106
|
*/
|
|
103
107
|
getTchilasZmanKidushLevana7Days(): Temporal.ZonedDateTime;
|
|
104
108
|
/**
|
|
105
|
-
* Returns the latest time of Kiddush Levana according to the
|
|
106
|
-
*
|
|
109
|
+
* Returns the latest time of Kiddush Levana according to the
|
|
110
|
+
* [Maharil's](https://en.wikipedia.org/wiki/Yaakov_ben_Moshe_Levi_Moelin) opinion that it is calculated as
|
|
107
111
|
* halfway between molad and molad. This adds half the 29 days, 12 hours and 793 chalakim time between molad and
|
|
108
112
|
* molad (14 days, 18 hours, 22 minutes and 666 milliseconds) to the month's molad. This method returns the time
|
|
109
113
|
* even if it is during the day when _Kiddush Levana_ can't be said. Callers of this method should consider
|
|
@@ -115,12 +119,12 @@ export declare class Molad {
|
|
|
115
119
|
/**
|
|
116
120
|
* Returns the latest time of Kiddush Levana calculated as 15 days after the molad. This is the opinion brought down
|
|
117
121
|
* in the Shulchan Aruch (Orach Chaim 426). It should be noted that some opinions hold that the
|
|
118
|
-
*
|
|
119
|
-
*
|
|
120
|
-
* {@link Molad.getSofZmanKidushLevanaBetweenMoldos
|
|
122
|
+
* [Rema](https://en.wikipedia.org/wiki/Moses_Isserles) who brings down the opinion of the
|
|
123
|
+
* [Maharil's](https://en.wikipedia.org/wiki/Yaakov_ben_Moshe_Levi_Moelin) of calculating
|
|
124
|
+
* {@link Molad.getSofZmanKidushLevanaBetweenMoldos | half way between molad and molad} is of the opinion that Mechaber
|
|
121
125
|
* agrees to his opinion. Also see the Aruch Hashulchan. For additional details on the subject, See Rabbi Dovid
|
|
122
|
-
* Heber's very detailed writeup in Siman Daled (chapter 4) of
|
|
123
|
-
*
|
|
126
|
+
* Heber's very detailed writeup in Siman Daled (chapter 4) of
|
|
127
|
+
* [Shaarei Zmanim](https://www.worldcat.org/oclc/461326125). This method returns the time even if it is during
|
|
124
128
|
* the day when _Kiddush Levana_ can't be said. Callers of this method should consider displaying _alos_
|
|
125
129
|
* before this time if the zman is between _alos_ and _tzais_.
|
|
126
130
|
*
|
|
@@ -133,14 +137,16 @@ export declare class Molad {
|
|
|
133
137
|
* month name, day of week, hour : minute, and chalakim if non-zero.
|
|
134
138
|
*
|
|
135
139
|
* Time format honors `options.hour12` and `options.location` (12-hour vs.
|
|
136
|
-
* 24-hour); see {@link
|
|
140
|
+
* 24-hour); see {@link reformatTimeStr}.
|
|
137
141
|
* @example
|
|
138
142
|
* import {Molad, months} from '@hebcal/core';
|
|
139
143
|
* const m = new Molad(5784, months.NISAN);
|
|
140
144
|
* m.render('en', {hour12: true});
|
|
141
|
-
* // => 'Molad Nisan:
|
|
145
|
+
* // => 'Molad Nisan: Monday, 10:57pm and 7 chalakim'
|
|
146
|
+
* m.render('en', {hour12: false});
|
|
147
|
+
* // => 'Molad Nisan: Monday, 22:57 and 7 chalakim'
|
|
142
148
|
* m.render('he');
|
|
143
|
-
* // => 'מוֹלָד נִיסָן יִהְיֶה בַּיּוֹם שֵׁנִי בשָׁבוּעַ, …'
|
|
149
|
+
* // => 'מוֹלָד הָלְּבָנָה נִיסָן יִהְיֶה בַּיּוֹם שֵׁנִי בשָׁבוּעַ, …'
|
|
144
150
|
* @param [locale] Optional locale name (defaults to empty locale)
|
|
145
151
|
* @param options used for time formatting (12-hour vs 24-hour)
|
|
146
152
|
*/
|
package/dist/esm/molad.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! @hebcal/core v6.
|
|
1
|
+
/*! @hebcal/core v6.9.0, 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';
|
|
@@ -69,8 +69,8 @@ function getHebrewTimeOfDay(hour) {
|
|
|
69
69
|
* import {Molad, months} from '@hebcal/core';
|
|
70
70
|
* const m = new Molad(5784, months.NISAN);
|
|
71
71
|
* console.log(m.getMonthName()); // 'Nisan'
|
|
72
|
-
* console.log(m.getHour(), m.getMinutes(), m.getChalakim()); //
|
|
73
|
-
* console.log(m.render('en')); // 'Molad Nisan:
|
|
72
|
+
* console.log(m.getHour(), m.getMinutes(), m.getChalakim()); // 22 57 7
|
|
73
|
+
* console.log(m.render('en')); // 'Molad Nisan: Monday, 10:57pm and 7 chalakim'
|
|
74
74
|
*/
|
|
75
75
|
class Molad {
|
|
76
76
|
m;
|
|
@@ -142,17 +142,21 @@ class Molad {
|
|
|
142
142
|
return this.m.chalakim;
|
|
143
143
|
}
|
|
144
144
|
/**
|
|
145
|
-
* Returns the
|
|
146
|
-
*
|
|
147
|
-
*
|
|
148
|
-
*
|
|
145
|
+
* Returns the moment of the molad as a `Temporal.ZonedDateTime` in the `UTC` zone.
|
|
146
|
+
*
|
|
147
|
+
* The molad is computed in Jerusalem *standard* time and then converted, so the
|
|
148
|
+
* returned instant is correct year-round; only the zone of the returned object
|
|
149
|
+
* is `UTC`. This method subtracts 20.94 minutes (20 minutes and 56.496 seconds)
|
|
150
|
+
* from the computed time — Har Habayis, at longitude 35.2354°, is 5.2354° away
|
|
151
|
+
* from the multiple-of-15 timezone longitude — to get to standard time. Daylight
|
|
152
|
+
* savings time is intentionally not applied; adjust when formatting for display.
|
|
149
153
|
*
|
|
150
154
|
* The returned value is cached after the first call.
|
|
151
155
|
* @example
|
|
152
156
|
* import {Molad, months} from '@hebcal/core';
|
|
153
157
|
* const m = new Molad(5784, months.NISAN);
|
|
154
158
|
* const zdt = m.getInstant();
|
|
155
|
-
* console.log(zdt.toString()); //
|
|
159
|
+
* console.log(zdt.toString()); // '2024-04-08T20:36:26.837+00:00[UTC]'
|
|
156
160
|
* @return the `Temporal.ZonedDateTime` representing the moment of the molad
|
|
157
161
|
*/
|
|
158
162
|
getInstant() {
|
|
@@ -171,9 +175,9 @@ class Molad {
|
|
|
171
175
|
return zdt.add({ hours: 72 });
|
|
172
176
|
}
|
|
173
177
|
/**
|
|
174
|
-
* Returns the earliest time of Kiddush Levana calculated as 7 days after the molad as mentioned by the
|
|
175
|
-
*
|
|
176
|
-
*
|
|
178
|
+
* Returns the earliest time of Kiddush Levana calculated as 7 days after the molad as mentioned by the
|
|
179
|
+
* [Mechaber](https://en.wikipedia.org/wiki/Yosef_Karo). See the
|
|
180
|
+
* [Bach's](https://en.wikipedia.org/wiki/Yoel_Sirkis) opinion on this time. This method returns the time
|
|
177
181
|
* even if it is during the day when _Kiddush Levana_ can't be said. Callers of this method should consider
|
|
178
182
|
* displaying the next _tzais_ if the zman is between _alos_ and _tzais_.
|
|
179
183
|
*
|
|
@@ -184,8 +188,8 @@ class Molad {
|
|
|
184
188
|
return zdt.add({ hours: 168 });
|
|
185
189
|
}
|
|
186
190
|
/**
|
|
187
|
-
* Returns the latest time of Kiddush Levana according to the
|
|
188
|
-
*
|
|
191
|
+
* Returns the latest time of Kiddush Levana according to the
|
|
192
|
+
* [Maharil's](https://en.wikipedia.org/wiki/Yaakov_ben_Moshe_Levi_Moelin) opinion that it is calculated as
|
|
189
193
|
* halfway between molad and molad. This adds half the 29 days, 12 hours and 793 chalakim time between molad and
|
|
190
194
|
* molad (14 days, 18 hours, 22 minutes and 666 milliseconds) to the month's molad. This method returns the time
|
|
191
195
|
* even if it is during the day when _Kiddush Levana_ can't be said. Callers of this method should consider
|
|
@@ -208,12 +212,12 @@ class Molad {
|
|
|
208
212
|
/**
|
|
209
213
|
* Returns the latest time of Kiddush Levana calculated as 15 days after the molad. This is the opinion brought down
|
|
210
214
|
* in the Shulchan Aruch (Orach Chaim 426). It should be noted that some opinions hold that the
|
|
211
|
-
*
|
|
212
|
-
*
|
|
213
|
-
* {@link Molad.getSofZmanKidushLevanaBetweenMoldos
|
|
215
|
+
* [Rema](https://en.wikipedia.org/wiki/Moses_Isserles) who brings down the opinion of the
|
|
216
|
+
* [Maharil's](https://en.wikipedia.org/wiki/Yaakov_ben_Moshe_Levi_Moelin) of calculating
|
|
217
|
+
* {@link Molad.getSofZmanKidushLevanaBetweenMoldos | half way between molad and molad} is of the opinion that Mechaber
|
|
214
218
|
* agrees to his opinion. Also see the Aruch Hashulchan. For additional details on the subject, See Rabbi Dovid
|
|
215
|
-
* Heber's very detailed writeup in Siman Daled (chapter 4) of
|
|
216
|
-
*
|
|
219
|
+
* Heber's very detailed writeup in Siman Daled (chapter 4) of
|
|
220
|
+
* [Shaarei Zmanim](https://www.worldcat.org/oclc/461326125). This method returns the time even if it is during
|
|
217
221
|
* the day when _Kiddush Levana_ can't be said. Callers of this method should consider displaying _alos_
|
|
218
222
|
* before this time if the zman is between _alos_ and _tzais_.
|
|
219
223
|
*
|
|
@@ -230,14 +234,16 @@ class Molad {
|
|
|
230
234
|
* month name, day of week, hour : minute, and chalakim if non-zero.
|
|
231
235
|
*
|
|
232
236
|
* Time format honors `options.hour12` and `options.location` (12-hour vs.
|
|
233
|
-
* 24-hour); see {@link
|
|
237
|
+
* 24-hour); see {@link reformatTimeStr}.
|
|
234
238
|
* @example
|
|
235
239
|
* import {Molad, months} from '@hebcal/core';
|
|
236
240
|
* const m = new Molad(5784, months.NISAN);
|
|
237
241
|
* m.render('en', {hour12: true});
|
|
238
|
-
* // => 'Molad Nisan:
|
|
242
|
+
* // => 'Molad Nisan: Monday, 10:57pm and 7 chalakim'
|
|
243
|
+
* m.render('en', {hour12: false});
|
|
244
|
+
* // => 'Molad Nisan: Monday, 22:57 and 7 chalakim'
|
|
239
245
|
* m.render('he');
|
|
240
|
-
* // => 'מוֹלָד נִיסָן יִהְיֶה בַּיּוֹם שֵׁנִי בשָׁבוּעַ, …'
|
|
246
|
+
* // => 'מוֹלָד הָלְּבָנָה נִיסָן יִהְיֶה בַּיּוֹם שֵׁנִי בשָׁבוּעַ, …'
|
|
241
247
|
* @param [locale] Optional locale name (defaults to empty locale)
|
|
242
248
|
* @param options used for time formatting (12-hour vs 24-hour)
|
|
243
249
|
*/
|