@hebcal/core 6.0.5 → 6.0.7

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 (149) hide show
  1. package/README.md +42 -27
  2. package/dist/bundle.js +26 -15
  3. package/dist/bundle.js.map +1 -1
  4. package/dist/bundle.min.js +3 -3
  5. package/dist/bundle.min.js.map +1 -1
  6. package/dist/esm/DailyLearning.js +1 -1
  7. package/dist/esm/HebrewDateEvent.js +1 -1
  8. package/dist/esm/HolidayEvent.js +2 -2
  9. package/dist/esm/HolidayEvent.js.map +1 -1
  10. package/dist/esm/MevarchimChodeshEvent.js +1 -1
  11. package/dist/esm/ParshaEvent.js +2 -2
  12. package/dist/esm/ParshaEvent.js.map +1 -1
  13. package/dist/esm/TimedEvent.js +1 -1
  14. package/dist/esm/YomKippurKatanEvent.js +1 -1
  15. package/dist/esm/ashkenazi.po.js +1 -1
  16. package/dist/esm/calendar.js +7 -5
  17. package/dist/esm/calendar.js.map +1 -1
  18. package/dist/esm/candles.js +1 -1
  19. package/dist/esm/event.js +1 -1
  20. package/dist/esm/getStartAndEnd.js +1 -1
  21. package/dist/esm/hallel.js +1 -1
  22. package/dist/esm/he-x-NoNikud.po.d.ts +2 -0
  23. package/dist/esm/he-x-NoNikud.po.js +2 -2
  24. package/dist/esm/he-x-NoNikud.po.js.map +1 -1
  25. package/dist/esm/he.po.d.ts +1 -0
  26. package/dist/esm/he.po.js +2 -2
  27. package/dist/esm/he.po.js.map +1 -1
  28. package/dist/esm/hebcal.js +1 -1
  29. package/dist/esm/holidays.js +1 -1
  30. package/dist/esm/holidays.js.map +1 -1
  31. package/dist/esm/index.js +1 -1
  32. package/dist/esm/isAssurBemlacha.js +1 -1
  33. package/dist/esm/locale.js +1 -1
  34. package/dist/esm/location.js +2 -2
  35. package/dist/esm/location.js.map +1 -1
  36. package/dist/esm/modern.js +1 -1
  37. package/dist/esm/molad.js +1 -1
  38. package/dist/esm/omer.d.ts +1 -1
  39. package/dist/esm/omer.js +6 -2
  40. package/dist/esm/omer.js.map +1 -1
  41. package/dist/esm/parshaName.js +1 -1
  42. package/dist/esm/parshaYear.d.ts +2 -2
  43. package/dist/esm/parshaYear.js +1 -1
  44. package/dist/esm/parshaYear.js.map +1 -1
  45. package/dist/esm/pkgVersion.d.ts +1 -1
  46. package/dist/esm/pkgVersion.js +2 -2
  47. package/dist/esm/pkgVersion.js.map +1 -1
  48. package/dist/esm/reformatTimeStr.js +1 -1
  49. package/dist/esm/sedra.d.ts +5 -1
  50. package/dist/esm/sedra.js +9 -3
  51. package/dist/esm/sedra.js.map +1 -1
  52. package/dist/esm/staticHolidays.js +1 -2
  53. package/dist/esm/staticHolidays.js.map +1 -1
  54. package/dist/esm/tachanun.js +1 -1
  55. package/dist/esm/zmanim.js +1 -1
  56. package/dist/he-x-NoNikud.po.d.ts +2 -0
  57. package/dist/he.po.d.ts +1 -0
  58. package/dist/omer.d.ts +1 -1
  59. package/dist/parshaYear.d.ts +2 -2
  60. package/dist/pkgVersion.d.ts +1 -1
  61. package/dist/po2json.d.ts +1 -0
  62. package/dist/po2json.js +41 -0
  63. package/dist/sedra.d.ts +5 -1
  64. package/dist/size-demo/dist/getHoliday.d.ts +1944 -0
  65. package/dist/size-demo/dist/getHoliday.js +3712 -0
  66. package/dist/size-demo/dist/parshiyot.js +10662 -0
  67. package/dist/size-demo/dist/sedra.d.ts +1411 -0
  68. package/dist/size-demo/dist/sedra.js +2359 -0
  69. package/dist/size-demo/dist/tachanun.d.ts +1015 -0
  70. package/dist/size-demo/dist/tachanun.js +1755 -0
  71. package/dist/size-demo/getHoliday.d.ts +1 -0
  72. package/dist/size-demo/getHoliday.js +3 -0
  73. package/dist/size-demo/parshiyot.d.ts +1 -0
  74. package/dist/size-demo/parshiyot.js +11 -0
  75. package/dist/size-demo/rollup.config.d.ts +3 -0
  76. package/dist/size-demo/rollup.config.js +47 -0
  77. package/dist/size-demo/sedra.d.ts +1 -0
  78. package/dist/size-demo/sedra.js +3 -0
  79. package/dist/size-demo/tachanun.d.ts +1 -0
  80. package/dist/size-demo/tachanun.js +3 -0
  81. package/dist/src/CalOptions.d.ts +168 -0
  82. package/dist/src/CalOptions.js +1 -0
  83. package/dist/src/DailyLearning.d.ts +32 -0
  84. package/dist/src/DailyLearning.js +55 -0
  85. package/dist/src/HebrewDateEvent.d.ts +37 -0
  86. package/dist/src/HebrewDateEvent.js +72 -0
  87. package/dist/src/HolidayEvent.d.ts +83 -0
  88. package/dist/src/HolidayEvent.js +186 -0
  89. package/dist/src/MevarchimChodeshEvent.d.ts +26 -0
  90. package/dist/src/MevarchimChodeshEvent.js +50 -0
  91. package/dist/src/ParshaEvent.d.ts +19 -0
  92. package/dist/src/ParshaEvent.js +43 -0
  93. package/dist/src/TimedEvent.d.ts +47 -0
  94. package/dist/src/TimedEvent.js +92 -0
  95. package/dist/src/YomKippurKatanEvent.d.ts +23 -0
  96. package/dist/src/YomKippurKatanEvent.js +38 -0
  97. package/dist/src/ashkenazi.po.d.ts +70 -0
  98. package/dist/src/ashkenazi.po.js +1 -0
  99. package/dist/src/calendar.d.ts +111 -0
  100. package/dist/src/calendar.js +660 -0
  101. package/dist/src/candles.d.ts +44 -0
  102. package/dist/src/candles.js +163 -0
  103. package/dist/src/event.d.ts +188 -0
  104. package/dist/src/event.js +233 -0
  105. package/dist/src/getStartAndEnd.d.ts +6 -0
  106. package/dist/src/getStartAndEnd.js +97 -0
  107. package/dist/src/hallel.d.ts +6 -0
  108. package/dist/src/hallel.js +47 -0
  109. package/dist/src/he-x-NoNikud.po.d.ts +15 -0
  110. package/dist/src/he-x-NoNikud.po.js +1 -0
  111. package/dist/src/he.po.d.ts +195 -0
  112. package/dist/src/he.po.js +1 -0
  113. package/dist/src/hebcal.d.ts +260 -0
  114. package/dist/src/hebcal.js +332 -0
  115. package/dist/src/holidays.d.ts +22 -0
  116. package/dist/src/holidays.js +288 -0
  117. package/dist/src/index.d.ts +26 -0
  118. package/dist/src/index.js +24 -0
  119. package/dist/src/isAssurBemlacha.d.ts +9 -0
  120. package/dist/src/isAssurBemlacha.js +62 -0
  121. package/dist/src/locale.d.ts +2 -0
  122. package/dist/src/locale.js +11 -0
  123. package/dist/src/location.d.ts +73 -0
  124. package/dist/src/location.js +306 -0
  125. package/dist/src/modern.d.ts +18 -0
  126. package/dist/src/modern.js +59 -0
  127. package/dist/src/molad.d.ts +62 -0
  128. package/dist/src/molad.js +169 -0
  129. package/dist/src/omer.d.ts +53 -0
  130. package/dist/src/omer.js +302 -0
  131. package/dist/src/parshaName.d.ts +2 -0
  132. package/dist/src/parshaName.js +13 -0
  133. package/dist/src/parshaYear.d.ts +9 -0
  134. package/dist/src/parshaYear.js +24 -0
  135. package/dist/src/pkgVersion.d.ts +2 -0
  136. package/dist/src/pkgVersion.js +2 -0
  137. package/dist/src/reformatTimeStr.d.ts +8 -0
  138. package/dist/src/reformatTimeStr.js +48 -0
  139. package/dist/src/sedra.d.ts +95 -0
  140. package/dist/src/sedra.js +477 -0
  141. package/dist/src/staticHolidays.d.ts +176 -0
  142. package/dist/src/staticHolidays.js +614 -0
  143. package/dist/src/tachanun.d.ts +29 -0
  144. package/dist/src/tachanun.js +120 -0
  145. package/dist/src/zmanim.d.ts +347 -0
  146. package/dist/src/zmanim.js +579 -0
  147. package/dist/version.d.ts +1 -0
  148. package/dist/version.js +9 -0
  149. package/package.json +12 -9
