@hebcal/core 6.16.1 → 6.17.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (73) hide show
  1. package/dist/bundle.js +530 -381
  2. package/dist/bundle.js.map +1 -1
  3. package/dist/bundle.min.js +7 -7
  4. package/dist/bundle.min.js.map +1 -1
  5. package/dist/esm/DailyLearning.js +1 -1
  6. package/dist/esm/HebrewDateEvent.js +1 -1
  7. package/dist/esm/HolidayEvent.js +1 -1
  8. package/dist/esm/KiddushLevanaEvent.js +3 -4
  9. package/dist/esm/KiddushLevanaEvent.js.map +1 -1
  10. package/dist/esm/MevarchimChodeshEvent.js +3 -3
  11. package/dist/esm/MevarchimChodeshEvent.js.map +1 -1
  12. package/dist/esm/ParshaEvent.js +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.d.ts +6 -0
  17. package/dist/esm/calendar.js +84 -11
  18. package/dist/esm/calendar.js.map +1 -1
  19. package/dist/esm/candles.js +4 -2
  20. package/dist/esm/candles.js.map +1 -1
  21. package/dist/esm/cities.json.js +1 -1
  22. package/dist/esm/event.js +7 -3
  23. package/dist/esm/event.js.map +1 -1
  24. package/dist/esm/getStartAndEnd.js +2 -2
  25. package/dist/esm/getStartAndEnd.js.map +1 -1
  26. package/dist/esm/hallel.js +3 -3
  27. package/dist/esm/hallel.js.map +1 -1
  28. package/dist/esm/he-x-NoNikud.po.js +1 -1
  29. package/dist/esm/he.po.js +1 -1
  30. package/dist/esm/hebcal.js +3 -6
  31. package/dist/esm/hebcal.js.map +1 -1
  32. package/dist/esm/holidays.d.ts +17 -0
  33. package/dist/esm/holidays.js +91 -34
  34. package/dist/esm/holidays.js.map +1 -1
  35. package/dist/esm/horizon.js +1 -1
  36. package/dist/esm/index.d.ts +1 -0
  37. package/dist/esm/index.js +2 -1
  38. package/dist/esm/index.js.map +1 -1
  39. package/dist/esm/isAssurBemlacha.js +7 -23
  40. package/dist/esm/isAssurBemlacha.js.map +1 -1
  41. package/dist/esm/isAveilut.js +1 -1
  42. package/dist/esm/isFastDay.js +1 -1
  43. package/dist/esm/isYomTov.d.ts +21 -0
  44. package/dist/esm/isYomTov.js +46 -0
  45. package/dist/esm/isYomTov.js.map +1 -0
  46. package/dist/esm/locale.js +1 -1
  47. package/dist/esm/location.js +3 -3
  48. package/dist/esm/location.js.map +1 -1
  49. package/dist/esm/modern.js +1 -1
  50. package/dist/esm/molad.js +3 -3
  51. package/dist/esm/molad.js.map +1 -1
  52. package/dist/esm/moladBase.js +1 -1
  53. package/dist/esm/moladDate.js +1 -1
  54. package/dist/esm/omer.js +1 -1
  55. package/dist/esm/parshaName.js +1 -1
  56. package/dist/esm/parshaYear.js +3 -3
  57. package/dist/esm/parshaYear.js.map +1 -1
  58. package/dist/esm/pkgVersion.d.ts +1 -1
  59. package/dist/esm/pkgVersion.js +2 -2
  60. package/dist/esm/pkgVersion.js.map +1 -1
  61. package/dist/esm/reformatTimeStr.js +2 -2
  62. package/dist/esm/reformatTimeStr.js.map +1 -1
  63. package/dist/esm/sedra.js +6 -6
  64. package/dist/esm/sedra.js.map +1 -1
  65. package/dist/esm/sefira.json.js +1 -1
  66. package/dist/esm/staticHolidays.js +1 -1
  67. package/dist/esm/string.js +1 -1
  68. package/dist/esm/tachanun.js +8 -8
  69. package/dist/esm/tachanun.js.map +1 -1
  70. package/dist/esm/zenith.js +1 -1
  71. package/dist/esm/zmanim.js +4 -4
  72. package/dist/esm/zmanim.js.map +1 -1
  73. package/package.json +8 -8
@@ -1,4 +1,4 @@
1
- /*! @hebcal/core v6.16.1, distributed under GPLv2 or later https://www.gnu.org/licenses/gpl-2.0.txt */
1
+ /*! @hebcal/core v6.17.0, distributed under GPLv2 or later https://www.gnu.org/licenses/gpl-2.0.txt */
2
2
  import { months } from '@hebcal/hdate';
3
3
  import { flags } from './event.js';
4
4
  import { HolidayEvent, ChanukahEvent } from './HolidayEvent.js';
@@ -67,7 +67,9 @@ const MINOR_FAST_END_MINUTES_IL = 15;
67
67
  * Returns `val` when it is a finite nonzero number, otherwise `undefined`
68
68
  */
69
69
  function nonzero(val) {
70
- return typeof val === 'number' && isFinite(val) && val !== 0 ? val : undefined;
70
+ return typeof val === 'number' && Number.isFinite(val) && val !== 0
71
+ ? val
72
+ : undefined;
71
73
  }
72
74
  /**
73
75
  * Computes the "Fast begins" time for a minor fast (one that begins at dawn).
@@ -1 +1 @@
1
- {"version":3,"file":"candles.js","sources":["../../../src/candles.ts"],"sourcesContent":["import {HDate, months} from '@hebcal/hdate';\nimport {CalOptions} from './CalOptions.js';\nimport {Location} from './location.js';\nimport {Event, flags} from './event.js';\nimport {ChanukahEvent, HolidayEvent} from './HolidayEvent.js';\nimport {Zmanim} from './zmanim.js';\nimport {TimedEvent, CandleLightingEvent, HavdalahEvent} from './TimedEvent.js';\nimport {holidayDesc as hdesc} from './staticHolidays.js';\nimport {DEG_6_POINT_45, DEG_7_POINT_083, DEG_16_POINT_1} from './zenith.js';\n\nconst {LIGHT_CANDLES, LIGHT_CANDLES_TZEIS} = flags;\nconst {FAST_BEGINS, FAST_ENDS} = hdesc;\n\n/** @internal */\nexport function makeCandleEvent(\n ev: Event | undefined,\n hd: HDate,\n options: CalOptions,\n isFriday: boolean,\n isSaturday: boolean\n): TimedEvent | undefined {\n let havdalahTitle = false;\n let useHavdalahOffset = isSaturday;\n let mask = ev ? ev.mask : LIGHT_CANDLES;\n if (ev !== undefined) {\n // if linked event && dow == FRI, use Candle lighting time & title\n if (!isFriday) {\n if (ev.hasAnyFlag('LIGHT_CANDLES_TZEIS', 'CHANUKAH_CANDLES')) {\n useHavdalahOffset = true;\n } else if (ev.hasFlag('YOM_TOV_ENDS')) {\n havdalahTitle = true;\n useHavdalahOffset = true;\n }\n }\n } else if (isSaturday) {\n havdalahTitle = true;\n mask = LIGHT_CANDLES_TZEIS;\n }\n // if Havdalah offset is 0 or undefined, we'll use tzeit time\n const offset = useHavdalahOffset\n ? Number(options.havdalahMins)\n : Number(options.candleLightingMins);\n const location = options.location as Location;\n const useElevation = Boolean(options.useElevation);\n const zmanim = new Zmanim(location, hd, useElevation);\n const time =\n useHavdalahOffset && !offset\n ? zmanim.tzeit(options.havdalahDeg)\n : zmanim.sunsetOffset(offset, true);\n if (Number.isNaN(time.getTime())) {\n return undefined; // no sunset\n }\n if (havdalahTitle) {\n return new HavdalahEvent(\n hd,\n mask,\n time,\n location,\n options.havdalahMins,\n ev,\n options\n );\n } else {\n // Exactly one of the two candle-lighting flags, chosen by how the time\n // was computed: LIGHT_CANDLES for minutes before sunset (Shabbat or the\n // start of a chag), LIGHT_CANDLES_TZEIS for nightfall / Havdalah time\n // (the second night of Yom Tov, or a chag that begins Saturday night).\n mask = useHavdalahOffset\n ? (mask & ~LIGHT_CANDLES) | LIGHT_CANDLES_TZEIS\n : (mask & ~LIGHT_CANDLES_TZEIS) | LIGHT_CANDLES;\n return new CandleLightingEvent(hd, mask, time, location, ev, options);\n }\n}\n\n/**\n * Minutes after sunset that minor fasts (including Yom Kippur Katan) end in\n * Israel by default, following Rabbi Deblitzky's practice.\n * @see {https://www.yeshiva.org.il/calendar/timeprinciples}\n */\nconst MINOR_FAST_END_MINUTES_IL = 15;\n\n/**\n * Returns `val` when it is a finite nonzero number, otherwise `undefined`\n */\nfunction nonzero(val: number | undefined): number | undefined {\n return typeof val === 'number' && isFinite(val) && val !== 0 ? val : undefined;\n}\n\n/**\n * Computes the \"Fast begins\" time for a minor fast (one that begins at dawn).\n *\n * When `options.fastStartMins` is a nonzero number, the fast begins that many\n * minutes before sunrise; otherwise, when `options.fastStartDeg` is a nonzero\n * number, the fast begins when the sun is that many degrees below the horizon\n * in the morning. By default, minor fasts begin at Alot HaShachar (16.1°).\n */\nfunction makeFastStartTime(zmanim: Zmanim, options: CalOptions): Date {\n const fastStartMins = nonzero(options.fastStartMins);\n if (fastStartMins !== undefined) {\n return zmanim.sunriseOffset(-Math.abs(fastStartMins), true);\n }\n const fastStartDeg = nonzero(options.fastStartDeg);\n return zmanim.timeAtAngle(\n fastStartDeg === undefined ? DEG_16_POINT_1 : Math.abs(fastStartDeg),\n true\n );\n}\n\n/**\n * Computes the \"Fast ends\" time for a fast day.\n *\n * Tish'a B'Av ends `options.tishaBavEndMins` minutes after sunset or at tzeit\n * `options.tishaBavEndDeg` when either is a nonzero number, and otherwise at\n * tzeit 6.45° (Rabbi Yechiel Michel Tucazinsky). It is not affected by\n * `options.fastEndDeg`, `options.fastEndMins` or `options.il`.\n *\n * For minor fasts: when `options.fastEndMins` is a nonzero number, the fast\n * ends that many minutes after sunset; otherwise, when `options.fastEndDeg` is\n * a nonzero number, the fast ends at tzeit for that solar depression angle.\n * When neither is specified, the default depends on `options.il`:\n * - In Israel, minor fasts end 15 minutes after sunset (Rabbi Deblitzky's practice).\n * - Elsewhere, minor fasts end at tzeit 7.083° (3 medium-sized stars).\n */\nfunction makeFastEndTime(\n zmanim: Zmanim,\n isTishaBav: boolean,\n options: CalOptions\n): Date {\n if (isTishaBav) {\n const tishaBavEndMins = nonzero(options.tishaBavEndMins);\n if (tishaBavEndMins !== undefined) {\n return zmanim.sunsetOffset(Math.abs(tishaBavEndMins), true);\n }\n const tishaBavEndDeg = nonzero(options.tishaBavEndDeg);\n return zmanim.tzeit(\n tishaBavEndDeg === undefined ? DEG_6_POINT_45 : Math.abs(tishaBavEndDeg)\n );\n }\n const fastEndMins = options.fastEndMins;\n if (typeof fastEndMins === 'number' && fastEndMins !== 0) {\n return zmanim.sunsetOffset(Math.abs(fastEndMins), true);\n }\n const fastEndDeg = options.fastEndDeg;\n if (typeof fastEndDeg === 'number' && fastEndDeg !== 0) {\n return zmanim.tzeit(Math.abs(fastEndDeg));\n }\n if (options.il) {\n return zmanim.sunsetOffset(MINOR_FAST_END_MINUTES_IL, true);\n }\n return zmanim.tzeit(DEG_7_POINT_083);\n}\n\n/**\n * A fast day holiday with attached start and end time events.\n *\n * Wraps an underlying fast-day {@link HolidayEvent} and (when computable\n * for the given location) exposes a \"Fast begins\" and \"Fast ends\"\n * {@link TimedEvent}. Generated by {@link calendar} when\n * `options.candlelighting` is `true` and `options.location` is provided.\n *\n * - Minor fasts (including Yom Kippur Katan) begin at *Alot HaShachar*\n * (16.1° below horizon in the morning), which can be overridden via\n * `options.fastStartDeg` or `options.fastStartMins`. By default they end at\n * tzeit 7.083° (3 medium-sized stars) in the Diaspora, or 15 minutes after\n * sunset in Israel (Rabbi Deblitzky's practice). This can be overridden\n * via `options.fastEndDeg` or `options.fastEndMins`.\n * - Tish'a B'Av begins at sunset on the previous day, regardless of\n * `options.fastStartDeg` / `options.fastStartMins`. By default it ends at\n * tzeit 6.45° below horizon (Rabbi Yechiel Michel Tucazinsky), which can be\n * overridden via `options.tishaBavEndDeg` or `options.tishaBavEndMins`\n * (but not by `options.fastEndDeg` / `options.fastEndMins`).\n * - When a minor fast falls on a Friday, the end time is suppressed\n * (Shabbat begins before nightfall).\n */\nexport class FastDayEvent extends HolidayEvent {\n /** original event */\n readonly linkedEvent: HolidayEvent;\n /** this will be a \"Fast begins\" event */\n readonly startEvent?: TimedEvent;\n /** this will be a \"Fast ends\" event */\n readonly endEvent?: TimedEvent;\n constructor(\n linkedEvent: HolidayEvent,\n startEvent?: TimedEvent,\n endEvent?: TimedEvent\n ) {\n super(linkedEvent.getDate(), linkedEvent.getDesc(), linkedEvent.mask);\n this.linkedEvent = linkedEvent;\n this.startEvent = startEvent;\n this.endEvent = endEvent;\n }\n override render(locale?: string): string {\n return this.linkedEvent.render(locale);\n }\n override renderBrief(locale?: string): string {\n return this.linkedEvent.renderBrief(locale);\n }\n override urlDateSuffix(): string {\n return this.linkedEvent.urlDateSuffix();\n }\n override url(): string | undefined {\n return this.linkedEvent.url();\n }\n override getEmoji(): string {\n return this.linkedEvent.getEmoji();\n }\n override getCategories(): string[] {\n return this.linkedEvent.getCategories();\n }\n}\n\n/**\n * Makes a pair of events representing fast start and end times\n * @internal\n */\nexport function makeFastStartEnd(\n ev: HolidayEvent,\n options: CalOptions\n): FastDayEvent {\n const desc = ev.getDesc();\n if (desc === 'Yom Kippur') {\n throw new RangeError('YK does not require this function');\n }\n const hd = ev.getDate();\n const dt = hd.greg();\n const location = options.location as Location;\n const useElevation = Boolean(options.useElevation);\n const zmanim = new Zmanim(location, dt, useElevation);\n let startEvent: TimedEvent | undefined;\n let endEvent: TimedEvent | undefined;\n if (desc === \"Erev Tish'a B'Av\") {\n const sunset = zmanim.sunset();\n if (!Number.isNaN(sunset.getTime())) {\n startEvent = makeTimedEvent(ev, sunset, FAST_BEGINS, options);\n }\n } else if (desc.startsWith(\"Tish'a B'Av\")) {\n const fastEnd = makeFastEndTime(zmanim, true, options);\n if (!Number.isNaN(fastEnd.getTime())) {\n endEvent = makeTimedEvent(ev, fastEnd, FAST_ENDS, options);\n }\n } else {\n const fastStart = makeFastStartTime(zmanim, options);\n if (!Number.isNaN(fastStart.getTime())) {\n startEvent = makeTimedEvent(ev, fastStart, FAST_BEGINS, options);\n }\n if (\n dt.getDay() !== 5 &&\n !(hd.getDate() === 14 && hd.getMonth() === months.NISAN)\n ) {\n const fastEnd = makeFastEndTime(zmanim, false, options);\n if (!Number.isNaN(fastEnd.getTime())) {\n endEvent = makeTimedEvent(ev, fastEnd, FAST_ENDS, options);\n }\n }\n }\n const ev2 = new FastDayEvent(ev, startEvent, endEvent);\n // copy properties such as memo or emoji\n Object.assign(ev2, ev);\n return ev2;\n}\n\nfunction makeTimedEvent(\n ev: Event,\n time: Date,\n desc: string,\n options: CalOptions\n): TimedEvent {\n const location = options.location as Location;\n const hd = ev.getDate();\n return new TimedEvent(hd, desc, ev.mask, time, location, ev, options);\n}\n\n/**\n * A Chanukah candle-lighting event that carries a specific time of day.\n *\n * Generated by {@link calendar} when both `options.candlelighting`\n * and `options.location` are set. On weekdays the time is Bein HaShmashos\n * (13.5 minutes before the sun is 7.083° below the horizon in the evening);\n * on Friday it is regular candle-lighting time, and on Saturday night it is\n * regular Havdalah time.\n */\nexport class TimedChanukahEvent extends ChanukahEvent {\n /** Time at which candles are lit, rounded to the nearest minute */\n eventTime: Date;\n /** {@link eventTime} formatted for the event's location, e.g. `'4:31pm'` */\n eventTimeStr: string;\n /** Location used to calculate {@link eventTime} */\n readonly location: Location;\n /**\n * Normally created by {@link calendar} rather than directly.\n * @param ev the untimed Chanukah event this is derived from\n * @param eventTime time at which candles are lit\n * @param location location used to format the time\n */\n constructor(ev: ChanukahEvent, eventTime: Date, location: Location) {\n super(ev.getDate(), ev.getDesc(), ev.mask, ev.chanukahDay);\n this.eventTime = Zmanim.roundTime(eventTime);\n const timeFormat = location.getTimeFormatter();\n this.eventTimeStr = Zmanim.formatTime(this.eventTime, timeFormat);\n this.location = location;\n this.emoji = ev.emoji;\n }\n}\n\n/**\n * Makes a candle-lighting event for Chankah (not on Friday/Saturday).\n * At one point this used civil dusk (6 degrees below horizon).\n * Another source suggests 4.6667 degrees below horizon.\n * @internal\n */\nexport function makeWeekdayChanukahCandleLighting(\n ev: ChanukahEvent,\n options: CalOptions\n): TimedChanukahEvent | null {\n const hd = ev.getDate();\n const location = options.location as Location;\n const useElevation = Boolean(options.useElevation);\n const zmanim = new Zmanim(location, hd.greg(), useElevation);\n const candleLightingTime = zmanim.beinHaShmashos();\n if (Number.isNaN(candleLightingTime.getTime())) {\n return null;\n }\n return new TimedChanukahEvent(ev, candleLightingTime, location);\n}\n"],"names":["hdesc"],"mappings":";;;;;;;;;AAUA,MAAM,EAAC,aAAa,EAAE,mBAAmB,EAAC,GAAG,KAAK;AAClD,MAAM,EAAC,WAAW,EAAE,SAAS,EAAC,GAAGA,WAAK;AAEtC;AACM,SAAU,eAAe,CAC7B,EAAqB,EACrB,EAAS,EACT,OAAmB,EACnB,QAAiB,EACjB,UAAmB,EAAA;IAEnB,IAAI,aAAa,GAAG,KAAK;IACzB,IAAI,iBAAiB,GAAG,UAAU;AAClC,IAAA,IAAI,IAAI,GAAG,EA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AI,EAAE,EAAE,YAAY,CAAC;AAC5D,IAAA,MAAM,kBAAkB,GAAG,MAAM,CAAC,cAAc,EAAE;IAClD,IAAI,MAAM,CAAC,KAAK,CAAC,kBAAkB,CAAC,OAAO,EAAE,CAAC,EAAE;AAC9C,QAAA,OAAO,IAAI;IACb;IACA,OAAO,IAAI,kBAAkB,CAAC,EAAE,EAAE,kBAAkB,EAAE,QAAQ,CAAC;AACjE;;"}
1
+ {"version":3,"file":"candles.js","sources":["../../../src/candles.ts"],"sourcesContent":["import {HDate, months} from '@hebcal/hdate';\nimport {CalOptions} from './CalOptions.js';\nimport {Location} from './location.js';\nimport {Event, flags} from './event.js';\nimport {ChanukahEvent, HolidayEvent} from './HolidayEvent.js';\nimport {Zmanim} from './zmanim.js';\nimport {TimedEvent, CandleLightingEvent, HavdalahEvent} from './TimedEvent.js';\nimport {holidayDesc as hdesc} from './staticHolidays.js';\nimport {DEG_6_POINT_45, DEG_7_POINT_083, DEG_16_POINT_1} from './zenith.js';\n\nconst {LIGHT_CANDLES, LIGHT_CANDLES_TZEIS} = flags;\nconst {FAST_BEGINS, FAST_ENDS} = hdesc;\n\n/** @internal */\nexport function makeCandleEvent(\n ev: Event | undefined,\n hd: HDate,\n options: CalOptions,\n isFriday: boolean,\n isSaturday: boolean\n): TimedEvent | undefined {\n let havdalahTitle = false;\n let useHavdalahOffset = isSaturday;\n let mask = ev ? ev.mask : LIGHT_CANDLES;\n if (ev !== undefined) {\n // if linked event && dow == FRI, use Candle lighting time & title\n if (!isFriday) {\n if (ev.hasAnyFlag('LIGHT_CANDLES_TZEIS', 'CHANUKAH_CANDLES')) {\n useHavdalahOffset = true;\n } else if (ev.hasFlag('YOM_TOV_ENDS')) {\n havdalahTitle = true;\n useHavdalahOffset = true;\n }\n }\n } else if (isSaturday) {\n havdalahTitle = true;\n mask = LIGHT_CANDLES_TZEIS;\n }\n // if Havdalah offset is 0 or undefined, we'll use tzeit time\n const offset = useHavdalahOffset\n ? Number(options.havdalahMins)\n : Number(options.candleLightingMins);\n const location = options.location as Location;\n const useElevation = Boolean(options.useElevation);\n const zmanim = new Zmanim(location, hd, useElevation);\n const time =\n useHavdalahOffset && !offset\n ? zmanim.tzeit(options.havdalahDeg)\n : zmanim.sunsetOffset(offset, true);\n if (Number.isNaN(time.getTime())) {\n return undefined; // no sunset\n }\n if (havdalahTitle) {\n return new HavdalahEvent(\n hd,\n mask,\n time,\n location,\n options.havdalahMins,\n ev,\n options\n );\n } else {\n // Exactly one of the two candle-lighting flags, chosen by how the time\n // was computed: LIGHT_CANDLES for minutes before sunset (Shabbat or the\n // start of a chag), LIGHT_CANDLES_TZEIS for nightfall / Havdalah time\n // (the second night of Yom Tov, or a chag that begins Saturday night).\n mask = useHavdalahOffset\n ? (mask & ~LIGHT_CANDLES) | LIGHT_CANDLES_TZEIS\n : (mask & ~LIGHT_CANDLES_TZEIS) | LIGHT_CANDLES;\n return new CandleLightingEvent(hd, mask, time, location, ev, options);\n }\n}\n\n/**\n * Minutes after sunset that minor fasts (including Yom Kippur Katan) end in\n * Israel by default, following Rabbi Deblitzky's practice.\n * @see {https://www.yeshiva.org.il/calendar/timeprinciples}\n */\nconst MINOR_FAST_END_MINUTES_IL = 15;\n\n/**\n * Returns `val` when it is a finite nonzero number, otherwise `undefined`\n */\nfunction nonzero(val: number | undefined): number | undefined {\n return typeof val === 'number' && Number.isFinite(val) && val !== 0\n ? val\n : undefined;\n}\n\n/**\n * Computes the \"Fast begins\" time for a minor fast (one that begins at dawn).\n *\n * When `options.fastStartMins` is a nonzero number, the fast begins that many\n * minutes before sunrise; otherwise, when `options.fastStartDeg` is a nonzero\n * number, the fast begins when the sun is that many degrees below the horizon\n * in the morning. By default, minor fasts begin at Alot HaShachar (16.1°).\n */\nfunction makeFastStartTime(zmanim: Zmanim, options: CalOptions): Date {\n const fastStartMins = nonzero(options.fastStartMins);\n if (fastStartMins !== undefined) {\n return zmanim.sunriseOffset(-Math.abs(fastStartMins), true);\n }\n const fastStartDeg = nonzero(options.fastStartDeg);\n return zmanim.timeAtAngle(\n fastStartDeg === undefined ? DEG_16_POINT_1 : Math.abs(fastStartDeg),\n true\n );\n}\n\n/**\n * Computes the \"Fast ends\" time for a fast day.\n *\n * Tish'a B'Av ends `options.tishaBavEndMins` minutes after sunset or at tzeit\n * `options.tishaBavEndDeg` when either is a nonzero number, and otherwise at\n * tzeit 6.45° (Rabbi Yechiel Michel Tucazinsky). It is not affected by\n * `options.fastEndDeg`, `options.fastEndMins` or `options.il`.\n *\n * For minor fasts: when `options.fastEndMins` is a nonzero number, the fast\n * ends that many minutes after sunset; otherwise, when `options.fastEndDeg` is\n * a nonzero number, the fast ends at tzeit for that solar depression angle.\n * When neither is specified, the default depends on `options.il`:\n * - In Israel, minor fasts end 15 minutes after sunset (Rabbi Deblitzky's practice).\n * - Elsewhere, minor fasts end at tzeit 7.083° (3 medium-sized stars).\n */\nfunction makeFastEndTime(\n zmanim: Zmanim,\n isTishaBav: boolean,\n options: CalOptions\n): Date {\n if (isTishaBav) {\n const tishaBavEndMins = nonzero(options.tishaBavEndMins);\n if (tishaBavEndMins !== undefined) {\n return zmanim.sunsetOffset(Math.abs(tishaBavEndMins), true);\n }\n const tishaBavEndDeg = nonzero(options.tishaBavEndDeg);\n return zmanim.tzeit(\n tishaBavEndDeg === undefined ? DEG_6_POINT_45 : Math.abs(tishaBavEndDeg)\n );\n }\n const fastEndMins = options.fastEndMins;\n if (typeof fastEndMins === 'number' && fastEndMins !== 0) {\n return zmanim.sunsetOffset(Math.abs(fastEndMins), true);\n }\n const fastEndDeg = options.fastEndDeg;\n if (typeof fastEndDeg === 'number' && fastEndDeg !== 0) {\n return zmanim.tzeit(Math.abs(fastEndDeg));\n }\n if (options.il) {\n return zmanim.sunsetOffset(MINOR_FAST_END_MINUTES_IL, true);\n }\n return zmanim.tzeit(DEG_7_POINT_083);\n}\n\n/**\n * A fast day holiday with attached start and end time events.\n *\n * Wraps an underlying fast-day {@link HolidayEvent} and (when computable\n * for the given location) exposes a \"Fast begins\" and \"Fast ends\"\n * {@link TimedEvent}. Generated by {@link calendar} when\n * `options.candlelighting` is `true` and `options.location` is provided.\n *\n * - Minor fasts (including Yom Kippur Katan) begin at *Alot HaShachar*\n * (16.1° below horizon in the morning), which can be overridden via\n * `options.fastStartDeg` or `options.fastStartMins`. By default they end at\n * tzeit 7.083° (3 medium-sized stars) in the Diaspora, or 15 minutes after\n * sunset in Israel (Rabbi Deblitzky's practice). This can be overridden\n * via `options.fastEndDeg` or `options.fastEndMins`.\n * - Tish'a B'Av begins at sunset on the previous day, regardless of\n * `options.fastStartDeg` / `options.fastStartMins`. By default it ends at\n * tzeit 6.45° below horizon (Rabbi Yechiel Michel Tucazinsky), which can be\n * overridden via `options.tishaBavEndDeg` or `options.tishaBavEndMins`\n * (but not by `options.fastEndDeg` / `options.fastEndMins`).\n * - When a minor fast falls on a Friday, the end time is suppressed\n * (Shabbat begins before nightfall).\n */\nexport class FastDayEvent extends HolidayEvent {\n /** original event */\n readonly linkedEvent: HolidayEvent;\n /** this will be a \"Fast begins\" event */\n readonly startEvent?: TimedEvent;\n /** this will be a \"Fast ends\" event */\n readonly endEvent?: TimedEvent;\n constructor(\n linkedEvent: HolidayEvent,\n startEvent?: TimedEvent,\n endEvent?: TimedEvent\n ) {\n super(linkedEvent.getDate(), linkedEvent.getDesc(), linkedEvent.mask);\n this.linkedEvent = linkedEvent;\n this.startEvent = startEvent;\n this.endEvent = endEvent;\n }\n override render(locale?: string): string {\n return this.linkedEvent.render(locale);\n }\n override renderBrief(locale?: string): string {\n return this.linkedEvent.renderBrief(locale);\n }\n override urlDateSuffix(): string {\n return this.linkedEvent.urlDateSuffix();\n }\n override url(): string | undefined {\n return this.linkedEvent.url();\n }\n override getEmoji(): string {\n return this.linkedEvent.getEmoji();\n }\n override getCategories(): string[] {\n return this.linkedEvent.getCategories();\n }\n}\n\n/**\n * Makes a pair of events representing fast start and end times\n * @internal\n */\nexport function makeFastStartEnd(\n ev: HolidayEvent,\n options: CalOptions\n): FastDayEvent {\n const desc = ev.getDesc();\n if (desc === 'Yom Kippur') {\n throw new RangeError('YK does not require this function');\n }\n const hd = ev.getDate();\n const dt = hd.greg();\n const location = options.location as Location;\n const useElevation = Boolean(options.useElevation);\n const zmanim = new Zmanim(location, dt, useElevation);\n let startEvent: TimedEvent | undefined;\n let endEvent: TimedEvent | undefined;\n if (desc === \"Erev Tish'a B'Av\") {\n const sunset = zmanim.sunset();\n if (!Number.isNaN(sunset.getTime())) {\n startEvent = makeTimedEvent(ev, sunset, FAST_BEGINS, options);\n }\n } else if (desc.startsWith(\"Tish'a B'Av\")) {\n const fastEnd = makeFastEndTime(zmanim, true, options);\n if (!Number.isNaN(fastEnd.getTime())) {\n endEvent = makeTimedEvent(ev, fastEnd, FAST_ENDS, options);\n }\n } else {\n const fastStart = makeFastStartTime(zmanim, options);\n if (!Number.isNaN(fastStart.getTime())) {\n startEvent = makeTimedEvent(ev, fastStart, FAST_BEGINS, options);\n }\n if (\n dt.getDay() !== 5 &&\n !(hd.getDate() === 14 && hd.getMonth() === months.NISAN)\n ) {\n const fastEnd = makeFastEndTime(zmanim, false, options);\n if (!Number.isNaN(fastEnd.getTime())) {\n endEvent = makeTimedEvent(ev, fastEnd, FAST_ENDS, options);\n }\n }\n }\n const ev2 = new FastDayEvent(ev, startEvent, endEvent);\n // copy properties such as memo or emoji\n Object.assign(ev2, ev);\n return ev2;\n}\n\nfunction makeTimedEvent(\n ev: Event,\n time: Date,\n desc: string,\n options: CalOptions\n): TimedEvent {\n const location = options.location as Location;\n const hd = ev.getDate();\n return new TimedEvent(hd, desc, ev.mask, time, location, ev, options);\n}\n\n/**\n * A Chanukah candle-lighting event that carries a specific time of day.\n *\n * Generated by {@link calendar} when both `options.candlelighting`\n * and `options.location` are set. On weekdays the time is Bein HaShmashos\n * (13.5 minutes before the sun is 7.083° below the horizon in the evening);\n * on Friday it is regular candle-lighting time, and on Saturday night it is\n * regular Havdalah time.\n */\nexport class TimedChanukahEvent extends ChanukahEvent {\n /** Time at which candles are lit, rounded to the nearest minute */\n eventTime: Date;\n /** {@link eventTime} formatted for the event's location, e.g. `'4:31pm'` */\n eventTimeStr: string;\n /** Location used to calculate {@link eventTime} */\n readonly location: Location;\n /**\n * Normally created by {@link calendar} rather than directly.\n * @param ev the untimed Chanukah event this is derived from\n * @param eventTime time at which candles are lit\n * @param location location used to format the time\n */\n constructor(ev: ChanukahEvent, eventTime: Date, location: Location) {\n super(ev.getDate(), ev.getDesc(), ev.mask, ev.chanukahDay);\n this.eventTime = Zmanim.roundTime(eventTime);\n const timeFormat = location.getTimeFormatter();\n this.eventTimeStr = Zmanim.formatTime(this.eventTime, timeFormat);\n this.location = location;\n this.emoji = ev.emoji;\n }\n}\n\n/**\n * Makes a candle-lighting event for Chankah (not on Friday/Saturday).\n * At one point this used civil dusk (6 degrees below horizon).\n * Another source suggests 4.6667 degrees below horizon.\n * @internal\n */\nexport function makeWeekdayChanukahCandleLighting(\n ev: ChanukahEvent,\n options: CalOptions\n): TimedChanukahEvent | null {\n const hd = ev.getDate();\n const location = options.location as Location;\n const useElevation = Boolean(options.useElevation);\n const zmanim = new Zmanim(location, hd.greg(), useElevation);\n const candleLightingTime = zmanim.beinHaShmashos();\n if (Number.isNaN(candleLightingTime.getTime())) {\n return null;\n }\n return new TimedChanukahEvent(ev, candleLightingTime, location);\n}\n"],"names":["hdesc"],"mappings":";;;;;;;;;AAUA,MAAM,EAAC,aAAa,EAAE,mBAAmB,EAAC,GAAG,KAAK;AAClD,MAAM,EAAC,WAAW,EAAE,SAAS,EAAC,GAAGA,WAAK;AAEtC;AACM,SAAU,eAAe,CAC7B,EAAqB,EACrB,EAAS,EACT,OAAmB,EACnB,QAAiB,EACjB,UAAmB,EAAA;IAEnB,IAAI,aAAa,GAAG,KAAK;IACzB,IAAI,iBAAiB,GAAG,UAAU;AAClC,IAAA,IAAI,IAAI,GAAG,EAAE,GAAG,EAAE,CAAC,IAAI,GAAG,aAAa;AACvC,IAAA,IAAI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kBAAkB,GAAG,MAAM,CAAC,cAAc,EAAE;IAClD,IAAI,MAAM,CAAC,KAAK,CAAC,kBAAkB,CAAC,OAAO,EAAE,CAAC,EAAE;AAC9C,QAAA,OAAO,IAAI;IACb;IACA,OAAO,IAAI,kBAAkB,CAAC,EAAE,EAAE,kBAAkB,EAAE,QAAQ,CAAC;AACjE;;"}
@@ -1,4 +1,4 @@
1
- /*! @hebcal/core v6.16.1, distributed under GPLv2 or later https://www.gnu.org/licenses/gpl-2.0.txt */
1
+ /*! @hebcal/core v6.17.0, distributed under GPLv2 or later https://www.gnu.org/licenses/gpl-2.0.txt */
2
2
  var citiesJson = [
3
3
  "Ashdod|IL|31.79213|34.64966|Asia/Jerusalem|27",
4
4
  "Atlanta|US|33.749|-84.38798|America/New_York|336",
package/dist/esm/event.js CHANGED
@@ -1,4 +1,4 @@
1
- /*! @hebcal/core v6.16.1, distributed under GPLv2 or later https://www.gnu.org/licenses/gpl-2.0.txt */
1
+ /*! @hebcal/core v6.17.0, distributed under GPLv2 or later https://www.gnu.org/licenses/gpl-2.0.txt */
2
2
  import { HDate, Locale } from '@hebcal/hdate';
3
3
  import './locale.js';
4
4
 
@@ -70,10 +70,14 @@ const flags = {
70
70
  };
71
71
  const flagEntries = Object.entries(flags);
72
72
  function flagBit(name) {
73
- if (!Object.hasOwn(flags, name)) {
73
+ // No Object.prototype property is a number, so this rejects 'toString'
74
+ // and friends as well as Object.hasOwn() would, but is cheaper in the
75
+ // hasFlag() calls on calendar()'s hot path.
76
+ const bit = flags[name];
77
+ if (typeof bit !== 'number') {
74
78
  throw new RangeError(`Unknown flag name: ${String(name)}`);
75
79
  }
76
- return flags[name];
80
+ return bit;
77
81
  }
78
82
  const flagToCategory = [
79
83
  [flags.MAJOR_FAST, 'holiday', 'major', 'fast'],
@@ -1 +1 @@
1
- {"version":3,"file":"event.js","sources":["../../../src/event.ts"],"sourcesContent":["import {HDate, Locale} from '@hebcal/hdate';\nimport './locale.js'; // Adds Hebrew and Ashkenazic translations\n\n/**\n * Holiday flags for Event. These flags are typically\n * combined using bitwise arithmetic to form a mask.\n */\nexport const flags = {\n /** Chag, yontiff, yom tov */\n CHAG: 0x000001,\n /** Light candles before sundown */\n LIGHT_CANDLES: 0x000002,\n /** End of holiday (end of Yom Tov) */\n YOM_TOV_ENDS: 0x000004,\n /** Observed only in the Diaspora (chutz l'aretz) */\n CHUL_ONLY: 0x000008,\n /** Observed only in Israel */\n IL_ONLY: 0x000010,\n /** Light candles in the evening at Tzeit time (3 small stars) */\n LIGHT_CANDLES_TZEIS: 0x000020,\n /** Candle-lighting for Chanukah */\n CHANUKAH_CANDLES: 0x000040,\n /** Rosh Chodesh, beginning of a new Hebrew month */\n ROSH_CHODESH: 0x000080,\n /** Minor fasts like Tzom Tammuz, Ta'anit Esther, ... */\n MINOR_FAST: 0x000100,\n /** Shabbat Shekalim, Zachor, ... */\n SPECIAL_SHABBAT: 0x000200,\n /** Weekly sedrot on Saturdays */\n PARSHA_HASHAVUA: 0x000400,\n /** Daily page of Talmud (Bavli) */\n DAF_YOMI: 0x000800,\n /** Days of the Omer */\n OMER_COUNT: 0x001000,\n /** Yom HaShoah, Yom HaAtzma'ut, ... */\n MODERN_HOLIDAY: 0x002000,\n /** Yom Kippur and Tish'a B'Av */\n MAJOR_FAST: 0x004000,\n /** On the Saturday before Rosh Chodesh */\n SHABBAT_MEVARCHIM: 0x008000,\n /** Molad */\n MOLAD: 0x010000,\n /** Yahrzeit or Hebrew Anniversary */\n USER_EVENT: 0x020000,\n /** Daily Hebrew date (\"11th of Sivan, 5780\") */\n HEBREW_DATE: 0x040000,\n /** A holiday that's not major, modern, rosh chodesh, or a fast day */\n MINOR_HOLIDAY: 0x080000,\n /** Evening before a major or minor holiday */\n EREV: 0x100000,\n /** Chol haMoed, intermediate days of Pesach or Sukkot */\n CHOL_HAMOED: 0x200000,\n /** Mishna Yomi */\n MISHNA_YOMI: 0x400000,\n /** Yom Kippur Katan, minor day of atonement on the day preceeding each Rosh Chodesh */\n YOM_KIPPUR_KATAN: 0x800000,\n /** Daily page of Jerusalem Talmud (Yerushalmi) */\n YERUSHALMI_YOMI: 0x1000000,\n /** Nach Yomi */\n NACH_YOMI: 0x2000000,\n /** Daily Learning */\n DAILY_LEARNING: 0x4000000,\n /** Yizkor */\n YIZKOR: 0x8000000,\n /** BeHaB fast days on Monday, Thursday and Monday after Pesach and Sukkot */\n BEHAB: 0x10000000,\n /** Latest time for Kiddush Levana (Sanctification of the Moon) */\n KIDDUSH_LEVANA: 0x20000000,\n} as const;\n\n/**\n * Name of one of the {@link flags}, such as `'CHAG'` or `'ROSH_CHODESH'`.\n * Used by {@link Event.hasFlag} and {@link Event.flagNames}.\n */\nexport type FlagName = keyof typeof flags;\n\nconst flagEntries = Object.entries(flags) as [FlagName, number][];\n\nfunction flagBit(name: FlagName): number {\n if (!Object.hasOwn(flags, name)) {\n throw new RangeError(`Unknown flag name: ${String(name)}`);\n }\n return flags[name];\n}\n\nconst flagToCategory = [\n [flags.MAJOR_FAST, 'holiday', 'major', 'fast'],\n [flags.CHANUKAH_CANDLES, 'holiday', 'minor'],\n [flags.HEBREW_DATE, 'hebdate'],\n [flags.MINOR_FAST, 'holiday', 'fast'],\n [flags.MINOR_HOLIDAY, 'holiday', 'minor'],\n [flags.MODERN_HOLIDAY, 'holiday', 'modern'],\n [flags.MOLAD, 'molad'],\n [flags.OMER_COUNT, 'omer'],\n [flags.PARSHA_HASHAVUA, 'parashat'], // backwards-compat\n [flags.ROSH_CHODESH, 'roshchodesh'],\n [flags.SHABBAT_MEVARCHIM, 'mevarchim'],\n [flags.SPECIAL_SHABBAT, 'holiday', 'shabbat'],\n [flags.USER_EVENT, 'user'],\n [flags.YIZKOR, 'yizkor'],\n] as const;\n\n/**\n * Represents an Event with a title, date, and flags.\n *\n * Events are used to represent holidays, candle-lighting times,\n * Torah readings, Omer days, Hebrew dates, and more. Most concrete event\n * types are subclasses (e.g. {@link HolidayEvent}, {@link TimedEvent},\n * {@link ParshaEvent}, {@link OmerEvent}) and are produced by\n * {@link calendar}.\n *\n * To get the title of the event in a language other than English with\n * Sephardic transliterations, use the {@link Event.render} method.\n *\n * @example\n * import {Event, HDate, flags} from '@hebcal/core';\n * const ev = new Event(new HDate(6, 'Sivan', 5749), 'Shavuot', flags.CHAG);\n * ev.getDate().toString(); // '6 Sivan 5749'\n * ev.getDesc(); // 'Shavuot'\n * ev.render('he'); // 'שָׁבוּעוֹת'\n */\nexport class Event {\n /** Hebrew date of this event */\n readonly date: HDate;\n /**\n * Untranslated title of this event. Note that these description\n * strings are always in English and will remain stable across releases.\n * To get the title of the event in another language, use the\n * `render()` method.\n */\n readonly desc: string;\n /** Bitmask of optional event flags. See {@link flags} */\n readonly mask: number;\n /** Optional emoji character such as ✡️, 🕯️, 🕎, 🕍, 🌒 */\n emoji?: string;\n /** Optional longer description or memo text */\n memo?: string;\n /** Alarms are used by iCalendar feeds */\n alarm?: Date | string | boolean;\n /**\n * Constructs Event\n * @param date Hebrew date event occurs\n * @param desc Description (not translated)\n * @param [mask=0] optional bitmask of holiday flags (see {@link flags})\n * @param [attrs={}] optional additional attributes (e.g. `eventTimeStr`, `cholHaMoedDay`)\n */\n constructor(date: HDate, desc: string, mask = 0, attrs?: object) {\n if (!HDate.isHDate(date)) {\n throw new TypeError(`Invalid Event date: ${date}`);\n }\n if (typeof desc !== 'string') {\n throw new TypeError(`Invalid Event description: ${desc}`);\n }\n this.date = date;\n this.desc = desc;\n this.mask = +mask;\n if (typeof attrs === 'object' && attrs !== null) {\n Object.assign(this, attrs);\n }\n }\n /**\n * Hebrew date of this event\n */\n getDate(): HDate {\n return this.date;\n }\n /**\n * Gregorian date of this event\n */\n greg(): Date {\n return this.date.greg();\n }\n /**\n * Untranslated title of this event. Note that these description\n * strings are always in English and will remain stable across releases.\n * To get the title of the event in another language, use the\n * `render()` method.\n */\n getDesc(): string {\n return this.desc;\n }\n /**\n * Bitmask of optional event flags. See {@link flags}\n * @deprecated Use {@link Event.hasFlag} to test for a flag, or\n * {@link Event.flagNames} to list them. Code that genuinely needs the\n * raw bitmask can read {@link Event.mask}.\n */\n getFlags(): number {\n return this.mask;\n }\n /**\n * Does this event have the given flag?\n *\n * A readable alternative to testing the bitmask with `&`.\n * @example\n * import {Event, HDate, flags} from '@hebcal/core';\n * const ev = new Event(new HDate(7, 'Sivan', 5749), 'Shavuot II',\n * flags.CHAG | flags.CHUL_ONLY);\n * ev.hasFlag('CHAG'); // true\n * ev.hasFlag('CHUL_ONLY'); // true\n * ev.hasFlag('MINOR_FAST'); // false\n * @param name flag name, one of the keys of {@link flags}\n * @throws {RangeError} if `name` is not a key of {@link flags}\n */\n hasFlag(name: FlagName): boolean {\n return (this.mask & flagBit(name)) !== 0;\n }\n /**\n * Does this event have at least one of the given flags?\n *\n * Returns `false` when called with no arguments.\n * @example\n * import {Event, HDate, flags} from '@hebcal/core';\n * const ev = new Event(new HDate(10, 'Tishrei', 5784), 'Yom Kippur',\n * flags.CHAG | flags.MAJOR_FAST);\n * ev.hasAnyFlag('MAJOR_FAST', 'MINOR_FAST'); // true\n * ev.hasAnyFlag('ROSH_CHODESH', 'MINOR_FAST'); // false\n * @param names flag names, each one of the keys of {@link flags}\n * @throws {RangeError} if any name is not a key of {@link flags}\n */\n hasAnyFlag(...names: FlagName[]): boolean {\n let bits = 0;\n for (const name of names) {\n bits |= flagBit(name);\n }\n return (this.mask & bits) !== 0;\n }\n /**\n * Names of all {@link flags} set on this event, in ascending bit order.\n * Returns an empty array for an event with no flags.\n * @example\n * import {Event, HDate, flags} from '@hebcal/core';\n * const ev = new Event(new HDate(7, 'Sivan', 5749), 'Shavuot II',\n * flags.CHAG | flags.CHUL_ONLY);\n * ev.flagNames(); // ['CHAG', 'CHUL_ONLY']\n */\n flagNames(): FlagName[] {\n return flagEntries.filter(([, bit]) => this.mask & bit).map(([name]) => name);\n }\n /**\n * Returns (translated) description of this event\n * @example\n * const ev = new Event(new HDate(6, 'Sivan', 5749), 'Shavuot', flags.CHAG);\n * ev.render('en'); // 'Shavuot'\n * ev.render('he'); // 'שָׁבוּעוֹת'\n * ev.render('ashkenazi'); // 'Shavuos'\n * @param [locale] Optional locale name (defaults to empty locale)\n */\n render(locale?: string): string {\n return Locale.gettext(this.desc, locale);\n }\n /**\n * Returns a brief (translated) description of this event.\n *\n * For most events this is the same as {@link render}. Some subclasses\n * (e.g. {@link CandleLightingEvent}, {@link HavdalahEvent},\n * {@link OmerEvent}) produce shorter text without an attached time or\n * extra qualifier — useful for compact UI display.\n * @example\n * import {CandleLightingEvent} from '@hebcal/core';\n * // For a regular Event, renderBrief() == render():\n * const ev = new Event(new HDate(6, 'Sivan', 5749), 'Shavuot', flags.CHAG);\n * ev.renderBrief('en'); // 'Shavuot'\n * @param [locale] Optional locale name (defaults to empty locale)\n */\n renderBrief(locale?: string): string {\n return this.render(locale);\n }\n /**\n * Returns the event's emoji character (e.g. `🕯️`, `🕎`, `🇮🇱`, `🍏🍯`),\n * or `null` if no emoji is associated with this event.\n * Subclasses override this to provide holiday-specific emoji.\n */\n getEmoji(): string | null {\n return this.emoji || null;\n }\n /**\n * Returns a simplified (untranslated) description for this event, suitable\n * for grouping related events under a single name.\n *\n * For example, {@link HolidayEvent} strips qualifiers so that\n * `\"Erev Pesach\"` → `\"Pesach\"` and `\"Sukkot III (CH''M)\"` → `\"Sukkot\"`.\n * For many events the basename and the event description are identical.\n * @example\n * import {HolidayEvent, HDate, months, flags} from '@hebcal/core';\n * const ev = new HolidayEvent(\n * new HDate(14, months.NISAN, 5784), 'Erev Pesach', flags.EREV);\n * ev.getDesc(); // 'Erev Pesach'\n * ev.basename(); // 'Pesach'\n */\n basename(): string {\n return this.getDesc();\n }\n /**\n * Returns a URL to hebcal.com or sefaria.org for more detail on the event,\n * or `undefined` for events with no detail page.\n *\n * Subclasses such as {@link HolidayEvent}, {@link ChanukahEvent},\n * {@link AsaraBTevetEvent}, {@link ParshaEvent}, and {@link OmerEvent}\n * override this with their own URL patterns.\n */\n url(): string | undefined {\n return undefined;\n }\n /**\n * Is this event observed in Israel?\n * @example\n * const ev1 = new Event(new HDate(7, 'Sivan', 5749), 'Shavuot II', flags.CHAG | flags.CHUL_ONLY);\n * ev1.observedInIsrael(); // false\n * const ev2 = new Event(new HDate(26, 'Kislev', 5749), 'Chanukah: 3 Candles', 0);\n * ev2.observedInIsrael(); // true\n */\n observedInIsrael(): boolean {\n return !this.hasFlag('CHUL_ONLY');\n }\n /**\n * Is this event observed in the Diaspora?\n * @example\n * const ev1 = new Event(new HDate(7, 'Sivan', 5749), 'Shavuot II', flags.CHAG | flags.CHUL_ONLY);\n * ev1.observedInDiaspora(); // true\n * const ev2 = new Event(new HDate(26, 'Kislev', 5749), 'Chanukah: 3 Candles', 0);\n * ev2.observedInDiaspora(); // true\n */\n observedInDiaspora(): boolean {\n return !this.hasFlag('IL_ONLY');\n }\n /**\n * Is this event observed in Israel/Diaspora?\n * @example\n * const ev1 = new Event(new HDate(7, 'Sivan', 5749), 'Shavuot II', flags.CHAG | flags.CHUL_ONLY);\n * ev1.observedIn(false); // true\n * ev1.observedIn(true); // false\n * const ev2 = new Event(new HDate(26, 'Kislev', 5749), 'Chanukah: 3 Candles', 0);\n * ev2.observedIn(false); // true\n * ev2.observedIn(true); // true\n * @param il\n */\n observedIn(il: boolean): boolean {\n return il ? this.observedInIsrael() : this.observedInDiaspora();\n }\n /**\n * Returns an array of category strings classifying this event, derived\n * from its {@link flags} bitmask. The first element is the broad category\n * (e.g. `'holiday'`, `'roshchodesh'`, `'parashat'`, `'omer'`), followed\n * by zero or more refinements (e.g. `'major'`, `'minor'`, `'fast'`).\n *\n * Returns `['unknown']` if no flag maps to a known category.\n * @example\n * import {Event, HDate, flags} from '@hebcal/core';\n * new Event(new HDate(10, 'Tishrei', 5784), 'Yom Kippur', flags.MAJOR_FAST)\n * .getCategories(); // ['holiday', 'major', 'fast']\n * new Event(new HDate(1, 'Shvat', 5784), 'Rosh Chodesh Sh\\'vat', flags.ROSH_CHODESH)\n * .getCategories();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AkB,EAAE;IACjE;AACA;;;;;;;;;;;;;AAaG;IACH,aAAa,GAAA;QACX,KAAK,MAAM,CAAC,GAAG,EAAE,GAAG,UAAU,CAAC,IAAI,cAAc,EAAE;AACjD,YAAA,IAAI,IAAI,CAAC,IAAI,GAAG,GAAG,EAAE;AACnB,gBAAA,OAAO,UAAU;YACnB;QACF;QACA,OAAO,CAAC,SAAS,CAAC;IACpB;AACD;;"}
1
+ {"version":3,"file":"event.js","sources":["../../../src/event.ts"],"sourcesContent":["import {HDate, Locale} from '@hebcal/hdate';\nimport './locale.js'; // Adds Hebrew and Ashkenazic translations\n\n/**\n * Holiday flags for Event. These flags are typically\n * combined using bitwise arithmetic to form a mask.\n */\nexport const flags = {\n /** Chag, yontiff, yom tov */\n CHAG: 0x000001,\n /** Light candles before sundown */\n LIGHT_CANDLES: 0x000002,\n /** End of holiday (end of Yom Tov) */\n YOM_TOV_ENDS: 0x000004,\n /** Observed only in the Diaspora (chutz l'aretz) */\n CHUL_ONLY: 0x000008,\n /** Observed only in Israel */\n IL_ONLY: 0x000010,\n /** Light candles in the evening at Tzeit time (3 small stars) */\n LIGHT_CANDLES_TZEIS: 0x000020,\n /** Candle-lighting for Chanukah */\n CHANUKAH_CANDLES: 0x000040,\n /** Rosh Chodesh, beginning of a new Hebrew month */\n ROSH_CHODESH: 0x000080,\n /** Minor fasts like Tzom Tammuz, Ta'anit Esther, ... */\n MINOR_FAST: 0x000100,\n /** Shabbat Shekalim, Zachor, ... */\n SPECIAL_SHABBAT: 0x000200,\n /** Weekly sedrot on Saturdays */\n PARSHA_HASHAVUA: 0x000400,\n /** Daily page of Talmud (Bavli) */\n DAF_YOMI: 0x000800,\n /** Days of the Omer */\n OMER_COUNT: 0x001000,\n /** Yom HaShoah, Yom HaAtzma'ut, ... */\n MODERN_HOLIDAY: 0x002000,\n /** Yom Kippur and Tish'a B'Av */\n MAJOR_FAST: 0x004000,\n /** On the Saturday before Rosh Chodesh */\n SHABBAT_MEVARCHIM: 0x008000,\n /** Molad */\n MOLAD: 0x010000,\n /** Yahrzeit or Hebrew Anniversary */\n USER_EVENT: 0x020000,\n /** Daily Hebrew date (\"11th of Sivan, 5780\") */\n HEBREW_DATE: 0x040000,\n /** A holiday that's not major, modern, rosh chodesh, or a fast day */\n MINOR_HOLIDAY: 0x080000,\n /** Evening before a major or minor holiday */\n EREV: 0x100000,\n /** Chol haMoed, intermediate days of Pesach or Sukkot */\n CHOL_HAMOED: 0x200000,\n /** Mishna Yomi */\n MISHNA_YOMI: 0x400000,\n /** Yom Kippur Katan, minor day of atonement on the day preceeding each Rosh Chodesh */\n YOM_KIPPUR_KATAN: 0x800000,\n /** Daily page of Jerusalem Talmud (Yerushalmi) */\n YERUSHALMI_YOMI: 0x1000000,\n /** Nach Yomi */\n NACH_YOMI: 0x2000000,\n /** Daily Learning */\n DAILY_LEARNING: 0x4000000,\n /** Yizkor */\n YIZKOR: 0x8000000,\n /** BeHaB fast days on Monday, Thursday and Monday after Pesach and Sukkot */\n BEHAB: 0x10000000,\n /** Latest time for Kiddush Levana (Sanctification of the Moon) */\n KIDDUSH_LEVANA: 0x20000000,\n} as const;\n\n/**\n * Name of one of the {@link flags}, such as `'CHAG'` or `'ROSH_CHODESH'`.\n * Used by {@link Event.hasFlag} and {@link Event.flagNames}.\n */\nexport type FlagName = keyof typeof flags;\n\nconst flagEntries = Object.entries(flags) as [FlagName, number][];\n\nfunction flagBit(name: FlagName): number {\n // No Object.prototype property is a number, so this rejects 'toString'\n // and friends as well as Object.hasOwn() would, but is cheaper in the\n // hasFlag() calls on calendar()'s hot path.\n const bit: unknown = flags[name];\n if (typeof bit !== 'number') {\n throw new RangeError(`Unknown flag name: ${String(name)}`);\n }\n return bit;\n}\n\nconst flagToCategory = [\n [flags.MAJOR_FAST, 'holiday', 'major', 'fast'],\n [flags.CHANUKAH_CANDLES, 'holiday', 'minor'],\n [flags.HEBREW_DATE, 'hebdate'],\n [flags.MINOR_FAST, 'holiday', 'fast'],\n [flags.MINOR_HOLIDAY, 'holiday', 'minor'],\n [flags.MODERN_HOLIDAY, 'holiday', 'modern'],\n [flags.MOLAD, 'molad'],\n [flags.OMER_COUNT, 'omer'],\n [flags.PARSHA_HASHAVUA, 'parashat'], // backwards-compat\n [flags.ROSH_CHODESH, 'roshchodesh'],\n [flags.SHABBAT_MEVARCHIM, 'mevarchim'],\n [flags.SPECIAL_SHABBAT, 'holiday', 'shabbat'],\n [flags.USER_EVENT, 'user'],\n [flags.YIZKOR, 'yizkor'],\n] as const;\n\n/**\n * Represents an Event with a title, date, and flags.\n *\n * Events are used to represent holidays, candle-lighting times,\n * Torah readings, Omer days, Hebrew dates, and more. Most concrete event\n * types are subclasses (e.g. {@link HolidayEvent}, {@link TimedEvent},\n * {@link ParshaEvent}, {@link OmerEvent}) and are produced by\n * {@link calendar}.\n *\n * To get the title of the event in a language other than English with\n * Sephardic transliterations, use the {@link Event.render} method.\n *\n * @example\n * import {Event, HDate, flags} from '@hebcal/core';\n * const ev = new Event(new HDate(6, 'Sivan', 5749), 'Shavuot', flags.CHAG);\n * ev.getDate().toString(); // '6 Sivan 5749'\n * ev.getDesc(); // 'Shavuot'\n * ev.render('he'); // 'שָׁבוּעוֹת'\n */\nexport class Event {\n /** Hebrew date of this event */\n readonly date: HDate;\n /**\n * Untranslated title of this event. Note that these description\n * strings are always in English and will remain stable across releases.\n * To get the title of the event in another language, use the\n * `render()` method.\n */\n readonly desc: string;\n /** Bitmask of optional event flags. See {@link flags} */\n readonly mask: number;\n /** Optional emoji character such as ✡️, 🕯️, 🕎, 🕍, 🌒 */\n emoji?: string;\n /** Optional longer description or memo text */\n memo?: string;\n /** Alarms are used by iCalendar feeds */\n alarm?: Date | string | boolean;\n /**\n * Constructs Event\n * @param date Hebrew date event occurs\n * @param desc Description (not translated)\n * @param [mask=0] optional bitmask of holiday flags (see {@link flags})\n * @param [attrs={}] optional additional attributes (e.g. `eventTimeStr`, `cholHaMoedDay`)\n */\n constructor(date: HDate, desc: string, mask = 0, attrs?: object) {\n if (!HDate.isHDate(date)) {\n throw new TypeError(`Invalid Event date: ${date}`);\n }\n if (typeof desc !== 'string') {\n throw new TypeError(`Invalid Event description: ${desc}`);\n }\n this.date = date;\n this.desc = desc;\n this.mask = +mask;\n if (typeof attrs === 'object' && attrs !== null) {\n Object.assign(this, attrs);\n }\n }\n /**\n * Hebrew date of this event\n */\n getDate(): HDate {\n return this.date;\n }\n /**\n * Gregorian date of this event\n */\n greg(): Date {\n return this.date.greg();\n }\n /**\n * Untranslated title of this event. Note that these description\n * strings are always in English and will remain stable across releases.\n * To get the title of the event in another language, use the\n * `render()` method.\n */\n getDesc(): string {\n return this.desc;\n }\n /**\n * Bitmask of optional event flags. See {@link flags}\n * @deprecated Use {@link Event.hasFlag} to test for a flag, or\n * {@link Event.flagNames} to list them. Code that genuinely needs the\n * raw bitmask can read {@link Event.mask}.\n */\n getFlags(): number {\n return this.mask;\n }\n /**\n * Does this event have the given flag?\n *\n * A readable alternative to testing the bitmask with `&`.\n * @example\n * import {Event, HDate, flags} from '@hebcal/core';\n * const ev = new Event(new HDate(7, 'Sivan', 5749), 'Shavuot II',\n * flags.CHAG | flags.CHUL_ONLY);\n * ev.hasFlag('CHAG'); // true\n * ev.hasFlag('CHUL_ONLY'); // true\n * ev.hasFlag('MINOR_FAST'); // false\n * @param name flag name, one of the keys of {@link flags}\n * @throws {RangeError} if `name` is not a key of {@link flags}\n */\n hasFlag(name: FlagName): boolean {\n return (this.mask & flagBit(name)) !== 0;\n }\n /**\n * Does this event have at least one of the given flags?\n *\n * Returns `false` when called with no arguments.\n * @example\n * import {Event, HDate, flags} from '@hebcal/core';\n * const ev = new Event(new HDate(10, 'Tishrei', 5784), 'Yom Kippur',\n * flags.CHAG | flags.MAJOR_FAST);\n * ev.hasAnyFlag('MAJOR_FAST', 'MINOR_FAST'); // true\n * ev.hasAnyFlag('ROSH_CHODESH', 'MINOR_FAST'); // false\n * @param names flag names, each one of the keys of {@link flags}\n * @throws {RangeError} if any name is not a key of {@link flags}\n */\n hasAnyFlag(...names: FlagName[]): boolean {\n let bits = 0;\n for (const name of names) {\n bits |= flagBit(name);\n }\n return (this.mask & bits) !== 0;\n }\n /**\n * Names of all {@link flags} set on this event, in ascending bit order.\n * Returns an empty array for an event with no flags.\n * @example\n * import {Event, HDate, flags} from '@hebcal/core';\n * const ev = new Event(new HDate(7, 'Sivan', 5749), 'Shavuot II',\n * flags.CHAG | flags.CHUL_ONLY);\n * ev.flagNames(); // ['CHAG', 'CHUL_ONLY']\n */\n flagNames(): FlagName[] {\n return flagEntries.filter(([, bit]) => this.mask & bit).map(([name]) => name);\n }\n /**\n * Returns (translated) description of this event\n * @example\n * const ev = new Event(new HDate(6, 'Sivan', 5749), 'Shavuot', flags.CHAG);\n * ev.render('en'); // 'Shavuot'\n * ev.render('he'); // 'שָׁבוּעוֹת'\n * ev.render('ashkenazi'); // 'Shavuos'\n * @param [locale] Optional locale name (defaults to empty locale)\n */\n render(locale?: string): string {\n return Locale.gettext(this.desc, locale);\n }\n /**\n * Returns a brief (translated) description of this event.\n *\n * For most events this is the same as {@link render}. Some subclasses\n * (e.g. {@link CandleLightingEvent}, {@link HavdalahEvent},\n * {@link OmerEvent}) produce shorter text without an attached time or\n * extra qualifier — useful for compact UI display.\n * @example\n * import {CandleLightingEvent} from '@hebcal/core';\n * // For a regular Event, renderBrief() == render():\n * const ev = new Event(new HDate(6, 'Sivan', 5749), 'Shavuot', flags.CHAG);\n * ev.renderBrief('en'); // 'Shavuot'\n * @param [locale] Optional locale name (defaults to empty locale)\n */\n renderBrief(locale?: string): string {\n return this.render(locale);\n }\n /**\n * Returns the event's emoji character (e.g. `🕯️`, `🕎`, `🇮🇱`, `🍏🍯`),\n * or `null` if no emoji is associated with this event.\n * Subclasses override this to provide holiday-specific emoji.\n */\n getEmoji(): string | null {\n return this.emoji || null;\n }\n /**\n * Returns a simplified (untranslated) description for this event, suitable\n * for grouping related events under a single name.\n *\n * For example, {@link HolidayEvent} strips qualifiers so that\n * `\"Erev Pesach\"` → `\"Pesach\"` and `\"Sukkot III (CH''M)\"` → `\"Sukkot\"`.\n * For many events the basename and the event description are identical.\n * @example\n * import {HolidayEvent, HDate, months, flags} from '@hebcal/core';\n * const ev = new HolidayEvent(\n * new HDate(14, months.NISAN, 5784), 'Erev Pesach', flags.EREV);\n * ev.getDesc(); // 'Erev Pesach'\n * ev.basename(); // 'Pesach'\n */\n basename(): string {\n return this.getDesc();\n }\n /**\n * Returns a URL to hebcal.com or sefaria.org for more detail on the event,\n * or `undefined` for events with no detail page.\n *\n * Subclasses such as {@link HolidayEvent}, {@link ChanukahEvent},\n * {@link AsaraBTevetEvent}, {@link ParshaEvent}, and {@link OmerEvent}\n * override this with their own URL patterns.\n */\n url(): string | undefined {\n return undefined;\n }\n /**\n * Is this event observed in Israel?\n * @example\n * const ev1 = new Event(new HDate(7, 'Sivan', 5749), 'Shavuot II', flags.CHAG | flags.CHUL_ONLY);\n * ev1.observedInIsrael(); // false\n * const ev2 = new Event(new HDate(26, 'Kislev', 5749), 'Chanukah: 3 Candles', 0);\n * ev2.observedInIsrael(); // true\n */\n observedInIsrael(): boolean {\n return !this.hasFlag('CHUL_ONLY');\n }\n /**\n * Is this event observed in the Diaspora?\n * @example\n * const ev1 = new Event(new HDate(7, 'Sivan', 5749), 'Shavuot II', flags.CHAG | flags.CHUL_ONLY);\n * ev1.observedInDiaspora(); // true\n * const ev2 = new Event(new HDate(26, 'Kislev', 5749), 'Chanukah: 3 Candles', 0);\n * ev2.observedInDiaspora(); // true\n */\n observedInDiaspora(): boolean {\n return !this.hasFlag('IL_ONLY');\n }\n /**\n * Is this event observed in Israel/Diaspora?\n * @example\n * const ev1 = new Event(new HDate(7, 'Sivan', 5749), 'Shavuot II', flags.CHAG | flags.CHUL_ONLY);\n * ev1.observedIn(false); // true\n * ev1.observedIn(true); // false\n * const ev2 = new Event(new HDate(26, 'Kislev', 5749), 'Chanukah: 3 Candles', 0);\n * ev2.observedIn(false); // true\n * ev2.observedIn(true); // true\n * @param il\n */\n observedIn(il: boolean): boolean {\n return il ? this.observedInIsrael() : this.observedInDiaspora();\n }\n /**\n * Returns an array of category strings classifying this event, derived\n * from its {@link flags} bitmask. The first element is the broad category\n * (e.g. `'holiday'`, `'roshchodesh'`, `'parashat'`, `'omer'`), followed\n * by zero or more refinements (e.g. `'major'`, `'minor'`, `'fast'`).\n *\n * Returns `['unknown']` if no flag maps to a known category.\n * @example\n * import {Event, HDate, flags} from '@hebcal/core';\n * new Event(new HDate(10, 'Tishrei', 5784), 'Yom Kippur', flags.MAJOR_FAST)\n * .getCategories(); // ['holiday', 'major', 'fast']\n * new Event(new HDate(1, 'Shvat', 5784), 'Rosh Chodesh Sh\\'vat', flags.ROSH_CHODESH)\n * .getCategories(); // ['roshchodesh']\n */\n getCategories(): string[] {\n for (const [bit, ...categories] of flagToCategory) {\n if (this.mask & bit) {\n return categories;\n }\n }\n return ['unknown'];\n }\n}\n"],"names":[],"mappings":";;;;AAGA;;;AAGG;AACI,MAAM,KAAK,GAAG;;AAEnB,IAAA,IAAI,EAAE,QAAQ;;AAEd,IAAA,aAAa,EAAE,QAAQ;;AAEvB,IAAA,YAAY,EAAE,QAAQ;;AAEtB,IAAA,SAAS,EAAE,QAAQ;;AAEnB,IAAA,OAAO,EAAE,QAAQ;;AAEjB,IAAA,mBAAmB,EAAE,QAAQ;;AAE7B,IAAA,gBAAgB,EAAE,QAAQ;;AAE1B,IAAA,YAAY,EAAE,QAAQ;;AAEtB,IAAA,UAAU,EAAE,QAAQ;;AAEpB,IAAA,eAAe,EAAE,QAAQ;;AAEzB,IAAA,eAAe,EAAE,QAAQ;;AAEzB,IAAA,QAAQ,EAAE,QAAQ;;AAElB,IAAA,UAAU,EAAE,QAAQ;;AAEpB,IAAA,cAAc,EAAE,QAAQ;;AAExB,IAAA,UAAU,EAAE,QAAQ;;AAEpB,IAAA,iBAAiB,EAAE,QAAQ;;AAE3B,IAAA,KAAK,EAAE,QAAQ;;AAEf,IAAA,UAAU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;;;;;;;;;;AAaG;IACH,QAAQ,GAAA;AACN,QAAA,OAAO,IAAI,CAAC,OAAO,EAAE;IACvB;AACA;;;;;;;AAOG;IACH,GAAG,GAAA;AACD,QAAA,OAAO,SAAS;IAClB;AACA;;;;;;;AAOG;IACH,gBAAgB,GAAA;AACd,QAAA,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC;IACnC;AACA;;;;;;;AAOG;IACH,kBAAkB,GAAA;AAChB,QAAA,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC;IACjC;AACA;;;;;;;;;;AAUG;AACH,IAAA,UAAU,CAAC,EAAW,EAAA;AACpB,QAAA,OAAO,EAAE,GAAG,IAAI,CAAC,gBAAgB,EAAE,GAAG,IAAI,CAAC,kBAAkB,EAAE;IACjE;AACA;;;;;;;;;;;;;AAaG;IACH,aAAa,GAAA;QACX,KAAK,MAAM,CAAC,GAAG,EAAE,GAAG,UAAU,CAAC,IAAI,cAAc,EAAE;AACjD,YAAA,IAAI,IAAI,CAAC,IAAI,GAAG,GAAG,EAAE;AACnB,gBAAA,OAAO,UAAU;YACnB;QACF;QACA,OAAO,CAAC,SAAS,CAAC;IACpB;AACD;;"}
@@ -1,4 +1,4 @@
1
- /*! @hebcal/core v6.16.1, distributed under GPLv2 or later https://www.gnu.org/licenses/gpl-2.0.txt */
1
+ /*! @hebcal/core v6.17.0, distributed under GPLv2 or later https://www.gnu.org/licenses/gpl-2.0.txt */
2
2
  import { months, isDate, greg2abs, HDate, daysInGregMonth } from '@hebcal/hdate';
3
3
 
4
4
  const { TISHREI } = months;
@@ -69,7 +69,7 @@ function getMonth(options) {
69
69
  return options.month;
70
70
  }
71
71
  }
72
- return NaN;
72
+ return Number.NaN;
73
73
  }
74
74
  function startEndGregorian(theMonth, theYear, numYears) {
75
75
  const gregMonth = theMonth ? theMonth - 1 : 0;
@@ -1 +1 @@
1
- {"version":3,"file":"getStartAndEnd.js","sources":["../../../src/getStartAndEnd.ts"],"sourcesContent":["import {greg2abs, isDate, daysInGregMonth, HDate, months} from '@hebcal/hdate';\nimport {CalOptions} from './CalOptions.js';\n\nconst {TISHREI} = months;\n\n/**\n * Gets the R.D. days for a number, Date, or HDate\n */\nfunction getAbs(d: Date | HDate | number): number {\n if (typeof d === 'number') return d;\n if (isDate(d)) return greg2abs(d);\n if (HDate.isHDate(d)) return d.abs();\n throw new TypeError(`Invalid date type: ${d}`);\n}\n\nfunction getYear(options: CalOptions): number {\n if (options.year !== undefined) {\n return Number(options.year);\n }\n return options.isHebrewYear\n ? new HDate().getFullYear()\n : new Date().getFullYear();\n}\n\nconst MAX_NUM_YEARS = 2000;\n\n/**\n * Parse options object to determine start & end days\n * @internal\n */\nexport function getStartAndEnd(options: CalOptions): number[] {\n const {start: start0, end: end0} = options;\n if ((start0 === undefined) !== (end0 === undefined)) {\n throw new TypeError('options.start requires options.end');\n }\n if (start0 !== undefined && end0 !== undefined) {\n const start = getAbs(start0);\n const end = getAbs(end0);\n if (end - start > 365 * MAX_NUM_YEARS) {\n throw new RangeError(`Date range exceeds ${MAX_NUM_YEARS} years`);\n }\n return [start, end];\n }\n const isHebrewYear = Boolean(options.isHebrewYear);\n const theYear = getYear(options);\n if (Number.isNaN(theYear)) {\n throw new RangeError(`Invalid year ${options.year}`);\n }\n if (isHebrewYear && theYear < 1) {\n throw new RangeError(`Invalid Hebrew year ${theYear}`);\n }\n const theMonth = getMonth(options);\n const numYears = Number(options.numYears) || 1;\n if (numYears > MAX_NUM_YEARS) {\n throw new RangeError(`options.numYears exceeds ${MAX_NUM_YEARS}`);\n }\n if (isHebrewYear) {\n return startEndHebrew(theMonth, theYear, numYears);\n } else {\n return startEndGregorian(theMonth, theYear, numYears);\n }\n}\n\nfunction getMonth(options: CalOptions): number {\n if (options.month) {\n if (options.isHebrewYear) {\n return HDate.monthNum(options.month);\n }\n if (typeof options.month === 'number') {\n return options.month;\n }\n }\n return NaN;\n}\n\nfunction startEndGregorian(\n theMonth: number,\n theYear: number,\n numYears: number\n): number[] {\n const gregMonth = theMonth ? theMonth - 1 : 0;\n const startGreg = new Date(theYear, gregMonth, 1);\n if (theYear < 100) {\n startGreg.setFullYear(theYear);\n }\n const startAbs = greg2abs(startGreg);\n let endAbs: number;\n if (theMonth) {\n endAbs = startAbs + daysInGregMonth(theMonth, theYear) - 1;\n } else {\n const endYear = theYear + numYears;\n const endGreg = new Date(endYear, 0, 1);\n if (endYear < 100) {\n endGreg.setFullYear(endYear);\n }\n endAbs = greg2abs(endGreg) - 1;\n }\n return [startAbs, endAbs];\n}\n\nfunction startEndHebrew(\n theMonth: number,\n theYear: number,\n numYears: number\n): number[] {\n const startDate = new HDate(1, theMonth || TISHREI, theYear);\n let startAbs = startDate.abs();\n const endAbs = theMonth\n ? startAbs + startDate.daysInMonth()\n : new HDate(1, TISHREI, theYear + numYears).abs() - 1;\n // for full Hebrew year, start on Erev Rosh Hashana which\n // is technically in the previous Hebrew year\n // (but conveniently lets us get candle-lighting time for Erev)\n if (!theMonth && theYear > 1) {\n startAbs--;\n }\n return [startAbs, endAbs];\n}\n"],"names":[],"mappings":";;;AAGA,MAAM,EAAC,OAAO,EAAC,GAAG,MAAM;AAExB;;AAEG;AACH,SAAS,MAAM,CAAC,CAAwB,EAAA;IACtC,IAAI,OAAO,CAAC,KAAK,QAAQ;AAAE,QAAA,OAAO,CAAC;IACnC,IAAI,MAAM,CAAC,CAAC,CAAC;AAAE,QAAA,OAAO,QAAQ,CAAC,CAAC,CAAC;AACjC,IAAA,IAAI,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC;AAAE,QAAA,OAAO,CAAC,CAAC,GAAG,EAAE;AACpC,IAAA,MAAM,IAAI,SAAS,CAAC,sBAAsB,CAAC,CAAA,CAAE,CAAC;AAChD;AAEA,SAAS,OAAO,CAAC,OAAmB,EAAA;AAClC,IAAA,IAAI,OAAO,CAAC,IAAI,KAAK,SAAS,EAAE;AAC9B,QAAA,OAAO,MAAM,CAAC,OAAO,CAAC,IAAI,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O,GAAG,OAAO,GAAG,QAAQ;QAClC,MAAM,OAAO,GAAG,IAAI,IAAI,CAAC,OAAO,EAAE,CAAC,EAAE,CAAC,CAAC;AACvC,QAAA,IAAI,OAAO,GAAG,GAAG,EAAE;AACjB,YAAA,OAAO,CAAC,WAAW,CAAC,OAAO,CAAC;QAC9B;AACA,QAAA,MAAM,GAAG,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC;IAChC;AACA,IAAA,OAAO,CAAC,QAAQ,EAAE,MAAM,CAAC;AAC3B;AAEA,SAAS,cAAc,CACrB,QAAgB,EAChB,OAAe,EACf,QAAgB,EAAA;AAEhB,IAAA,MAAM,SAAS,GAAG,IAAI,KAAK,CAAC,CAAC,EAAE,QAAQ,IAAI,OAAO,EAAE,OAAO,CAAC;AAC5D,IAAA,IAAI,QAAQ,GAAG,SAAS,CAAC,GAAG,EAAE;IAC9B,MAAM,MAAM,GAAG;AACb,UAAE,QAAQ,GAAG,SAAS,CAAC,WAAW;AAClC,UAAE,IAAI,KAAK,CAAC,CAAC,EAAE,OAAO,EAAE,OAAO,GAAG,QAAQ,CAAC,CAAC,GAAG,EAAE,GAAG,CAAC;;;;AAIvD,IAAA,IAAI,CAAC,QAAQ,IAAI,OAAO,GAAG,CAAC,EAAE;AAC5B,QAAA,QAAQ,EAAE;IACZ;AACA,IAAA,OAAO,CAAC,QAAQ,EAAE,MAAM,CAAC;AAC3B;;"}
1
+ {"version":3,"file":"getStartAndEnd.js","sources":["../../../src/getStartAndEnd.ts"],"sourcesContent":["import {greg2abs, isDate, daysInGregMonth, HDate, months} from '@hebcal/hdate';\nimport {CalOptions} from './CalOptions.js';\n\nconst {TISHREI} = months;\n\n/**\n * Gets the R.D. days for a number, Date, or HDate\n */\nfunction getAbs(d: Date | HDate | number): number {\n if (typeof d === 'number') return d;\n if (isDate(d)) return greg2abs(d);\n if (HDate.isHDate(d)) return d.abs();\n throw new TypeError(`Invalid date type: ${d}`);\n}\n\nfunction getYear(options: CalOptions): number {\n if (options.year !== undefined) {\n return Number(options.year);\n }\n return options.isHebrewYear\n ? new HDate().getFullYear()\n : new Date().getFullYear();\n}\n\nconst MAX_NUM_YEARS = 2000;\n\n/**\n * Parse options object to determine start & end days\n * @internal\n */\nexport function getStartAndEnd(options: CalOptions): number[] {\n const {start: start0, end: end0} = options;\n if ((start0 === undefined) !== (end0 === undefined)) {\n throw new TypeError('options.start requires options.end');\n }\n if (start0 !== undefined && end0 !== undefined) {\n const start = getAbs(start0);\n const end = getAbs(end0);\n if (end - start > 365 * MAX_NUM_YEARS) {\n throw new RangeError(`Date range exceeds ${MAX_NUM_YEARS} years`);\n }\n return [start, end];\n }\n const isHebrewYear = Boolean(options.isHebrewYear);\n const theYear = getYear(options);\n if (Number.isNaN(theYear)) {\n throw new RangeError(`Invalid year ${options.year}`);\n }\n if (isHebrewYear && theYear < 1) {\n throw new RangeError(`Invalid Hebrew year ${theYear}`);\n }\n const theMonth = getMonth(options);\n const numYears = Number(options.numYears) || 1;\n if (numYears > MAX_NUM_YEARS) {\n throw new RangeError(`options.numYears exceeds ${MAX_NUM_YEARS}`);\n }\n if (isHebrewYear) {\n return startEndHebrew(theMonth, theYear, numYears);\n } else {\n return startEndGregorian(theMonth, theYear, numYears);\n }\n}\n\nfunction getMonth(options: CalOptions): number {\n if (options.month) {\n if (options.isHebrewYear) {\n return HDate.monthNum(options.month);\n }\n if (typeof options.month === 'number') {\n return options.month;\n }\n }\n return Number.NaN;\n}\n\nfunction startEndGregorian(\n theMonth: number,\n theYear: number,\n numYears: number\n): number[] {\n const gregMonth = theMonth ? theMonth - 1 : 0;\n const startGreg = new Date(theYear, gregMonth, 1);\n if (theYear < 100) {\n startGreg.setFullYear(theYear);\n }\n const startAbs = greg2abs(startGreg);\n let endAbs: number;\n if (theMonth) {\n endAbs = startAbs + daysInGregMonth(theMonth, theYear) - 1;\n } else {\n const endYear = theYear + numYears;\n const endGreg = new Date(endYear, 0, 1);\n if (endYear < 100) {\n endGreg.setFullYear(endYear);\n }\n endAbs = greg2abs(endGreg) - 1;\n }\n return [startAbs, endAbs];\n}\n\nfunction startEndHebrew(\n theMonth: number,\n theYear: number,\n numYears: number\n): number[] {\n const startDate = new HDate(1, theMonth || TISHREI, theYear);\n let startAbs = startDate.abs();\n const endAbs = theMonth\n ? startAbs + startDate.daysInMonth()\n : new HDate(1, TISHREI, theYear + numYears).abs() - 1;\n // for full Hebrew year, start on Erev Rosh Hashana which\n // is technically in the previous Hebrew year\n // (but conveniently lets us get candle-lighting time for Erev)\n if (!theMonth && theYear > 1) {\n startAbs--;\n }\n return [startAbs, endAbs];\n}\n"],"names":[],"mappings":";;;AAGA,MAAM,EAAC,OAAO,EAAC,GAAG,MAAM;AAExB;;AAEG;AACH,SAAS,MAAM,CAAC,CAAwB,EAAA;IACtC,IAAI,OAAO,CAAC,KAAK,QAAQ;AAAE,QAAA,OAAO,CAAC;IACnC,IAAI,MAAM,CAAC,CAAC,CAAC;AAAE,QAAA,OAAO,QAAQ,CAAC,CAAC,CAAC;AACjC,IAAA,IAAI,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC;AAAE,QAAA,OAAO,CAAC,CAAC,GAAG,EAAE;AACpC,IAAA,MAAM,IAAI,SAAS,CAAC,sBAAsB,CAAC,CAAA,CAAE,CAAC;AAChD;AAEA,SAAS,OAAO,CAAC,OAAmB,EAAA;AAClC,IAAA,IAAI,OAAO,CAAC,IAAI,KAAK,SAAS,EAAE;AAC9B,QAAA,OAAO,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC;IAC7B;IACA,OAAO,OAAO,CAAC;AACb,UAAE,IAAI,KAAK,EAAE,CAAC,WAAW;AACzB,UAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;AAC9B;AAEA,MAAM,aAAa,GAAG,IAAI;AAE1B;;;AAGG;AACG,SAAU,cAAc,CAAC,OAAmB,EAAA;IAChD,MAAM,EAAC,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,IAAI,EAAC,GAAG,OAAO;AA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AC,QAAQ,EAAE,MAAM,CAAC;AAC3B;AAEA,SAAS,cAAc,CACrB,QAAgB,EAChB,OAAe,EACf,QAAgB,EAAA;AAEhB,IAAA,MAAM,SAAS,GAAG,IAAI,KAAK,CAAC,CAAC,EAAE,QAAQ,IAAI,OAAO,EAAE,OAAO,CAAC;AAC5D,IAAA,IAAI,QAAQ,GAAG,SAAS,CAAC,GAAG,EAAE;IAC9B,MAAM,MAAM,GAAG;AACb,UAAE,QAAQ,GAAG,SAAS,CAAC,WAAW;AAClC,UAAE,IAAI,KAAK,CAAC,CAAC,EAAE,OAAO,EAAE,OAAO,GAAG,QAAQ,CAAC,CAAC,GAAG,EAAE,GAAG,CAAC;;;;AAIvD,IAAA,IAAI,CAAC,QAAQ,IAAI,OAAO,GAAG,CAAC,EAAE;AAC5B,QAAA,QAAQ,EAAE;IACZ;AACA,IAAA,OAAO,CAAC,QAAQ,EAAE,MAAM,CAAC;AAC3B;;"}
@@ -1,5 +1,5 @@
1
- /*! @hebcal/core v6.16.1, distributed under GPLv2 or later https://www.gnu.org/licenses/gpl-2.0.txt */
2
- import { months, HDate } from '@hebcal/hdate';
1
+ /*! @hebcal/core v6.17.0, distributed under GPLv2 or later https://www.gnu.org/licenses/gpl-2.0.txt */
2
+ import { months, shortKislev } from '@hebcal/hdate';
3
3
  import { dateYomHaZikaron } from './modern.js';
4
4
 
5
5
  const NONE = 0;
@@ -49,7 +49,7 @@ function hallel(hdate, il) {
49
49
  break;
50
50
  case months.TEVET: {
51
51
  // Chanukah lasts 8 days, ending on 2 Tevet (3 Tevet if Kislev is short)
52
- const lastDay = HDate.shortKislev(hdate.getFullYear()) ? 3 : 2;
52
+ const lastDay = shortKislev(hdate.getFullYear()) ? 3 : 2;
53
53
  if (dd <= lastDay) {
54
54
  return WHOLE;
55
55
  }
@@ -1 +1 @@
1
- {"version":3,"file":"hallel.js","sources":["../../../src/hallel.ts"],"sourcesContent":["import {HDate, months} from '@hebcal/hdate';\nimport {dateYomHaZikaron} from './modern.js';\n\nconst NONE = 0;\nconst HALF = 1;\nconst WHOLE = 2;\n\n/**\n * Determines which form of Hallel (if any) is recited\n * on a given Hebrew date.\n *\n * Returns 0 (none), 1 (half Hallel), or 2 (whole Hallel).\n *\n * Whole Hallel is said on Chanukah, the first Yom Tov of Pesach, Shavuot, Sukkot,\n * Shmini Atzeret, Simchat Torah, Yom Ha'atzmaut, and Yom Yerushalayim.\n *\n * Half Hallel is said on Rosh Chodesh (not Rosh Hashanah), and the last 6 days of Pesach.\n * Rosh Chodesh Tevet falls during Chanukah, so whole Hallel is said then.\n *\n * The result is computed directly from the Hebrew month and day,\n * without generating holiday events.\n * @example\n * import {hallel, HDate, months} from '@hebcal/core';\n * hallel(new HDate(25, months.KISLEV, 5784), false); // 2 (Chanukah)\n * hallel(new HDate(1, months.SHVAT, 5784), false); // 1 (Rosh Chodesh)\n * hallel(new HDate(2, months.SHVAT, 5784), false); // 0\n * hallel(new HDate(16, months.NISAN, 5784), false); // 2 (Pesach II, Diaspora)\n * hallel(new HDate(16, months.NISAN, 5784), true); // 1 (Chol HaMoed, Israel)\n * @param hdate Hebrew date to test\n * @param il use the Israeli holiday schedule\n * @returns 0 for no Hallel, 1 for half Hallel, 2 for whole Hallel\n */\nexport function hallel(hdate: HDate, il: boolean): number {\n const mm = hdate.getMonth();\n const dd = hdate.getDate();\n switch (mm) {\n case months.TISHREI:\n // Sukkot (15-21), Shmini Atzeret (22), Simchat Torah (23, Diaspora)\n if (dd >= 15 && dd <= (il ? 22 : 23)) {\n return WHOLE;\n }\n break;\n case months.KISLEV:\n // Chanukah begins 25 Kislev; the first candle on the evening of\n // 24 Kislev precedes the first morning of Chanukah\n if (dd >= 25) {\n return WHOLE;\n }\n break;\n case months.TEVET: {\n // Chanukah lasts 8 days, ending on 2 Tevet (3 Tevet if Kislev is short)\n const lastDay = HDate.shortKislev(hdate.getFullYear()) ? 3 : 2;\n if (dd <= lastDay) {\n return WHOLE;\n }\n break;\n }\n case months.NISAN:\n // First day(s) of Pesach\n if (dd === 15 || (dd === 16 && !il)) {\n return WHOLE;\n }\n // Remaining days of Pesach\n if (dd >= 16 && dd <= (il ? 21 : 22)) {\n return HALF;\n }\n break;\n case months.IYYAR: {\n const year = hdate.getFullYear();\n // Yom Yerushalayim\n if (dd === 28 && year >= 5727) {\n return WHOLE;\n }\n // Yom Ha'atzmaut, the day after Yom HaZikaron\n const yomHaZikaron = dateYomHaZikaron(year);\n if (yomHaZikaron !== null && dd === yomHaZikaron.getDate() + 1) {\n return WHOLE;\n }\n break;\n }\n case months.SIVAN:\n // Shavuot\n if (dd === 6 || (dd === 7 && !il)) {\n return WHOLE;\n }\n break;\n default:\n break;\n }\n\n // Rosh Chodesh: the 30th of any month, or the 1st of any month\n // other than Tishrei (Rosh Hashana)\n if (dd === 30 || (dd === 1 && mm !== months.TISHREI)) {\n return HALF;\n }\n\n return NONE;\n}\n"],"names":[],"mappings":";;;;AAGA,MAAM,IAAI,GAAG,CAAC;AACd,MAAM,IAAI,GAAG,CAAC;AACd,MAAM,KAAK,GAAG,CAAC;AAEf;;;;;;;;;;;;;;;;;;;;;;;;AAwBG;AACG,SAAU,MAAM,CAAC,KAAY,EAAE,EAAW,EAAA;AAC9C,IAAA,MAAM,EAAE,GAAG,KAAK,CAAC,QAAQ,EAAE;AAC3B,IAAA,MAAM,EAAE,GAAG,KAAK,CAAC,OAAO,EAAE;IAC1B,QAAQ,EAAE;QACR,KAAK,MAAM,CAAC,OAAO;;AAEjB,YAAA,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC,EAAE;AACpC,gBAAA,OAAO,KAAK;YACd;YACA;QACF,KAAK,MAAM,CAAC,MAAM;;;AAGhB,YAAA,IAAI,EAAE,IAAI,EAAE,EAAE;AACZ,gBAAA,OAAO,KAAK;YACd;YACA;AACF,QAAA,KAAK,MAAM,CAAC,KAAK,EAAE;;AAEjB,YAAA,MAAM,OAAO,GAAG,KAAK,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cal/hdate';\nimport {dateYomHaZikaron} from './modern.js';\n\nconst NONE = 0;\nconst HALF = 1;\nconst WHOLE = 2;\n\n/**\n * Determines which form of Hallel (if any) is recited\n * on a given Hebrew date.\n *\n * Returns 0 (none), 1 (half Hallel), or 2 (whole Hallel).\n *\n * Whole Hallel is said on Chanukah, the first Yom Tov of Pesach, Shavuot, Sukkot,\n * Shmini Atzeret, Simchat Torah, Yom Ha'atzmaut, and Yom Yerushalayim.\n *\n * Half Hallel is said on Rosh Chodesh (not Rosh Hashanah), and the last 6 days of Pesach.\n * Rosh Chodesh Tevet falls during Chanukah, so whole Hallel is said then.\n *\n * The result is computed directly from the Hebrew month and day,\n * without generating holiday events.\n * @example\n * import {hallel, HDate, months} from '@hebcal/core';\n * hallel(new HDate(25, months.KISLEV, 5784), false); // 2 (Chanukah)\n * hallel(new HDate(1, months.SHVAT, 5784), false); // 1 (Rosh Chodesh)\n * hallel(new HDate(2, months.SHVAT, 5784), false); // 0\n * hallel(new HDate(16, months.NISAN, 5784), false); // 2 (Pesach II, Diaspora)\n * hallel(new HDate(16, months.NISAN, 5784), true); // 1 (Chol HaMoed, Israel)\n * @param hdate Hebrew date to test\n * @param il use the Israeli holiday schedule\n * @returns 0 for no Hallel, 1 for half Hallel, 2 for whole Hallel\n */\nexport function hallel(hdate: HDate, il: boolean): number {\n const mm = hdate.getMonth();\n const dd = hdate.getDate();\n switch (mm) {\n case months.TISHREI:\n // Sukkot (15-21), Shmini Atzeret (22), Simchat Torah (23, Diaspora)\n if (dd >= 15 && dd <= (il ? 22 : 23)) {\n return WHOLE;\n }\n break;\n case months.KISLEV:\n // Chanukah begins 25 Kislev; the first candle on the evening of\n // 24 Kislev precedes the first morning of Chanukah\n if (dd >= 25) {\n return WHOLE;\n }\n break;\n case months.TEVET: {\n // Chanukah lasts 8 days, ending on 2 Tevet (3 Tevet if Kislev is short)\n const lastDay = shortKislev(hdate.getFullYear()) ? 3 : 2;\n if (dd <= lastDay) {\n return WHOLE;\n }\n break;\n }\n case months.NISAN:\n // First day(s) of Pesach\n if (dd === 15 || (dd === 16 && !il)) {\n return WHOLE;\n }\n // Remaining days of Pesach\n if (dd >= 16 && dd <= (il ? 21 : 22)) {\n return HALF;\n }\n break;\n case months.IYYAR: {\n const year = hdate.getFullYear();\n // Yom Yerushalayim\n if (dd === 28 && year >= 5727) {\n return WHOLE;\n }\n // Yom Ha'atzmaut, the day after Yom HaZikaron\n const yomHaZikaron = dateYomHaZikaron(year);\n if (yomHaZikaron !== null && dd === yomHaZikaron.getDate() + 1) {\n return WHOLE;\n }\n break;\n }\n case months.SIVAN:\n // Shavuot\n if (dd === 6 || (dd === 7 && !il)) {\n return WHOLE;\n }\n break;\n default:\n break;\n }\n\n // Rosh Chodesh: the 30th of any month, or the 1st of any month\n // other than Tishrei (Rosh Hashana)\n if (dd === 30 || (dd === 1 && mm !== months.TISHREI)) {\n return HALF;\n }\n\n return NONE;\n}\n"],"names":[],"mappings":";;;;AAGA,MAAM,IAAI,GAAG,CAAC;AACd,MAAM,IAAI,GAAG,CAAC;AACd,MAAM,KAAK,GAAG,CAAC;AAEf;;;;;;;;;;;;;;;;;;;;;;;;AAwBG;AACG,SAAU,MAAM,CAAC,KAAY,EAAE,EAAW,EAAA;AAC9C,IAAA,MAAM,EAAE,GAAG,KAAK,CAAC,QAAQ,EAAE;AAC3B,IAAA,MAAM,EAAE,GAAG,KAAK,CAAC,OAAO,EAAE;IAC1B,QAAQ,EAAE;QACR,KAAK,MAAM,CAAC,OAAO;;AAEjB,YAAA,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC,EAAE;AACpC,gBAAA,OAAO,KAAK;YACd;YACA;QACF,KAAK,MAAM,CAAC,MAAM;;;AAGhB,YAAA,IAAI,EAAE,IAAI,EAAE,EAAE;AACZ,gBAAA,OAAO,KAAK;YACd;YACA;AACF,QAAA,KAAK,MAAM,CAAC,KAAK,EAAE;;AAEjB,YAAA,M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/licenses/gpl-2.0.txt */
1
+ /*! @hebcal/core v6.17.0, distributed under GPLv2 or later https://www.gnu.org/licenses/gpl-2.0.txt */
2
2
  var noNikudOverride = { "headers": { "plural-forms": "nplurals=2; plural=(n != 1);", "language": "he-x-NoNikud" }, "contexts": { "": { "Korach": ["קורח"], "Chukat": ["חוקת"], "Erev Yom Kippur": ["ערב יום כיפור"], "Yom Kippur": ["יום כיפור"], "Yom Kippur Katan": ["יום כיפור קטן"], "Pesach Shabbat Chol ha-Moed": ["שבת חול המועד פסח"], "Sukkot Shabbat Chol ha-Moed": ["שבת חול המועד סוכות"], "Erev Sukkot": ["ערב סוכות"], "Sukkot": ["סוכות"], "Sukkot I": ["סוכות א׳"], "Sukkot II": ["סוכות ב׳"], "Sukkot II (CH''M)": ["סוכות ב׳ (חוה״מ)"], "Sukkot III (CH''M)": ["סוכות ג׳ (חוה״מ)"], "Sukkot IV (CH''M)": ["סוכות ד׳ (חוה״מ)"], "Sukkot V (CH''M)": ["סוכות ה׳ (חוה״מ)"], "Sukkot VI (CH''M)": ["סוכות ו׳ (חוה״מ)"], "Sukkot VII (Hoshana Raba)": ["סוכות ז׳ (הושענא רבה)"], "Swords of Iron War Memorial Day": ["יום הזיכרון לחללי מלחמת חרבות ברזל"], "Latest Kiddush Levana": ["סוף זמן קידוש לבנה"] } } };
3
3
 
4
4
  export { noNikudOverride as default };
package/dist/esm/he.po.js CHANGED
@@ -1,4 +1,4 @@
1
- /*! @hebcal/core v6.16.1, distributed under GPLv2 or later https://www.gnu.org/licenses/gpl-2.0.txt */
1
+ /*! @hebcal/core v6.17.0, distributed under GPLv2 or later https://www.gnu.org/licenses/gpl-2.0.txt */
2
2
  var poHe = { "headers": { "plural-forms": "nplurals=2; plural=(n > 1);", "language": "he_IL" }, "contexts": { "": { "Shabbat": ["שַׁבָּת"], "Parashat": ["פָּרָשַׁת"], "Achrei Mot": ["אַחֲרֵי מוֹת"], "Balak": ["בָּלָק"], "Bamidbar": ["בְּמִדְבַּר"], "Bechukotai": ["בְּחֻקֹּתַי"], "Beha'alotcha": ["בְּהַעֲלֹתְךָ"], "Behar": ["בְּהַר"], "Bereshit": ["בְּרֵאשִׁית"], "Beshalach": ["בְּשַׁלַּח"], "Bo": ["בֹּא"], "Chayei Sara": ["חַיֵּי שָֹרָה"], "Chukat": ["חֻקַּת"], "Devarim": ["דְּבָרִים"], "Eikev": ["עֵקֶב"], "Emor": ["אֱמוֹר"], "Ha'azinu": ["הַאֲזִינוּ"], "Kedoshim": ["קְדֹשִׁים"], "Ki Tavo": ["כִּי־תָבוֹא"], "Ki Teitzei": ["כִּי־תֵצֵא"], "Ki Tisa": ["כִּי תִשָּׂא"], "Korach": ["קֹרַח"], "Lech-Lecha": ["לֶךְ־לְךָ"], "Masei": ["מַסְעֵי"], "Matot": ["מַטּוֹת"], "Metzora": ["מְצֹרָע"], "Miketz": ["מִקֵּץ"], "Mishpatim": ["מִשְׁפָּטִים"], "Nasso": ["נָשׂא"], "Nitzavim": ["נִצָּבִים"], "Noach": ["נֹחַ"], "Pekudei": ["פְקוּדֵי"], "Pinchas": ["פִּינְחָס"], "Re'eh": ["רְאֵה"], "Sh'lach": ["שְׁלַח־לְךָ"], "Shemot": ["שְׁמוֹת"], "Shmini": ["שְּׁמִינִי"], "Shoftim": ["שׁוֹפְטִים"], "Tazria": ["תַזְרִיעַ"], "Terumah": ["תְּרוּמָה"], "Tetzaveh": ["תְּצַוֶּה"], "Toldot": ["תּוֹלְדוֹת"], "Tzav": ["צַו"], "Vaera": ["וָאֵרָא"], "Vaetchanan": ["וָאֶתְחַנַּן"], "Vayakhel": ["וַיַּקְהֵל"], "Vayechi": ["וַיְחִי"], "Vayeilech": ["וַיֵּלֶךְ"], "Vayera": ["וַיֵּרָא"], "Vayeshev": ["וַיֵּשֶׁב"], "Vayetzei": ["וַיֵּצֵא"], "Vayigash": ["וַיִּגַּשׁ"], "Vayikra": ["וַיִּקְרָא"], "Vayishlach": ["וַיִּשְׁלַח"], "Vezot Haberakhah": ["וְזֹאת הַבְּרָכָה"], "Yitro": ["יִתְרוֹ"], "Asara B'Tevet": ["עֲשָׂרָה בְּטֵבֵת"], "Candle lighting": ["הַדְלָקַת נֵרוֹת"], "Chanukah": ["חֲנוּכָּה"], "Chanukah: 1 Candle": ["חֲנוּכָּה: א׳ נֵר"], "Chanukah: 2 Candles": ["חֲנוּכָּה: ב׳ נֵרוֹת"], "Chanukah: 3 Candles": ["חֲנוּכָּה: ג׳ נֵרוֹת"], "Chanukah: 4 Candles": ["חֲנוּכָּה: ד׳ נֵרוֹת"], "Chanukah: 5 Candles": ["חֲנוּכָּה: ה׳ נֵרוֹת"], "Chanukah: 6 Candles": ["חֲנוּכָּה: ו׳ נֵרוֹת"], "Chanukah: 7 Candles": ["חֲנוּכָּה: ז׳ נֵרוֹת"], "Chanukah: 8 Candles": ["חֲנוּכָּה: ח׳ נֵרוֹת"], "Chanukah: 8th Day": ["חֲנוּכָּה: יוֹם ח׳"], "Days of the Omer": ["סְפִירַת הָעוֹמֶר"], "Omer": ["עוֹמֶר"], "day of the Omer": ["בָּעוֹמֶר"], "Erev Pesach": ["עֶרֶב פֶּסַח"], "Erev Purim": ["עֶרֶב פּוּרִים"], "Erev Rosh Hashana": ["עֶרֶב רֹאשׁ הַשָּׁנָה"], "Erev Shavuot": ["עֶרֶב שָׁבוּעוֹת"], "Erev Simchat Torah": ["עֶרֶב שִׂמְחַת תּוֹרָה"], "Erev Sukkot": ["עֶרֶב סֻכּוֹת"], "Erev Tish'a B'Av": ["עֶרֶב תִּשְׁעָה בְּאָב"], "Erev Yom Kippur": ["עֶרֶב יוֹם כִּפּוּר"], "Havdalah": ["הַבְדָּלָה"], "Lag BaOmer": ["ל״ג בָּעוֹמֶר"], "Leil Selichot": ["סְלִיחוֹת"], "Pesach": ["פֶּסַח"], "Pesach I": ["פֶּסַח א׳"], "Pesach II": ["פֶּסַח ב׳"], "Pesach II (CH''M)": ["פֶּסַח ב׳ (חוה״מ)"], "Pesach III (CH''M)": ["פֶּסַח ג׳ (חוה״מ)"], "Pesach IV (CH''M)": ["פֶּסַח ד׳ (חוה״מ)"], "Pesach Sheni": ["פֶּסַח שֵׁנִי"], "Pesach V (CH''M)": ["פֶּסַח ה׳ (חוה״מ)"], "Pesach VI (CH''M)": ["פֶּסַח ו׳ (חוה״מ)"], "Pesach VII": ["פֶּסַח ז׳"], "Pesach VIII": ["פֶּסַח ח׳"], "Pesach Shabbat Chol ha-Moed": ["שַׁבַּת חֹל הַמּוֹעֵד פֶּסַח"], "Purim": ["פּוּרִים"], "Purim Katan": ["פּוּרִים קָטָן"], "Rosh Chodesh": ["רֹאשׁ חוֹדֶשׁ"], "Rosh Hashana": ["רֹאשׁ הַשָּׁנָה"], "Rosh Hashana I": ["רֹאשׁ הַשָּׁנָה א׳"], "Rosh Hashana II": ["רֹאשׁ הַשָּׁנָה ב׳"], "Shabbat Chazon": ["שַׁבַּת חֲזוֹן"], "Shabbat HaChodesh": ["שַׁבַּת הַחֹדֶשׁ"], "Shabbat HaGadol": ["שַׁבַּת הַגָּדוֹל"], "Shabbat Nachamu": ["שַׁבַּת נַחֲמוּ"], "Shabbat Parah": ["שַׁבַּת פָּרָה"], "Shabbat Shekalim": ["שַׁבַּת שְׁקָלִים"], "Shabbat Shuva": ["שַׁבַּת שׁוּבָה"], "Shabbat Zachor": ["שַׁבַּת זָכוֹר"], "Shavuot": ["שָׁבוּעוֹת"], "Shavuot I": ["שָׁבוּעוֹת א׳"], "Shavuot II": ["שָׁבוּעוֹת ב׳"], "Shmini Atzeret": ["שְׁמִינִי עֲצֶרֶת"], "Shushan Purim": ["שׁוּשָׁן פּוּרִים"], "Sigd": ["חַג הַסִּיגְד"], "Simchat Torah": ["שִׂמְחַת תּוֹרָה"], "Sukkot": ["סֻכּוֹת"], "Sukkot I": ["סֻכּוֹת א׳"], "Sukkot II": ["סֻכּוֹת ב׳"], "Sukkot II (CH''M)": ["סֻכּוֹת ב׳ (חוה״מ)"], "Sukkot III (CH''M)": ["סֻכּוֹת ג׳ (חוה״מ)"], "Sukkot IV (CH''M)": ["סֻכּוֹת ד׳ (חוה״מ)"], "Sukkot V (CH''M)": ["סֻכּוֹת ה׳ (חוה״מ)"], "Sukkot VI (CH''M)": ["סֻכּוֹת ו׳ (חוה״מ)"], "Sukkot VII (Hoshana Raba)": ["סֻכּוֹת ז׳ (הוֹשַׁעְנָא רַבָּה)"], "Sukkot Shabbat Chol ha-Moed": ["שַׁבַּת חֹל הַמּוֹעֵד סֻכּוֹת"], "Ta'anit Bechorot": ["תַּעֲנִית בְּכוֹרוֹת"], "Ta'anit BeHaB": ["תַּעֲנִית בה״ב"], "Ta'anit Esther": ["תַּעֲנִית אֶסְתֵּר"], "Tish'a B'Av": ["תִּשְׁעָה בְּאָב"], "Tu B'Av": ["ט״וּ בְּאָב"], "Tu BiShvat": ["ט״וּ בִּשְׁבָט"], "Tu B'Shvat": ["ט״וּ בִּשְׁבָט"], "Tzom Gedaliah": ["צוֹם גְּדַלְיָה"], "Tzom Tammuz": ["צוֹם י״ז בְּתַמּוּז"], "Yom HaAtzma'ut": ["יוֹם הָעַצְמָאוּת"], "Yom HaShoah": ["יוֹם הַשּׁוֹאָה"], "Yom HaZikaron": ["יוֹם הַזִּכָּרוֹן"], "Yom Kippur": ["יוֹם כִּפּוּר"], "Yom Yerushalayim": ["יוֹם יְרוּשָׁלַיִם"], "Yom HaAliyah": ["יוֹם הַעֲלִיָּה"], "Yom HaAliyah School Observance": ["שְׁמִירָת בֵּית הַסֵפֶר לְיוֹם הַעֲלִיָּה"], "Rosh Chodesh Adar": ["רֹאשׁ חוֹדֶשׁ אֲדָר"], "Rosh Chodesh Adar I": ["רֹאשׁ חוֹדֶשׁ אֲדָר א׳"], "Rosh Chodesh Adar II": ["רֹאשׁ חוֹדֶשׁ אֲדָר ב׳"], "Rosh Chodesh Av": ["רֹאשׁ חוֹדֶשׁ אָב"], "Rosh Chodesh Cheshvan": ["רֹאשׁ חוֹדֶשׁ חֶשְׁוָן"], "Rosh Chodesh Elul": ["רֹאשׁ חוֹדֶשׁ אֱלוּל"], "Rosh Chodesh Iyyar": ["רֹאשׁ חוֹדֶשׁ אִיָּיר"], "Rosh Chodesh Kislev": ["רֹאשׁ חוֹדֶשׁ כִּסְלֵו"], "Rosh Chodesh Nisan": ["רֹאשׁ חוֹדֶשׁ נִיסָן"], "Rosh Chodesh Sh'vat": ["רֹאשׁ חוֹדֶשׁ שְׁבָט"], "Rosh Chodesh Sivan": ["רֹאשׁ חוֹדֶשׁ סִיוָן"], "Rosh Chodesh Tamuz": ["רֹאשׁ חוֹדֶשׁ תַּמּוּז"], "Rosh Chodesh Tammuz": ["רֹאשׁ חוֹדֶשׁ תַּמּוּז"], "Rosh Chodesh Tevet": ["רֹאשׁ חוֹדֶשׁ טֵבֵת"], "min": ["דַּקּוֹת"], "Fast begins": ["תְּחִילַּת הַצוֹם"], "Fast ends": ["סִיּוּם הַצוֹם"], "Rosh Hashana LaBehemot": ["רֹאשׁ הַשָּׁנָה לְמַעְשַׂר בְּהֵמָה"], "Tish'a B'Av (observed)": ["(תִּשְׁעָה בְּאָב (נִדְחָה"], "Shabbat Mevarchim Chodesh": ["שַׁבַּת מְבָרְכִים חוֹדֶשׁ"], "Shabbat Shirah": ["שַׁבַּת שִׁירָה"], "Lovingkindness": ["חֶסֶד"], "Might": ["גְּבוּרָה"], "Beauty": ["תִּפְאֶרֶת"], "Eternity": ["נֶּצַח"], "Splendor": ["הוֹד"], "Foundation": ["יְּסוֹד"], "Majesty": ["מַּלְכוּת"], "day": ["יוֹם"], "Yom Kippur Katan": ["יוֹם כִּפּוּר קָטָן"], "Yizkor": ["יִזְכּוֹר"], "Family Day": ["יוֹם הַמִּשׁפָּחָה"], "Yitzhak Rabin Memorial Day": ["יוֹם הַזִּכָּרוֹן לְיִצְחָק רַבִּין"], "Jabotinsky Day": ["יוֹם זַ׳בּוֹטִינְסְקִי"], "Herzl Day": ["יוֹם הֶרְצְל"], "Ben-Gurion Day": ["יוֹם בֶּן־גּוּרִיּוֹן"], "Hebrew Language Day": ["יוֹם הַשָׂפָה הַעִברִית"], "Birkat Hachamah": ["בִּרְכַּת הַחַמָּה"], "Birkat HaChamah": ["בִּרְכַּת הַחַמָּה"], "Shushan Purim Katan": ["שׁוּשָׁן פּוּרִים קָטָן"], "Purim Meshulash": ["פּוּרִים מְשׁוּלָּשׁ"], "Chag HaBanot": ["חַג הַבָּנוֹת"], "Molad": ["מוֹלָד הָלְּבָנָה"], "chalakim": ["חֲלָקִים"], "Alot HaShachar": ["עֲלוֹת הַשַּׁחַר"], "Misheyakir": ["מִשֶּׁיַּכִּיר"], "Misheyakir Machmir": ["מִשֶּׁיַּכִּיר מַחְמִיר"], "Sunrise": ["נֵץ הַחַמָּה"], "Kriat Shema, sof zeman": ["סוֹף זְמַן קְרִיאַת שְׁמַע"], "Tefilah, sof zeman": ["סוֹף זְמַן תְּפִלָּה"], "Kriat Shema, sof zeman (MGA)": ["סוֹף זְמַן קְרִיאַת שְׁמַע (מג״א)"], "Kriat Shema, sof zeman (GRA)": ["סוֹף זְמַן קְרִיאַת שְׁמַע (גְּרָ״א)"], "Tefilah, sof zeman (MGA)": ["סוֹף זְמַן תְּפִלָּה (מג״א)"], "Tefilah, sof zeman (GRA)": ["סוֹף זְמַן תְּפִלָּה (גְּרָ״א)"], "Chatzot HaLailah": ["חֲצוֹת הַלַּיְלָה"], "Chatzot HaYom": ["חֲצוֹת הַיּוֹם"], "Chatzot hayom": ["חֲצוֹת הַיּוֹם"], "Mincha Gedolah": ["מִנְחָה גְּדוֹלָה"], "Mincha Ketanah": ["מִנְחָה קְטַנָּה"], "Plag HaMincha": ["פְּלַג הַמִּנְחָה"], "Sunset": ["שְׁקִיעַת הַחַמָּה"], "Bein HaShemashot": ["בֵּין הַשְּׁמָשׁוֹת"], "Tzeit HaKochavim": ["צֵאת הַכּוֹכָבִים"], "Biur Chametz": ["בִּעוּר חָמֵץ"], "Finish eating chametz": ["סוֹף זְמַן אֲכִילַת חָמֵץ"], "Swords of Iron War Memorial Day": ["יוֹם הַזִּכָּרוֹן לְחַלְלֵי מִלְחֶמֶת חַרְבוֹת בַּרְזֶל"], "Latest Kiddush Levana": ["סוֹף זְמַן קִדּוּשׁ לְבָנָה"] } } };
3
3
 
4
4
  export { poHe as default };
@@ -1,9 +1,10 @@
1
- /*! @hebcal/core v6.16.1, distributed under GPLv2 or later https://www.gnu.org/licenses/gpl-2.0.txt */
1
+ /*! @hebcal/core v6.17.0, distributed under GPLv2 or later https://www.gnu.org/licenses/gpl-2.0.txt */
2
2
  import { birthdayOrAnniversary, yahrzeit, HDate } from '@hebcal/hdate';
3
3
  import './locale.js';
4
4
  import { version } from './pkgVersion.js';
5
5
  import { getSedra } from './sedra.js';
6
6
  import { hallel } from './hallel.js';
7
+ import { isYomTov } from './isYomTov.js';
7
8
  import { getHolidaysForYear_, getHolidaysForYearArray, getHolidaysOnDate } from './holidays.js';
8
9
  import { reformatTimeStr } from './reformatTimeStr.js';
9
10
  import { tachanun } from './tachanun.js';
@@ -220,7 +221,7 @@ class HebrewCalendar {
220
221
  const today = new HDate(date);
221
222
  const friday = today.after(5);
222
223
  const tomorrow = today.next();
223
- return isChag(friday, il) && !isChag(today, il) && isChag(tomorrow, il);
224
+ return isYomTov(friday, il) && !isYomTov(today, il) && isYomTov(tomorrow, il);
224
225
  }
225
226
  /**
226
227
  * Helper function to format a 24-hour (00:00-23:59) time string in either
@@ -319,10 +320,6 @@ class HebrewCalendar {
319
320
  return tachanun(hdate, il);
320
321
  }
321
322
  }
322
- function isChag(date, il) {
323
- const events = getHolidaysOnDate(date, il) ?? [];
324
- return events.some(ev => ev.hasFlag('CHAG'));
325
- }
326
323
 
327
324
  export { HebrewCalendar };
328
325
  //# sourceMappingURL=hebcal.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"hebcal.js","sources":["../../../src/hebcal.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 */\n\nimport {birthdayOrAnniversary, yahrzeit, HDate} from '@hebcal/hdate';\nimport './locale.js'; // Adds Hebrew and Ashkenazic translations\nimport {CalOptions} from './CalOptions.js';\nimport {version as pkgVersion} from './pkgVersion.js';\nimport {Event} from './event.js';\nimport {Sedra, getSedra} from './sedra.js';\nimport {hallel} from './hallel.js';\nimport {\n getHolidaysForYear_,\n getHolidaysForYearArray,\n getHolidaysOnDate,\n HolidayYearMap,\n} from './holidays.js';\nimport {HolidayEvent} from './HolidayEvent.js';\nimport {reformatTimeStr} from './reformatTimeStr.js';\nimport {TachanunResult, tachanun} from './tachanun.js';\nimport {calendar} from './calendar.js';\n\n/**\n * HebrewCalendar is the main interface to the `@hebcal/core` library.\n * This namespace is used to calculate holidays, rosh chodesh, candle lighting & havdalah times,\n * Parashat HaShavua, Daf Yomi, days of the omer, and the molad.\n * Event names can be rendered in several languges using the `locale` option.\n */\nexport class HebrewCalendar {\n private constructor() {}\n /**\n * Calculates holidays and other Hebrew calendar events based on {@link CalOptions}.\n *\n * Each holiday is represented by an {@link Event} object which includes a date,\n * a description, flags and optional attributes.\n * If given no options, returns holidays for the Diaspora for the current Gregorian year.\n *\n * This is a convenience wrapper around the standalone {@link calendar} function.\n * See {@link calendar} for the complete list of supported options, the\n * candle-lighting and Havdalah defaults, and notes on locales.\n *\n * @example\n * import {HebrewCalendar, Location} from '@hebcal/core';\n * const options: CalOptions = {\n * year: 1981,\n * isHebrewYear: false,\n * candlelighting: true,\n * location: Location.lookup('San Francisco'),\n * sedrot: true,\n * omer: true,\n * };\n * const events = HebrewCalendar.calendar(options);\n * for (const ev of events) {\n * const hd = ev.getDate();\n * const date = hd.greg();\n * console.log(date.toLocaleDateString(), ev.render('en'), hd.toString());\n * }\n */\n static calendar(options: CalOptions = {}): Event[] {\n return calendar(options);\n }\n\n /**\n * Calculates a birthday or anniversary (non-yahrzeit).\n * Returns `undefined` when `hyear` precedes the original year of `gdate`.\n *\n * When `hyear` is the original year, the original date is returned unchanged —\n * a \"0th birthday\" is a meaningful thing to ask for. This differs from\n * {@link getYahrzeit}, which returns `undefined` for the original year,\n * because a yahrzeit only has meaning from the first anniversary onward.\n *\n * Hebcal uses the algorithm defined in \"Calendrical Calculations\"\n * by Edward M. Reingold and Nachum Dershowitz.\n *\n * The birthday of someone born in Adar of an ordinary year or Adar II of\n * a leap year is also always in the last month of the year, be that Adar\n * or Adar II. The birthday in an ordinary year of someone born during the\n * first 29 days of Adar I in a leap year is on the corresponding day of Adar;\n * in a leap year, the birthday occurs in Adar I, as expected.\n *\n * Someone born on the thirtieth day of Marcheshvan, Kislev, or Adar I\n * has his birthday postponed until the first of the following month in\n * years where that day does not occur. [Calendrical Calculations p. 111]\n * @example\n * import {HebrewCalendar} from '@hebcal/core';\n * const dt = new Date(2014, 2, 2); // '2014-03-02' == '30 Adar I 5774'\n * const hd = HebrewCalendar.getBirthdayOrAnniversary(5780, dt); // '1 Nisan 5780'\n * console.log(hd.greg().toLocaleDateString('en-US')); // '3/26/2020'\n * @param hyear Hebrew year\n * @param gdate Gregorian or Hebrew date of event\n * @returns anniversary occurring in `hyear`\n */\n static getBirthdayOrAnniversary(\n hyear: number,\n gdate: Date | HDate\n ): HDate | undefined {\n return birthdayOrAnniversary(hyear, gdate);\n }\n\n /**\n * Calculates yahrzeit.\n * `hyear` must be after original `gdate` of death.\n * Returns `undefined` when requested year preceeds or is same as original year.\n *\n * Hebcal uses the algorithm defined in \"Calendrical Calculations\"\n * by Edward M. Reingold and Nachum Dershowitz.\n *\n * The customary anniversary date of a death is more complicated and depends\n * also on the character of the year in which the first anniversary occurs.\n * There are several cases:\n *\n * * If the date of death is Marcheshvan 30, the anniversary in general depends\n * on the first anniversary; if that first anniversary was not Marcheshvan 30,\n * use the day before Kislev 1.\n * * If the date of death is Kislev 30, the anniversary in general again depends\n * on the first anniversary — if that was not Kislev 30, use the day before\n * Tevet 1.\n * * If the date of death is Adar II, the anniversary is the same day in the\n * last month of the Hebrew year (Adar or Adar II).\n * * If the date of death is Adar I 30, the anniversary in a Hebrew year that\n * is not a leap year (in which Adar only has 29 days) is the last day in\n * Shevat.\n * * In all other cases, use the normal (that is, same month number) anniversary\n * of the date of death. [Calendrical Calculations p. 113]\n * @example\n * import {HebrewCalendar} from '@hebcal/core';\n * const dt = new Date(2014, 2, 2); // '2014-03-02' == '30 Adar I 5774'\n * const hd = HebrewCalendar.getYahrzeit(5780, dt); // '30 Sh\\'vat 5780'\n * console.log(hd.greg().toLocaleDateString('en-US')); // '2/25/2020'\n * @param hyear Hebrew year\n * @param gdate Gregorian or Hebrew date of death\n * @returns anniversary occurring in hyear\n */\n static getYahrzeit(hyear: number, gdate: Date | HDate): HDate | undefined {\n return yahrzeit(hyear, gdate);\n }\n\n /**\n * Lower-level holidays interface, which returns a `Map` of `Event`s indexed by\n * `HDate.toString()`. These events are not filtered by Israel vs. Diaspora\n * holiday scheme; use {@link Event.observedIn} to do that.\n *\n * Includes Rosh Chodesh, fasts, Yom Kippur Katan, Special Shabbatot, etc.,\n * but does not generate candle-lighting times, Torah readings, or Omer days.\n * The result is cached in an internal LRU.\n * @example\n * import {HebrewCalendar} from '@hebcal/core';\n * const map = HebrewCalendar.getHolidaysForYear(5784);\n * for (const [hdStr, events] of map.entries()) {\n * for (const ev of events) {\n * console.log(hdStr, ev.getDesc());\n * }\n * }\n * @param year Hebrew year\n */\n static getHolidaysForYear(year: number): HolidayYearMap {\n return getHolidaysForYear_(year);\n }\n\n /**\n * Returns a sorted array of holidays observed during the given Hebrew year.\n *\n * Events are pre-filtered by Israel vs. Diaspora schedule, so callers do not\n * need to inspect `flags.IL_ONLY` / `flags.CHUL_ONLY` themselves.\n * Includes Rosh Chodesh, fasts, modern holidays, special Shabbatot, etc.,\n * but does not generate candle-lighting times, Torah readings, or Omer days.\n * @example\n * import {HebrewCalendar} from '@hebcal/core';\n * const events = HebrewCalendar.getHolidaysForYearArray(5784, false);\n * console.log(events[0].getDesc()); // 'Rosh Hashana 5784'\n * @param year Hebrew year\n * @param il use the Israeli schedule for holidays\n */\n static getHolidaysForYearArray(year: number, il: boolean): HolidayEvent[] {\n return getHolidaysForYearArray(year, il);\n }\n\n /**\n * Returns an array of holiday Events that occur on the given date,\n * or `undefined` if no holidays occur that day.\n *\n * When `il` is omitted, both Diaspora-only and Israel-only events are\n * returned; pass `true` or `false` to filter to a single schedule.\n * @example\n * import {HebrewCalendar, HDate, months} from '@hebcal/core';\n * const hd = new HDate(15, months.NISAN, 5784);\n * const events = HebrewCalendar.getHolidaysOnDate(hd, false);\n * console.log(events?.map(ev => ev.getDesc())); // ['Pesach I']\n * @param date Hebrew Date, Gregorian date, or absolute R.D. day number\n * @param [il] use the Israeli schedule for holidays\n */\n static getHolidaysOnDate(\n date: HDate | Date | number,\n il?: boolean\n ): HolidayEvent[] | undefined {\n return getHolidaysOnDate(date, il);\n }\n\n /**\n * Returns `true` if Eruv Tavshilin should be prepared on the given date.\n *\n * Eruv Tavshilin is prepared when a Yom Tov falls on Friday (so cooking\n * for Shabbat that begins Friday night may continue from Yom Tov into\n * Shabbat). This requires the day before to be a weekday (Wednesday or\n * Thursday), the following Friday to be Yom Tov, and the day after Friday\n * (Shabbat) to also be a sacred day.\n * @example\n * import {HebrewCalendar} from '@hebcal/core';\n * // Wednesday October 16, 2024 is Erev Sukkot 5785. In the Diaspora,\n * // Sukkot I falls on Thursday and Sukkot II on Friday, so Eruv\n * // Tavshilin is prepared on Wednesday:\n * HebrewCalendar.eruvTavshilin(new Date(2024, 9, 16), false); // true\n * // In Israel there is only one day of Yom Tov, so Friday is a weekday:\n * HebrewCalendar.eruvTavshilin(new Date(2024, 9, 16), true); // false\n * @param date Gregorian or Hebrew date to test\n * @param il use the Israeli holiday schedule\n */\n static eruvTavshilin(date: Date | HDate, il: boolean): boolean {\n const dow = date.getDay();\n if (dow < 3 || dow > 4) {\n return false;\n }\n const today = new HDate(date);\n const friday = today.after(5);\n const tomorrow = today.next();\n return isChag(friday, il) && !isChag(today, il) && isChag(tomorrow, il);\n }\n\n /**\n * Helper function to format a 24-hour (00:00-23:59) time string in either\n * 12-hour US format (e.g. `\"8:13pm\"`) or keep it in 24-hour format (e.g.\n * `\"20:13\"`) for any other locale or country.\n *\n * The locale (and therefore default behavior) is derived from\n * `options.location` / `options.locale`. The `options.hour12` override\n * takes precedence: if `false`, locale is ignored and the result is always\n * 24-hour; if `true`, locale is ignored and the result is always 12-hour.\n * @example\n * import {HebrewCalendar, Location} from '@hebcal/core';\n * const opts = {location: Location.lookup('Chicago')};\n * HebrewCalendar.reformatTimeStr('20:30', 'pm', opts); // '8:30pm'\n * HebrewCalendar.reformatTimeStr('20:30', 'pm', {hour12: false}); // '20:30'\n * @param timeStr - original time like \"20:30\"\n * @param suffix - \"p\" or \"pm\" or \" P.M.\". Add leading space if you want it\n * @param options optional; `location`, `locale` and `hour12` are consulted\n */\n static reformatTimeStr(\n timeStr: string,\n suffix: string,\n options?: CalOptions\n ): string {\n return reformatTimeStr(timeStr, suffix, options);\n }\n\n /**\n * Returns the semantic version string of the `@hebcal/core` package\n * (e.g. `\"6.8.2\"`). Useful for logging or feature detection.\n */\n static version(): string {\n return pkgVersion;\n }\n\n /**\n * Convenience function to create an instance of {@link Sedra} or reuse a\n * previously created and cached instance for the same year + schedule.\n *\n * Use this in preference to `new Sedra(...)` when calling repeatedly,\n * since an internal LRU cache (~120 entries) avoids recomputing the\n * keviyah-specific reading pattern.\n * @example\n * import {HebrewCalendar, HDate} from '@hebcal/core';\n * const sedra = HebrewCalendar.getSedra(5784, false);\n * const result = sedra.lookup(new HDate(15, 'Cheshvan', 5784));\n * console.log(result.parsha); // ['Vayera']\n * @param hyear Hebrew year\n * @param il Use Israel sedra schedule (`false` for Diaspora)\n */\n static getSedra(hyear: number, il: boolean): Sedra {\n return getSedra(hyear, il);\n }\n\n /**\n * Determines which form of Hallel (if any) is recited on a given Hebrew date:\n * 0 (none), 1 (half Hallel), or 2 (whole Hallel).\n * See {@link hallel} for details.\n * @example\n * import {HebrewCalendar, HDate, months} from '@hebcal/core';\n * HebrewCalendar.hallel(new HDate(25, months.KISLEV, 5784), false); // 2 (Chanukah)\n * HebrewCalendar.hallel(new HDate(1, months.SHVAT, 5784), false); // 1 (Rosh Chodesh)\n * HebrewCalendar.hallel(new HDate(2, months.SHVAT, 5784), false); // 0\n * @param hdate Hebrew date to test\n * @param il use the Israeli holiday schedule\n * @returns 0 for no Hallel, 1 for half Hallel, 2 for whole Hallel\n */\n static hallel(hdate: HDate, il: boolean): number {\n return hallel(hdate, il);\n }\n\n /**\n * Return details on what Tachanun (or Tzidchatcha on Shabbat) is said on `hdate`.\n *\n * Tachanun is not said on Rosh Chodesh, the month of Nisan, Lag Baomer,\n * Rosh Chodesh Sivan until Isru Chag, Tisha B'av, 15 Av, Erev Rosh Hashanah,\n * Rosh Hashanah, Erev Yom Kippur until after Simchat Torah, Chanukah,\n * Tu B'shvat, Purim and Shushan Purim, and Purim and Shushan Purim Katan.\n *\n * In some congregations Tachanun is not said until from Rosh Chodesh Sivan\n * until 14th Sivan, Sukkot until after Rosh Chodesh Cheshvan, Pesach Sheini,\n * Yom Ha'atzmaut, and Yom Yerushalayim.\n *\n * Tachanun is not said at Mincha on days before it is not said at Shacharit.\n *\n * Tachanun is not said at Shacharit on Shabbat, but is at Mincha, usually.\n * @example\n * import {HebrewCalendar, HDate, months} from '@hebcal/core';\n * // Regular weekday — Tachanun is said at both services\n * HebrewCalendar.tachanun(new HDate(4, months.SHVAT, 5784), false);\n * // => { shacharit: true, mincha: true, allCongs: true }\n *\n * // Friday 2 Sh'vat — said at Shacharit, but not at Mincha (erev Shabbat)\n * HebrewCalendar.tachanun(new HDate(2, months.SHVAT, 5784), false);\n * // => { shacharit: true, mincha: false, allCongs: true }\n *\n * // Rosh Chodesh — no Tachanun\n * HebrewCalendar.tachanun(new HDate(1, months.SHVAT, 5784), false);\n * // => { shacharit: false, mincha: false, allCongs: false }\n * @param hdate Hebrew date to test\n * @param il use the Israeli holiday schedule\n */\n static tachanun(hdate: HDate, il: boolean): TachanunResult {\n return tachanun(hdate, il);\n }\n}\n\nfunction isChag(date: HDate, il: boolean): boolean {\n const events = getHolidaysOnDate(date, il) ?? [];\n return events.some(ev => ev.hasFlag('CHAG'));\n}\n"],"names":["pkgVersion"],"mappings":";;;;;;;;;;;AAAA;;;;;;;;;;;;;;;;;;;AAmBG;AAoBH;;;;;AAKG;MACU,cAAc,CAAA;AACzB,IAAA,WAAA,GAAA,EAAuB;AACvB;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2BG;AACH,IAAA,OAAO,QAAQ,CAAC,OAAA,GAAsB,EAAE,EAAA;AACtC,QAAA,OAAO,QAAQ,CAAC,OAAO,CAAC;IAC1B;AAEA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6BG;AACH,IAAA,OAAO,wBAAwB,CAC7B,KAAa,EACb,KAAmB,EAAA;AAEnB,QAAA,OAAO,qBAAqB,CAAC,KAAK,EAAE,KAAK,CAAC;IAC5C;AAEA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiCG;AACH,IAAA,OAAO,WAAW,CAAC,KAAa,EAAE,KAAmB,EAAA;AACnD,QAAA,OAAO,QAAQ,CAAC,KAAK,EAAE,KAAK,CAAC;IAC/B;AAEA;;;;;;;;;;;;;;;;;AAiBG;IACH,OAAO,kBAAkB,CAAC,IAAY,EAAA;AACpC,QAAA,OAAO,mBAAmB,CAAC,IAAI,CAAC;IAClC;AAEA;;;;;;;;;;;;;AAaG;AACH,I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A,OAAO,MAAM,CAAC,KAAY,EAAE,EAAW,EAAA;AACrC,QAAA,OAAO,MAAM,CAAC,KAAK,EAAE,EAAE,CAAC;IAC1B;AAEA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8BG;AACH,IAAA,OAAO,QAAQ,CAAC,KAAY,EAAE,EAAW,EAAA;AACvC,QAAA,OAAO,QAAQ,CAAC,KAAK,EAAE,EAAE,CAAC;IAC5B;AACD;AAED,SAAS,MAAM,CAAC,IAAW,EAAE,EAAW,EAAA;IACtC,MAAM,MAAM,GAAG,iBAAiB,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,EAAE;AAChD,IAAA,OAAO,MAAM,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;AAC9C;;"}
1
+ {"version":3,"file":"hebcal.js","sources":["../../../src/hebcal.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 */\n\nimport {birthdayOrAnniversary, yahrzeit, HDate} from '@hebcal/hdate';\nimport './locale.js'; // Adds Hebrew and Ashkenazic translations\nimport {CalOptions} from './CalOptions.js';\nimport {version as pkgVersion} from './pkgVersion.js';\nimport {Event} from './event.js';\nimport {Sedra, getSedra} from './sedra.js';\nimport {hallel} from './hallel.js';\nimport {isYomTov} from './isYomTov.js';\nimport {\n getHolidaysForYear_,\n getHolidaysForYearArray,\n getHolidaysOnDate,\n HolidayYearMap,\n} from './holidays.js';\nimport {HolidayEvent} from './HolidayEvent.js';\nimport {reformatTimeStr} from './reformatTimeStr.js';\nimport {TachanunResult, tachanun} from './tachanun.js';\nimport {calendar} from './calendar.js';\n\n/**\n * HebrewCalendar is the main interface to the `@hebcal/core` library.\n * This namespace is used to calculate holidays, rosh chodesh, candle lighting & havdalah times,\n * Parashat HaShavua, Daf Yomi, days of the omer, and the molad.\n * Event names can be rendered in several languges using the `locale` option.\n */\nexport class HebrewCalendar {\n private constructor() {}\n /**\n * Calculates holidays and other Hebrew calendar events based on {@link CalOptions}.\n *\n * Each holiday is represented by an {@link Event} object which includes a date,\n * a description, flags and optional attributes.\n * If given no options, returns holidays for the Diaspora for the current Gregorian year.\n *\n * This is a convenience wrapper around the standalone {@link calendar} function.\n * See {@link calendar} for the complete list of supported options, the\n * candle-lighting and Havdalah defaults, and notes on locales.\n *\n * @example\n * import {HebrewCalendar, Location} from '@hebcal/core';\n * const options: CalOptions = {\n * year: 1981,\n * isHebrewYear: false,\n * candlelighting: true,\n * location: Location.lookup('San Francisco'),\n * sedrot: true,\n * omer: true,\n * };\n * const events = HebrewCalendar.calendar(options);\n * for (const ev of events) {\n * const hd = ev.getDate();\n * const date = hd.greg();\n * console.log(date.toLocaleDateString(), ev.render('en'), hd.toString());\n * }\n */\n static calendar(options: CalOptions = {}): Event[] {\n return calendar(options);\n }\n\n /**\n * Calculates a birthday or anniversary (non-yahrzeit).\n * Returns `undefined` when `hyear` precedes the original year of `gdate`.\n *\n * When `hyear` is the original year, the original date is returned unchanged —\n * a \"0th birthday\" is a meaningful thing to ask for. This differs from\n * {@link getYahrzeit}, which returns `undefined` for the original year,\n * because a yahrzeit only has meaning from the first anniversary onward.\n *\n * Hebcal uses the algorithm defined in \"Calendrical Calculations\"\n * by Edward M. Reingold and Nachum Dershowitz.\n *\n * The birthday of someone born in Adar of an ordinary year or Adar II of\n * a leap year is also always in the last month of the year, be that Adar\n * or Adar II. The birthday in an ordinary year of someone born during the\n * first 29 days of Adar I in a leap year is on the corresponding day of Adar;\n * in a leap year, the birthday occurs in Adar I, as expected.\n *\n * Someone born on the thirtieth day of Marcheshvan, Kislev, or Adar I\n * has his birthday postponed until the first of the following month in\n * years where that day does not occur. [Calendrical Calculations p. 111]\n * @example\n * import {HebrewCalendar} from '@hebcal/core';\n * const dt = new Date(2014, 2, 2); // '2014-03-02' == '30 Adar I 5774'\n * const hd = HebrewCalendar.getBirthdayOrAnniversary(5780, dt); // '1 Nisan 5780'\n * console.log(hd.greg().toLocaleDateString('en-US')); // '3/26/2020'\n * @param hyear Hebrew year\n * @param gdate Gregorian or Hebrew date of event\n * @returns anniversary occurring in `hyear`\n */\n static getBirthdayOrAnniversary(\n hyear: number,\n gdate: Date | HDate\n ): HDate | undefined {\n return birthdayOrAnniversary(hyear, gdate);\n }\n\n /**\n * Calculates yahrzeit.\n * `hyear` must be after original `gdate` of death.\n * Returns `undefined` when requested year preceeds or is same as original year.\n *\n * Hebcal uses the algorithm defined in \"Calendrical Calculations\"\n * by Edward M. Reingold and Nachum Dershowitz.\n *\n * The customary anniversary date of a death is more complicated and depends\n * also on the character of the year in which the first anniversary occurs.\n * There are several cases:\n *\n * * If the date of death is Marcheshvan 30, the anniversary in general depends\n * on the first anniversary; if that first anniversary was not Marcheshvan 30,\n * use the day before Kislev 1.\n * * If the date of death is Kislev 30, the anniversary in general again depends\n * on the first anniversary — if that was not Kislev 30, use the day before\n * Tevet 1.\n * * If the date of death is Adar II, the anniversary is the same day in the\n * last month of the Hebrew year (Adar or Adar II).\n * * If the date of death is Adar I 30, the anniversary in a Hebrew year that\n * is not a leap year (in which Adar only has 29 days) is the last day in\n * Shevat.\n * * In all other cases, use the normal (that is, same month number) anniversary\n * of the date of death. [Calendrical Calculations p. 113]\n * @example\n * import {HebrewCalendar} from '@hebcal/core';\n * const dt = new Date(2014, 2, 2); // '2014-03-02' == '30 Adar I 5774'\n * const hd = HebrewCalendar.getYahrzeit(5780, dt); // '30 Sh\\'vat 5780'\n * console.log(hd.greg().toLocaleDateString('en-US')); // '2/25/2020'\n * @param hyear Hebrew year\n * @param gdate Gregorian or Hebrew date of death\n * @returns anniversary occurring in hyear\n */\n static getYahrzeit(hyear: number, gdate: Date | HDate): HDate | undefined {\n return yahrzeit(hyear, gdate);\n }\n\n /**\n * Lower-level holidays interface, which returns a `Map` of `Event`s indexed by\n * `HDate.toString()`. These events are not filtered by Israel vs. Diaspora\n * holiday scheme; use {@link Event.observedIn} to do that.\n *\n * Includes Rosh Chodesh, fasts, Yom Kippur Katan, Special Shabbatot, etc.,\n * but does not generate candle-lighting times, Torah readings, or Omer days.\n * The result is cached in an internal LRU.\n * @example\n * import {HebrewCalendar} from '@hebcal/core';\n * const map = HebrewCalendar.getHolidaysForYear(5784);\n * for (const [hdStr, events] of map.entries()) {\n * for (const ev of events) {\n * console.log(hdStr, ev.getDesc());\n * }\n * }\n * @param year Hebrew year\n */\n static getHolidaysForYear(year: number): HolidayYearMap {\n return getHolidaysForYear_(year);\n }\n\n /**\n * Returns a sorted array of holidays observed during the given Hebrew year.\n *\n * Events are pre-filtered by Israel vs. Diaspora schedule, so callers do not\n * need to inspect `flags.IL_ONLY` / `flags.CHUL_ONLY` themselves.\n * Includes Rosh Chodesh, fasts, modern holidays, special Shabbatot, etc.,\n * but does not generate candle-lighting times, Torah readings, or Omer days.\n * @example\n * import {HebrewCalendar} from '@hebcal/core';\n * const events = HebrewCalendar.getHolidaysForYearArray(5784, false);\n * console.log(events[0].getDesc()); // 'Rosh Hashana 5784'\n * @param year Hebrew year\n * @param il use the Israeli schedule for holidays\n */\n static getHolidaysForYearArray(year: number, il: boolean): HolidayEvent[] {\n return getHolidaysForYearArray(year, il);\n }\n\n /**\n * Returns an array of holiday Events that occur on the given date,\n * or `undefined` if no holidays occur that day.\n *\n * When `il` is omitted, both Diaspora-only and Israel-only events are\n * returned; pass `true` or `false` to filter to a single schedule.\n * @example\n * import {HebrewCalendar, HDate, months} from '@hebcal/core';\n * const hd = new HDate(15, months.NISAN, 5784);\n * const events = HebrewCalendar.getHolidaysOnDate(hd, false);\n * console.log(events?.map(ev => ev.getDesc())); // ['Pesach I']\n * @param date Hebrew Date, Gregorian date, or absolute R.D. day number\n * @param [il] use the Israeli schedule for holidays\n */\n static getHolidaysOnDate(\n date: HDate | Date | number,\n il?: boolean\n ): HolidayEvent[] | undefined {\n return getHolidaysOnDate(date, il);\n }\n\n /**\n * Returns `true` if Eruv Tavshilin should be prepared on the given date.\n *\n * Eruv Tavshilin is prepared when a Yom Tov falls on Friday (so cooking\n * for Shabbat that begins Friday night may continue from Yom Tov into\n * Shabbat). This requires the day before to be a weekday (Wednesday or\n * Thursday), the following Friday to be Yom Tov, and the day after Friday\n * (Shabbat) to also be a sacred day.\n * @example\n * import {HebrewCalendar} from '@hebcal/core';\n * // Wednesday October 16, 2024 is Erev Sukkot 5785. In the Diaspora,\n * // Sukkot I falls on Thursday and Sukkot II on Friday, so Eruv\n * // Tavshilin is prepared on Wednesday:\n * HebrewCalendar.eruvTavshilin(new Date(2024, 9, 16), false); // true\n * // In Israel there is only one day of Yom Tov, so Friday is a weekday:\n * HebrewCalendar.eruvTavshilin(new Date(2024, 9, 16), true); // false\n * @param date Gregorian or Hebrew date to test\n * @param il use the Israeli holiday schedule\n */\n static eruvTavshilin(date: Date | HDate, il: boolean): boolean {\n const dow = date.getDay();\n if (dow < 3 || dow > 4) {\n return false;\n }\n const today = new HDate(date);\n const friday = today.after(5);\n const tomorrow = today.next();\n return isYomTov(friday, il) && !isYomTov(today, il) && isYomTov(tomorrow, il);\n }\n\n /**\n * Helper function to format a 24-hour (00:00-23:59) time string in either\n * 12-hour US format (e.g. `\"8:13pm\"`) or keep it in 24-hour format (e.g.\n * `\"20:13\"`) for any other locale or country.\n *\n * The locale (and therefore default behavior) is derived from\n * `options.location` / `options.locale`. The `options.hour12` override\n * takes precedence: if `false`, locale is ignored and the result is always\n * 24-hour; if `true`, locale is ignored and the result is always 12-hour.\n * @example\n * import {HebrewCalendar, Location} from '@hebcal/core';\n * const opts = {location: Location.lookup('Chicago')};\n * HebrewCalendar.reformatTimeStr('20:30', 'pm', opts); // '8:30pm'\n * HebrewCalendar.reformatTimeStr('20:30', 'pm', {hour12: false}); // '20:30'\n * @param timeStr - original time like \"20:30\"\n * @param suffix - \"p\" or \"pm\" or \" P.M.\". Add leading space if you want it\n * @param options optional; `location`, `locale` and `hour12` are consulted\n */\n static reformatTimeStr(\n timeStr: string,\n suffix: string,\n options?: CalOptions\n ): string {\n return reformatTimeStr(timeStr, suffix, options);\n }\n\n /**\n * Returns the semantic version string of the `@hebcal/core` package\n * (e.g. `\"6.8.2\"`). Useful for logging or feature detection.\n */\n static version(): string {\n return pkgVersion;\n }\n\n /**\n * Convenience function to create an instance of {@link Sedra} or reuse a\n * previously created and cached instance for the same year + schedule.\n *\n * Use this in preference to `new Sedra(...)` when calling repeatedly,\n * since an internal LRU cache (~120 entries) avoids recomputing the\n * keviyah-specific reading pattern.\n * @example\n * import {HebrewCalendar, HDate} from '@hebcal/core';\n * const sedra = HebrewCalendar.getSedra(5784, false);\n * const result = sedra.lookup(new HDate(15, 'Cheshvan', 5784));\n * console.log(result.parsha); // ['Vayera']\n * @param hyear Hebrew year\n * @param il Use Israel sedra schedule (`false` for Diaspora)\n */\n static getSedra(hyear: number, il: boolean): Sedra {\n return getSedra(hyear, il);\n }\n\n /**\n * Determines which form of Hallel (if any) is recited on a given Hebrew date:\n * 0 (none), 1 (half Hallel), or 2 (whole Hallel).\n * See {@link hallel} for details.\n * @example\n * import {HebrewCalendar, HDate, months} from '@hebcal/core';\n * HebrewCalendar.hallel(new HDate(25, months.KISLEV, 5784), false); // 2 (Chanukah)\n * HebrewCalendar.hallel(new HDate(1, months.SHVAT, 5784), false); // 1 (Rosh Chodesh)\n * HebrewCalendar.hallel(new HDate(2, months.SHVAT, 5784), false); // 0\n * @param hdate Hebrew date to test\n * @param il use the Israeli holiday schedule\n * @returns 0 for no Hallel, 1 for half Hallel, 2 for whole Hallel\n */\n static hallel(hdate: HDate, il: boolean): number {\n return hallel(hdate, il);\n }\n\n /**\n * Return details on what Tachanun (or Tzidchatcha on Shabbat) is said on `hdate`.\n *\n * Tachanun is not said on Rosh Chodesh, the month of Nisan, Lag Baomer,\n * Rosh Chodesh Sivan until Isru Chag, Tisha B'av, 15 Av, Erev Rosh Hashanah,\n * Rosh Hashanah, Erev Yom Kippur until after Simchat Torah, Chanukah,\n * Tu B'shvat, Purim and Shushan Purim, and Purim and Shushan Purim Katan.\n *\n * In some congregations Tachanun is not said until from Rosh Chodesh Sivan\n * until 14th Sivan, Sukkot until after Rosh Chodesh Cheshvan, Pesach Sheini,\n * Yom Ha'atzmaut, and Yom Yerushalayim.\n *\n * Tachanun is not said at Mincha on days before it is not said at Shacharit.\n *\n * Tachanun is not said at Shacharit on Shabbat, but is at Mincha, usually.\n * @example\n * import {HebrewCalendar, HDate, months} from '@hebcal/core';\n * // Regular weekday — Tachanun is said at both services\n * HebrewCalendar.tachanun(new HDate(4, months.SHVAT, 5784), false);\n * // => { shacharit: true, mincha: true, allCongs: true }\n *\n * // Friday 2 Sh'vat — said at Shacharit, but not at Mincha (erev Shabbat)\n * HebrewCalendar.tachanun(new HDate(2, months.SHVAT, 5784), false);\n * // => { shacharit: true, mincha: false, allCongs: true }\n *\n * // Rosh Chodesh — no Tachanun\n * HebrewCalendar.tachanun(new HDate(1, months.SHVAT, 5784), false);\n * // => { shacharit: false, mincha: false, allCongs: false }\n * @param hdate Hebrew date to test\n * @param il use the Israeli holiday schedule\n */\n static tachanun(hdate: HDate, il: boolean): TachanunResult {\n return tachanun(hdate, il);\n }\n}\n"],"names":["pkgVersion"],"mappings":";;;;;;;;;;;;AAAA;;;;;;;;;;;;;;;;;;;AAmBG;AAqBH;;;;;AAKG;MACU,cAAc,CAAA;AACzB,IAAA,WAAA,GAAA,EAAuB;AACvB;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2BG;AACH,IAAA,OAAO,QAAQ,CAAC,O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;QAC7B,OAAO,QAAQ,CAAC,MAAM,EAAE,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,KAAK,EAAE,EAAE,CAAC,IAAI,QAAQ,CAAC,QAAQ,EAAE,EAAE,CAAC;IAC/E;AAEA;;;;;;;;;;;;;;;;;AAiBG;AACH,IAAA,OAAO,eAAe,CACpB,OAAe,EACf,MAAc,EACd,OAAoB,EAAA;QAEpB,OAAO,eAAe,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC;IAClD;AAEA;;;AAGG;AACH,IAAA,OAAO,OAAO,GAAA;AACZ,QAAA,OAAOA,OAAU;IACnB;AAEA;;;;;;;;;;;;;;AAcG;AACH,IAAA,OAAO,QAAQ,CAAC,KAAa,EAAE,EAAW,EAAA;AACxC,QAAA,OAAO,QAAQ,CAAC,KAAK,EAAE,EAAE,CAAC;IAC5B;AAEA;;;;;;;;;;;;AAYG;AACH,IAAA,OAAO,MAAM,CAAC,KAAY,EAAE,EAAW,EAAA;AACrC,QAAA,OAAO,MAAM,CAAC,KAAK,EAAE,EAAE,CAAC;IAC1B;AAEA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8BG;AACH,IAAA,OAAO,QAAQ,CAAC,KAAY,EAAE,EAAW,EAAA;AACvC,QAAA,OAAO,QAAQ,CAAC,KAAK,EAAE,EAAE,CAAC;IAC5B;AACD;;"}
@@ -25,6 +25,13 @@ export declare function getHolidaysOnDate(date: HDate | Date | number, il?: bool
25
25
  * by Israel vs. Diaspora — inspect `flags.IL_ONLY` / `flags.CHUL_ONLY`.
26
26
  */
27
27
  export type HolidayYearMap = Map<string, HolidayEvent[]>;
28
+ /**
29
+ * Holidays for an entire Hebrew year, indexed by R.D. (Rata Die) day number,
30
+ * i.e. `HDate.abs()`. Like {@link HolidayYearMap}, entries are not filtered by
31
+ * Israel vs. Diaspora. Cached and shared, so must not be modified.
32
+ * @internal
33
+ */
34
+ export type HolidayYearRdMap = ReadonlyMap<number, readonly HolidayEvent[]>;
28
35
  /** @internal */
29
36
  export declare const TIME_OF_DAY_DAWN = 0;
30
37
  /** @internal */
@@ -61,10 +68,20 @@ export declare const TIME_OF_DAY_NIGHT = 7;
61
68
  * @internal
62
69
  */
63
70
  export declare function timeOfDay(ev: Event): number;
71
+ /**
72
+ * Holidays for an entire Hebrew year, indexed by R.D. day number
73
+ * (`HDate.abs()`), so that per-day lookups don't have to build a date string.
74
+ * The result is cached in an internal LRU and shared between callers.
75
+ * @internal
76
+ */
77
+ export declare function getHolidaysForYearByRd(year: number): HolidayYearRdMap;
64
78
  /**
65
79
  * Lower-level holidays interface, which returns a `Map` of `Event`s indexed by
66
80
  * `HDate.toString()`. These events must filtered especially for `flags.IL_ONLY`
67
81
  * or `flags.CHUL_ONLY` depending on Israel vs. Diaspora holiday scheme.
82
+ *
83
+ * A string-keyed copy of {@link getHolidaysForYearByRd}, built once per
84
+ * cached year; the event arrays are shared with it.
68
85
  * @internal
69
86
  */
70
87
  export declare function getHolidaysForYear_(year: number): HolidayYearMap;