@@ -0,0 +1,660 @@
1
+ import { Locale } from './locale';
2
+ import { abs2greg, HDate, months } from '@hebcal/hdate';
3
+ import { makeCandleEvent, makeFastStartEnd, makeWeekdayChanukahCandleLighting, } from './candles';
4
+ import { Event, flags } from './event';
5
+ import { getStartAndEnd } from './getStartAndEnd';
6
+ import { HebrewDateEvent } from './HebrewDateEvent';
7
+ import { getHolidaysForYear_ } from './holidays';
8
+ import { ParshaEvent } from './ParshaEvent';
9
+ import { getSedra } from './sedra';
10
+ import { HavdalahEvent } from './TimedEvent';
11
+ import { DailyLearning } from './DailyLearning';
12
+ import { MevarchimChodeshEvent } from './MevarchimChodeshEvent';
13
+ import { MoladEvent, Molad } from './molad';
14
+ import { OmerEvent } from './omer';
15
+ import { Zmanim } from './zmanim';
16
+ import { Location } from './location';
17
+ /**
18
+ * Calculates holidays and other Hebrew calendar events based on {@link CalOptions}.
19
+ *
20
+ * Each holiday is represented by an {@link Event} object which includes a date,
21
+ * a description, flags and optional attributes.
22
+ * If given no options, returns holidays for the Diaspora for the current Gregorian year.
23
+ *
24
+ * The date range returned by this function can be controlled by:
25
+ * * `options.year` - Gregorian (e.g. 1993) or Hebrew year (e.g. 5749)
26
+ * * `options.isHebrewYear` - to interpret `year` as Hebrew year
27
+ * * `options.numYears` - generate calendar for multiple years (default 1)
28
+ * * `options.month` - Gregorian or Hebrew month (to filter results to a single month)
29
+ *
30
+ * Alternatively, specify start and end days with `Date` or {@link HDate} instances:
31
+ * * `options.start` - use specific start date (requires `end` date)
32
+ * * `options.end` - use specific end date (requires `start` date)
33
+ *
34
+ * Unless `options.noHolidays == true`, default holidays include:
35
+ * * Major holidays - Rosh Hashana, Yom Kippur, Pesach, Sukkot, etc.
36
+ * * Minor holidays - Purim, Chanukah, Tu BiShvat, Lag BaOmer, etc.
37
+ * * Minor fasts - Ta'anit Esther, Tzom Gedaliah, etc. (unless `options.noMinorFast`)
38
+ * * Special Shabbatot - Shabbat Shekalim, Zachor, etc. (unless `options.noSpecialShabbat`)
39
+ * * Modern Holidays - Yom HaShoah, Yom HaAtzma'ut, etc. (unless `options.noModern`)
40
+ * * Rosh Chodesh (unless `options.noRoshChodesh`)
41
+ *
42
+ * Holiday and Torah reading schedules differ between Israel and the Disapora.
43
+ * Set `options.il=true` to use the Israeli schedule.
44
+ *
45
+ * Additional non-default event types can be specified:
46
+ * * Parashat HaShavua - weekly Torah Reading on Saturdays (`options.sedrot`)
47
+ * * Counting of the Omer (`options.omer`)
48
+ * * Shabbat Mevarchim HaChodesh on Saturday before Rosh Chodesh (`options.shabbatMevarchim`)
49
+ * * Molad announcement on Saturday before Rosh Chodesh (`options.molad`)
50
+ * * Yom Kippur Katan (`options.yomKippurKatan`)
51
+ * * Yizkor (`options.yizkor`)
52
+ *
53
+ * Daily Study of texts are supported by the
54
+ * {@link https://github.com/hebcal/hebcal-learning @hebcal/learning} package,
55
+ * for example:
56
+ * * Babylonian Talmud Daf Yomi (`options.dailyLearning.dafYomi`)
57
+ * * Jerusalem Talmud (Yerushalmi) Yomi (`options.dailyLearning.yerushalmi`)
58
+ * * Mishna Yomi (`options.dailyLearning.mishnaYomi`)
59
+ * * Nach Yomi (`options.dailyLearning.nachYomi`)
60
+ *
61
+ * Candle-lighting and Havdalah times are approximated using latitude and longitude
62
+ * specified by the {@link Location} class. The `Location` class contains a small
63
+ * database of cities with their associated geographic information and time-zone information.
64
+ * If you ever have any doubts about Hebcal's times, consult your local halachic authority.
65
+ * If you enter geographic coordinates above the arctic circle or antarctic circle,
66
+ * the times are guaranteed to be wrong.
67
+ *
68
+ * To add candle-lighting options, set `options.candlelighting=true` and set
69
+ * `options.location` to an instance of `Location`. By default, candle lighting
70
+ * time is 18 minutes before sundown (40 minutes for Jerusalem,
71
+ * 30 minutes for Haifa and Zikhron Ya'akov) and Havdalah is
72
+ * calculated according to Tzeit Hakochavim - Nightfall (the point when 3 small stars
73
+ * are observable in the night time sky with the naked eye). The default Havdalah
74
+ * option (Tzeit Hakochavim) is calculated when the sun is 8.5° below the horizon.
75
+ * These defaults can be changed using these options:
76
+ * * `options.candleLightingMins` - minutes before sundown to light candles
77
+ * * `options.havdalahMins` - minutes after sundown for Havdalah (typical values are 42, 50, or 72).
78
+ * Havdalah times are suppressed when `options.havdalahMins=0`.
79
+ * * `options.havdalahDeg` - degrees for solar depression for Havdalah.
80
+ * Default is 8.5 degrees for 3 small stars. Use 7.083 degrees for 3 medium-sized stars.
81
+ * Havdalah times are suppressed when `options.havdalahDeg=0`.
82
+ *
83
+ * If both `options.candlelighting=true` and `options.location` is specified,
84
+ * Chanukah candle-lighting times and minor fast start/end times will also be generated.
85
+ * Chanukah candle-lighting is at Bein HaShmashos (13.5 minutes before
86
+ * the sun is 7.083° below the horizon in the evening)
87
+ * on weekdays, at regular candle-lighting time on Fridays, and at regular Havdalah time on
88
+ * Saturday night (see above).
89
+ *
90
+ * Minor fasts begin at Alot HaShachar (sun is 16.1° below the horizon in the morning) and
91
+ * end when 3 medium-sized stars are observable in the night sky (sun is 7.083° below the horizon
92
+ * in the evening).
93
+ *
94
+ * Two options also exist for generating an Event with the Hebrew date:
95
+ * * `options.addHebrewDates` - print the Hebrew date for the entire date range
96
+ * * `options.addHebrewDatesForEvents` - print the Hebrew date for dates with some events
97
+ *
98
+ * Lastly, translation and transliteration of event titles is controlled by
99
+ * `options.locale` and the {@link Locale} API.
100
+ * `@hebcal/core` supports three locales by default:
101
+ * * `en` - default, Sephardic transliterations (e.g. "Shabbat")
102
+ * * `ashkenazi` - Ashkenazi transliterations (e.g. "Shabbos")
103
+ * * `he` - Hebrew (e.g. "שַׁבָּת")
104
+ *
105
+ * Additional locales (such as `ru` or `fr`) are supported by the
106
+ * {@link https://github.com/hebcal/hebcal-locales @hebcal/locales} package
107
+ *
108
+ * @example
109
+ * import {HebrewCalendar, HDate, Location, Event} from '@hebcal/core';
110
+ * const options: CalOptions = {
111
+ * year: 1981,
112
+ * isHebrewYear: false,
113
+ * candlelighting: true,
114
+ * location: Location.lookup('San Francisco'),
115
+ * sedrot: true,
116
+ * omer: true,
117
+ * };
118
+ * const events = HebrewCalendar.calendar(options);
119
+ * for (const ev of events) {
120
+ * const hd = ev.getDate();
121
+ * const date = hd.greg();
122
+ * console.log(date.toLocaleDateString(), ev.render('en'), hd.toString());
123
+ * }
124
+ */
125
+ export function calendar(options = {}) {
126
+ options = Object.assign({}, options); // so we can modify freely
127
+ checkCandleOptions(options);
128
+ const location = (options.location = options.location || defaultLocation);
129
+ const il = (options.il = options.il || location.getIsrael() || false);
130
+ const hasUserMask = typeof options.mask === 'number';
131
+ options.mask = getMaskFromOptions(options);
132
+ if (options.locale) {
133
+ const locale = options.locale;
134
+ if (locale && typeof locale !== 'string') {
135
+ throw new TypeError(`Invalid options.locale: ${locale}`);
136
+ }
137
+ if (!Locale.hasLocale(locale)) {
138
+ throw new TypeError(`Locale '${locale}' not found; did you forget to import @hebcal/locales?`);
139
+ }
140
+ }
141
+ else if (options.ashkenazi) {
142
+ options.locale = 'ashkenazi';
143
+ }
144
+ else {
145
+ options.locale = 'en';
146
+ }
147
+ const evts = [];
148
+ let sedra;
149
+ let holidaysYear;
150
+ let beginOmer = -1;
151
+ let endOmer = -1;
152
+ let currentYear = -1;
153
+ const startAndEnd = getStartAndEnd(options);
154
+ warnUnrecognizedOptions(options);
155
+ const startAbs = startAndEnd[0];
156
+ const endAbs = startAndEnd[1];
157
+ const startGreg = abs2greg(startAbs);
158
+ const startGregYear = startGreg.getFullYear();
159
+ if (startGregYear < 100 || startGregYear > 9999) {
160
+ options.candlelighting = false;
161
+ options.sedrot = false;
162
+ options.dailyLearning = {};
163
+ }
164
+ for (let abs = startAbs; abs <= endAbs; abs++) {
165
+ const hd = new HDate(abs);
166
+ const hyear = hd.getFullYear();
167
+ if (hyear !== currentYear) {
168
+ currentYear = hyear;
169
+ holidaysYear = getHolidaysForYear_(currentYear);
170
+ if (options.sedrot) {
171
+ sedra = getSedra(currentYear, il);
172
+ }
173
+ if (options.omer) {
174
+ beginOmer = HDate.hebrew2abs(currentYear, NISAN, 16);
175
+ endOmer = HDate.hebrew2abs(currentYear, SIVAN, 5);
176
+ }
177
+ }
178
+ const prevEventsLength = evts.length;
179
+ const dow = hd.getDay();
180
+ const isFriday = dow === FRI;
181
+ const isSaturday = dow === SAT;
182
+ let candlesEv;
183
+ const holidays0 = holidaysYear.get(hd.toString()) || [];
184
+ const holidays = holidays0.filter(ev => ev.observedIn(il));
185
+ for (const ev of holidays) {
186
+ candlesEv = appendHolidayAndRelated(candlesEv, evts, ev, options, isFriday, isSaturday, hasUserMask);
187
+ }
188
+ if (options.sedrot && isSaturday) {
189
+ const parsha0 = sedra.lookup(abs);
190
+ if (!parsha0.chag) {
191
+ evts.push(new ParshaEvent(parsha0));
192
+ }
193
+ }
194
+ if (options.yizkor) {
195
+ const mm = hd.getMonth();
196
+ const dd = hd.getDate();
197
+ if ((mm === months.TISHREI && (dd === 10 || dd === 22)) ||
198
+ (mm === NISAN && dd === (il ? 21 : 22)) ||
199
+ (mm === SIVAN && dd === (il ? 6 : 7))) {
200
+ const linkedEvent = holidays[0];
201
+ const ev = new Event(hd, 'Yizkor', flags.YIZKOR, {
202
+ emoji: '🕯️',
203
+ linkedEvent,
204
+ });
205
+ evts.push(ev);
206
+ }
207
+ }
208
+ const dailyLearning = options.dailyLearning;
209
+ let numDailyLearning = 0;
210
+ if (typeof dailyLearning === 'object' && dailyLearning !== null) {
211
+ const events = makeDailyLearning(hd, dailyLearning, il);
212
+ numDailyLearning = events.length;
213
+ if (numDailyLearning) {
214
+ evts.push(...events);
215
+ }
216
+ }
217
+ if (options.omer && abs >= beginOmer && abs <= endOmer) {
218
+ const omer = abs - beginOmer + 1;
219
+ const omerEv = makeOmerEvent(hd, omer, options);
220
+ evts.push(omerEv);
221
+ }
222
+ if (isSaturday && (options.molad || options.shabbatMevarchim)) {
223
+ const events = makeMoladAndMevarchimChodesh(hd, options);
224
+ evts.push(...events);
225
+ }
226
+ if (!candlesEv && options.candlelighting && (isFriday || isSaturday)) {
227
+ candlesEv = makeCandleEvent(undefined, hd, options, isFriday, isSaturday);
228
+ if (isFriday && candlesEv && sedra) {
229
+ const parsha = sedra.lookup(abs);
230
+ if (!parsha.chag) {
231
+ const pe = new ParshaEvent(parsha);
232
+ candlesEv.memo = pe.render(options.locale);
233
+ }
234
+ else {
235
+ candlesEv.memo = Locale.gettext(parsha.parsha[0], options.locale);
236
+ }
237
+ }
238
+ }
239
+ // suppress Havdalah when options.havdalahMins=0 or options.havdalahDeg=0
240
+ if (candlesEv instanceof HavdalahEvent &&
241
+ (options.havdalahMins === 0 || options.havdalahDeg === 0)) {
242
+ candlesEv = undefined;
243
+ }
244
+ if (candlesEv) {
245
+ evts.push(candlesEv);
246
+ }
247
+ if (options.addHebrewDates ||
248
+ (options.addHebrewDatesForEvents &&
249
+ prevEventsLength !== evts.length - numDailyLearning)) {
250
+ const e2 = new HebrewDateEvent(hd);
251
+ if (prevEventsLength === evts.length) {
252
+ evts.push(e2);
253
+ }
254
+ else {
255
+ evts.splice(prevEventsLength, 0, e2);
256
+ }
257
+ }
258
+ }
259
+ return evts;
260
+ }
261
+ const FRI = 5;
262
+ const SAT = 6;
263
+ const NISAN = months.NISAN;
264
+ const SIVAN = months.SIVAN;
265
+ const ELUL = months.ELUL;
266
+ const LIGHT_CANDLES = flags.LIGHT_CANDLES;
267
+ const YOM_TOV_ENDS = flags.YOM_TOV_ENDS;
268
+ const CHUL_ONLY = flags.CHUL_ONLY;
269
+ const IL_ONLY = flags.IL_ONLY;
270
+ const LIGHT_CANDLES_TZEIS = flags.LIGHT_CANDLES_TZEIS;
271
+ const CHANUKAH_CANDLES = flags.CHANUKAH_CANDLES;
272
+ const MINOR_FAST = flags.MINOR_FAST;
273
+ const SPECIAL_SHABBAT = flags.SPECIAL_SHABBAT;
274
+ const MODERN_HOLIDAY = flags.MODERN_HOLIDAY;
275
+ const MAJOR_FAST = flags.MAJOR_FAST;
276
+ const ROSH_CHODESH = flags.ROSH_CHODESH;
277
+ const PARSHA_HASHAVUA = flags.PARSHA_HASHAVUA;
278
+ const DAF_YOMI = flags.DAF_YOMI;
279
+ const MISHNA_YOMI = flags.MISHNA_YOMI;
280
+ const NACH_YOMI = flags.NACH_YOMI;
281
+ const YERUSHALMI_YOMI = flags.YERUSHALMI_YOMI;
282
+ const OMER_COUNT = flags.OMER_COUNT;
283
+ const SHABBAT_MEVARCHIM = flags.SHABBAT_MEVARCHIM;
284
+ const MINOR_HOLIDAY = flags.MINOR_HOLIDAY;
285
+ const EREV = flags.EREV;
286
+ const CHOL_HAMOED = flags.CHOL_HAMOED;
287
+ const YOM_KIPPUR_KATAN = flags.YOM_KIPPUR_KATAN;
288
+ const YIZKOR = flags.YIZKOR;
289
+ const unrecognizedAlreadyWarned = new Set();
290
+ const RECOGNIZED_OPTIONS = {
291
+ location: 1,
292
+ year: 1,
293
+ isHebrewYear: 1,
294
+ month: 1,
295
+ numYears: 1,
296
+ start: 1,
297
+ end: 1,
298
+ candlelighting: 1,
299
+ candleLightingMins: 1,
300
+ havdalahMins: 1,
301
+ havdalahDeg: 1,
302
+ fastEndDeg: 1,
303
+ sedrot: 1,
304
+ il: 1,
305
+ noMinorFast: 1,
306
+ noModern: 1,
307
+ shabbatMevarchim: 1,
308
+ noRoshChodesh: 1,
309
+ noSpecialShabbat: 1,
310
+ noHolidays: 1,
311
+ omer: 1,
312
+ molad: 1,
313
+ ashkenazi: 1,
314
+ locale: 1,
315
+ addHebrewDates: 1,
316
+ addHebrewDatesForEvents: 1,
317
+ mask: 1,
318
+ yomKippurKatan: 1,
319
+ hour12: 1,
320
+ dailyLearning: 1,
321
+ useElevation: 1,
322
+ yizkor: 1,
323
+ };
324
+ /**
325
+ * @private
326
+ */
327
+ function warnUnrecognizedOptions(options) {
328
+ for (const k of Object.keys(options)) {
329
+ if (typeof RECOGNIZED_OPTIONS[k] === 'undefined' &&
330
+ !unrecognizedAlreadyWarned.has(k)) {
331
+ console.warn(`Ignoring unrecognized HebrewCalendar option: ${k}`);
332
+ unrecognizedAlreadyWarned.add(k);
333
+ }
334
+ }
335
+ if (options.dailyLearning) {
336
+ for (const k of Object.keys(options.dailyLearning)) {
337
+ if (!unrecognizedAlreadyWarned.has(k) && !DailyLearning.has(k)) {
338
+ console.warn(`Ignoring unrecognized DailyLearning calendar: ${k}`);
339
+ unrecognizedAlreadyWarned.add(k);
340
+ }
341
+ }
342
+ }
343
+ }
344
+ const israelCityOffset = {
345
+ Jerusalem: 40,
346
+ Haifa: 30,
347
+ "Zikhron Ya'aqov": 30,
348
+ "Zikhron Ya'akov": 30,
349
+ 'Zikhron Yaakov': 30,
350
+ "Zichron Ya'akov": 30,
351
+ 'Zichron Yaakov': 30,
352
+ };
353
+ const geoIdCandleOffset = {
354
+ '281184': 40, // Jerusalem
355
+ '294801': 30, // Haifa
356
+ '293067': 30, // Zikhron Yaakov
357
+ };
358
+ /**
359
+ * @private
360
+ * @constant
361
+ * This calculation is based on the position of the sun 36 minutes after sunset in Jerusalem
362
+ * around the equinox / equilux, which is 8.5° below geometric zenith.
363
+ * The Ohr Meir considers this the time that 3 small stars are visible,
364
+ * which is later than the required 3 medium stars.
365
+ * @see {https://kosherjava.com/zmanim/docs/api/com/kosherjava/zmanim/ZmanimCalendar.html#ZENITH_8_POINT_5}
366
+ */
367
+ const TZEIT_3SMALL_STARS = 8.5;
368
+ /**
369
+ * @private
370
+ * @constant
371
+ * This calculation is based on observation of 3 medium sized stars by Dr. Baruch Cohen
372
+ * in his calendar published in in 1899 in Strasbourg, France.
373
+ * This calculates to 7.0833333° below geometric zenith.
374
+ * @see {https://kosherjava.com/zmanim/docs/api/com/kosherjava/zmanim/ComplexZmanimCalendar.html#ZENITH_7_POINT_083}
375
+ */
376
+ const TZEIT_3MEDIUM_STARS = 7.0833333;
377
+ /**
378
+ * Modifies options in-place
379
+ * @private
380
+ */
381
+ function checkCandleOptions(options) {
382
+ if (!options.candlelighting) {
383
+ return;
384
+ }
385
+ const location = options.location;
386
+ if (typeof location === 'undefined' || !(location instanceof Location)) {
387
+ throw new TypeError('options.candlelighting requires valid options.location');
388
+ }
389
+ if (typeof options.havdalahMins === 'number' &&
390
+ typeof options.havdalahDeg === 'number') {
391
+ throw new TypeError('options.havdalahMins and options.havdalahDeg are mutually exclusive');
392
+ }
393
+ const min0 = options.candleLightingMins;
394
+ let min = typeof min0 === 'number' && !isNaN(min0) ? Math.trunc(min0) : 18;
395
+ if (location.getIsrael() && Math.abs(min) === 18) {
396
+ min = overrideIsraelCandleMins(location, min);
397
+ }
398
+ options.candleLightingMins = -1 * Math.abs(min);
399
+ if (typeof options.havdalahMins === 'number') {
400
+ options.havdalahMins = Math.trunc(Math.abs(options.havdalahMins));
401
+ }
402
+ else if (typeof options.havdalahDeg === 'number') {
403
+ options.havdalahDeg = Math.abs(options.havdalahDeg);
404
+ }
405
+ else {
406
+ options.havdalahDeg = TZEIT_3SMALL_STARS;
407
+ }
408
+ if (typeof options.fastEndDeg !== 'number') {
409
+ options.fastEndDeg = TZEIT_3MEDIUM_STARS;
410
+ }
411
+ }
412
+ function overrideIsraelCandleMins(location, min) {
413
+ const geoid = location.getGeoId();
414
+ if (geoid) {
415
+ const offset = geoIdCandleOffset[geoid];
416
+ if (typeof offset === 'number') {
417
+ return offset;
418
+ }
419
+ }
420
+ const shortName = location.getShortName();
421
+ if (shortName) {
422
+ const offset = israelCityOffset[shortName];
423
+ if (typeof offset === 'number') {
424
+ return offset;
425
+ }
426
+ }
427
+ return min;
428
+ }
429
+ /**
430
+ * Mask to filter Holiday array
431
+ * @private
432
+ */
433
+ function getMaskFromOptions(options) {
434
+ var _a;
435
+ if (typeof options.mask === 'number') {
436
+ return setOptionsFromMask(options);
437
+ }
438
+ const il = options.il || ((_a = options.location) === null || _a === void 0 ? void 0 : _a.getIsrael()) || false;
439
+ let mask = 0;
440
+ // default options
441
+ if (!options.noHolidays) {
442
+ mask |=
443
+ ROSH_CHODESH |
444
+ YOM_TOV_ENDS |
445
+ MINOR_FAST |
446
+ SPECIAL_SHABBAT |
447
+ MODERN_HOLIDAY |
448
+ MAJOR_FAST |
449
+ MINOR_HOLIDAY |
450
+ EREV |
451
+ CHOL_HAMOED |
452
+ LIGHT_CANDLES |
453
+ LIGHT_CANDLES_TZEIS |
454
+ CHANUKAH_CANDLES;
455
+ }
456
+ if (options.candlelighting) {
457
+ mask |= LIGHT_CANDLES | LIGHT_CANDLES_TZEIS | YOM_TOV_ENDS;
458
+ }
459
+ // suppression of defaults
460
+ if (options.noRoshChodesh) {
461
+ mask &= ~ROSH_CHODESH;
462
+ }
463
+ if (options.noModern) {
464
+ mask &= ~MODERN_HOLIDAY;
465
+ }
466
+ if (options.noMinorFast) {
467
+ mask &= ~MINOR_FAST;
468
+ }
469
+ if (options.noSpecialShabbat) {
470
+ mask &= ~SPECIAL_SHABBAT;
471
+ mask &= ~SHABBAT_MEVARCHIM;
472
+ }
473
+ if (il) {
474
+ mask |= IL_ONLY;
475
+ }
476
+ else {
477
+ mask |= CHUL_ONLY;
478
+ }
479
+ // non-default options
480
+ if (options.sedrot) {
481
+ mask |= PARSHA_HASHAVUA;
482
+ }
483
+ if (options.omer) {
484
+ mask |= OMER_COUNT;
485
+ }
486
+ if (options.shabbatMevarchim) {
487
+ mask |= SHABBAT_MEVARCHIM;
488
+ }
489
+ if (options.yomKippurKatan) {
490
+ mask |= YOM_KIPPUR_KATAN;
491
+ }
492
+ if (options.yizkor) {
493
+ mask |= YIZKOR;
494
+ }
495
+ const dailyLearning = options.dailyLearning;
496
+ if (typeof dailyLearning === 'object' && dailyLearning !== null) {
497
+ if (dailyLearning.dafYomi) {
498
+ mask |= DAF_YOMI;
499
+ }
500
+ if (dailyLearning.mishnaYomi) {
501
+ mask |= MISHNA_YOMI;
502
+ }
503
+ if (dailyLearning.nachYomi) {
504
+ mask |= NACH_YOMI;
505
+ }
506
+ if (dailyLearning.yerushalmi) {
507
+ mask |= YERUSHALMI_YOMI;
508
+ }
509
+ }
510
+ return mask;
511
+ }
512
+ const MASK_LIGHT_CANDLES = LIGHT_CANDLES | LIGHT_CANDLES_TZEIS | CHANUKAH_CANDLES | YOM_TOV_ENDS;
513
+ const defaultLocation = new Location(0, 0, false, 'UTC');
514
+ /**
515
+ * @private
516
+ */
517
+ function setOptionsFromMask(options) {
518
+ const m = options.mask || 0;
519
+ if (m & ROSH_CHODESH)
520
+ delete options.noRoshChodesh;
521
+ if (m & MODERN_HOLIDAY)
522
+ delete options.noModern;
523
+ if (m & MINOR_FAST)
524
+ delete options.noMinorFast;
525
+ if (m & SPECIAL_SHABBAT)
526
+ delete options.noSpecialShabbat;
527
+ if (m & PARSHA_HASHAVUA)
528
+ options.sedrot = true;
529
+ if (m & (DAF_YOMI | MISHNA_YOMI | NACH_YOMI | YERUSHALMI_YOMI)) {
530
+ options.dailyLearning = options.dailyLearning || {};
531
+ if (m & DAF_YOMI) {
532
+ options.dailyLearning.dafYomi = true;
533
+ }
534
+ if (m & MISHNA_YOMI) {
535
+ options.dailyLearning.mishnaYomi = true;
536
+ }
537
+ if (m & NACH_YOMI) {
538
+ options.dailyLearning.nachYomi = true;
539
+ }
540
+ if (m & YERUSHALMI_YOMI) {
541
+ options.dailyLearning.yerushalmi = 1;
542
+ }
543
+ }
544
+ if (m & OMER_COUNT)
545
+ options.omer = true;
546
+ if (m & SHABBAT_MEVARCHIM)
547
+ options.shabbatMevarchim = true;
548
+ if (m & YOM_KIPPUR_KATAN)
549
+ options.yomKippurKatan = true;
550
+ if (m & YIZKOR)
551
+ options.yizkor = true;
552
+ return m;
553
+ }
554
+ /**
555
+ * Appends the Event `ev` to the `events` array. Also may add related
556
+ * timed events like candle-lighting or fast start/end
557
+ * @private
558
+ */
559
+ function appendHolidayAndRelated(candlesEv, events, ev, options, isFriday, isSaturday, hasUserMask) {
560
+ const il = options.il || false;
561
+ if (!ev.observedIn(il)) {
562
+ return candlesEv; // holiday isn't observed here; bail out early
563
+ }
564
+ const eFlags = ev.getFlags();
565
+ if ((!options.yomKippurKatan && eFlags & YOM_KIPPUR_KATAN) ||
566
+ (options.noModern && eFlags & MODERN_HOLIDAY)) {
567
+ return candlesEv; // bail out early
568
+ }
569
+ const isMajorFast = Boolean(eFlags & MAJOR_FAST);
570
+ const isMinorFast = Boolean(eFlags & MINOR_FAST);
571
+ let fastEv;
572
+ if (options.candlelighting &&
573
+ (isMajorFast || isMinorFast) &&
574
+ ev.getDesc() !== 'Yom Kippur') {
575
+ ev = fastEv = makeFastStartEnd(ev, options);
576
+ if (fastEv.startEvent &&
577
+ (isMajorFast || (isMinorFast && !options.noMinorFast))) {
578
+ events.push(fastEv.startEvent);
579
+ }
580
+ }
581
+ if (eFlags & Number(options.mask) || (!eFlags && !hasUserMask)) {
582
+ if (options.candlelighting && eFlags & MASK_LIGHT_CANDLES) {
583
+ const hd = ev.getDate();
584
+ candlesEv = makeCandleEvent(ev, hd, options, isFriday, isSaturday);
585
+ if (eFlags & CHANUKAH_CANDLES && candlesEv && !options.noHolidays) {
586
+ // Replace Chanukah event with a clone that includes candle lighting time.
587
+ // For clarity, allow a "duplicate" candle lighting event to remain for Shabbat
588
+ const chanukahEv = makeWeekdayChanukahCandleLighting(ev, options);
589
+ if (chanukahEv) {
590
+ if (isFriday || isSaturday) {
591
+ chanukahEv.eventTime = candlesEv.eventTime;
592
+ chanukahEv.eventTimeStr = candlesEv.eventTimeStr;
593
+ }
594
+ ev = chanukahEv;
595
+ }
596
+ candlesEv = undefined;
597
+ }
598
+ }
599
+ if (!options.noHolidays ||
600
+ (options.yomKippurKatan && eFlags & YOM_KIPPUR_KATAN)) {
601
+ events.push(ev); // the original event itself
602
+ }
603
+ }
604
+ if ((isMajorFast || (isMinorFast && !options.noMinorFast)) &&
605
+ fastEv &&
606
+ fastEv.endEvent) {
607
+ events.push(fastEv.endEvent);
608
+ }
609
+ return candlesEv;
610
+ }
611
+ function makeMoladAndMevarchimChodesh(hd, options) {
612
+ const evts = [];
613
+ const hmonth = hd.getMonth();
614
+ const hdate = hd.getDate();
615
+ if (hmonth !== ELUL && hdate >= 23 && hdate <= 29) {
616
+ const hyear = hd.getFullYear();
617
+ const monNext = hmonth === HDate.monthsInYear(hyear) ? NISAN : hmonth + 1;
618
+ if (options.molad) {
619
+ evts.push(new MoladEvent(hd, hyear, monNext, options));
620
+ }
621
+ if (options.shabbatMevarchim) {
622
+ const nextMonthName = HDate.getMonthName(monNext, hyear);
623
+ const molad = new Molad(hyear, monNext);
624
+ const memo = molad.render(options.locale || 'en', options);
625
+ evts.push(new MevarchimChodeshEvent(hd, nextMonthName, memo, options.locale));
626
+ }
627
+ }
628
+ return evts;
629
+ }
630
+ function dailyLearningName(key, val) {
631
+ if (key === 'yerushalmi') {
632
+ return val === 2 ? 'yerushalmi-schottenstein' : 'yerushalmi-vilna';
633
+ }
634
+ return key;
635
+ }
636
+ function makeDailyLearning(hd, dailyLearning, il) {
637
+ const evts = [];
638
+ for (const [key, val] of Object.entries(dailyLearning)) {
639
+ if (val) {
640
+ const name = dailyLearningName(key, val);
641
+ const learningEv = DailyLearning.lookup(name, hd, il);
642
+ if (learningEv) {
643
+ evts.push(learningEv);
644
+ }
645
+ }
646
+ }
647
+ return evts;
648
+ }
649
+ function makeOmerEvent(hd, omerDay, options) {
650
+ const omerEv = new OmerEvent(hd, omerDay);
651
+ if (options.candlelighting) {
652
+ const location = options.location;
653
+ const zmanim = new Zmanim(location, hd.prev(), false);
654
+ const tzeit = zmanim.tzeit(7.0833);
655
+ if (!isNaN(tzeit.getTime())) {
656
+ omerEv.alarm = tzeit;
657
+ }
658
+ }
659
+ return omerEv;
660
+ }
@@ -0,0 +1,44 @@
1
+ import { HDate } from '@hebcal/hdate';
2
+ import { CalOptions } from './CalOptions';
3
+ import { Location } from './location';
4
+ import { Event } from './event';
5
+ import { ChanukahEvent, HolidayEvent } from './HolidayEvent';
6
+ import { TimedEvent } from './TimedEvent';
7
+ /**
8
+ * @private
9
+ */
10
+ export declare function makeCandleEvent(ev: Event | undefined, hd: HDate, options: CalOptions, isFriday: boolean, isSaturday: boolean): TimedEvent | undefined;
11
+ /** A fast day also contains a start and end time */
12
+ export declare class FastDayEvent extends HolidayEvent {
13
+ /** original event */
14
+ readonly linkedEvent: HolidayEvent;
15
+ /** this will be a "Fast begins" event */
16
+ readonly startEvent?: TimedEvent;
17
+ /** this will be a "Fast ends" event */
18
+ readonly endEvent?: TimedEvent;
19
+ constructor(linkedEvent: HolidayEvent, startEvent?: TimedEvent, endEvent?: TimedEvent);
20
+ render(locale?: string): string;
21
+ renderBrief(locale?: string): string;
22
+ urlDateSuffix(): string;
23
+ url(): string | undefined;
24
+ getEmoji(): string;
25
+ getCategories(): string[];
26
+ }
27
+ /**
28
+ * Makes a pair of events representing fast start and end times
29
+ * @private
30
+ */
31
+ export declare function makeFastStartEnd(ev: HolidayEvent, options: CalOptions): FastDayEvent;
32
+ export declare class TimedChanukahEvent extends ChanukahEvent {
33
+ eventTime: Date;
34
+ eventTimeStr: string;
35
+ readonly location: Location;
36
+ constructor(ev: ChanukahEvent, eventTime: Date, location: Location);
37
+ }
38
+ /**
39
+ * Makes a candle-lighting event for Chankah (not on Friday/Saturday).
40
+ * At one point this used civil dusk (6 degrees below horizon).
41
+ * Another source suggests 4.6667 degrees below horizon.
42
+ * @private
43
+ */
44
+ export declare function makeWeekdayChanukahCandleLighting(ev: ChanukahEvent, options: CalOptions): TimedChanukahEvent | null;