@hebcal/core 6.0.6 → 6.0.8

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 (142) hide show
  1. package/README.md +42 -27
  2. package/dist/bundle.js +13 -8
  3. package/dist/bundle.js.map +1 -1
  4. package/dist/bundle.min.js +3 -3
  5. package/dist/bundle.min.js.map +1 -1
  6. package/dist/esm/DailyLearning.js +1 -1
  7. package/dist/esm/HebrewDateEvent.js +1 -1
  8. package/dist/esm/HolidayEvent.js +1 -1
  9. package/dist/esm/MevarchimChodeshEvent.js +1 -1
  10. package/dist/esm/ParshaEvent.js +1 -1
  11. package/dist/esm/TimedEvent.js +1 -1
  12. package/dist/esm/YomKippurKatanEvent.js +1 -1
  13. package/dist/esm/ashkenazi.po.js +1 -1
  14. package/dist/esm/calendar.js +1 -1
  15. package/dist/esm/candles.js +1 -1
  16. package/dist/esm/event.js +1 -1
  17. package/dist/esm/getStartAndEnd.js +1 -1
  18. package/dist/esm/hallel.js +1 -1
  19. package/dist/esm/he-x-NoNikud.po.d.ts +3 -0
  20. package/dist/esm/he-x-NoNikud.po.js +2 -2
  21. package/dist/esm/he-x-NoNikud.po.js.map +1 -1
  22. package/dist/esm/he.po.d.ts +1 -0
  23. package/dist/esm/he.po.js +2 -2
  24. package/dist/esm/he.po.js.map +1 -1
  25. package/dist/esm/hebcal.js +1 -1
  26. package/dist/esm/holidays.js +1 -1
  27. package/dist/esm/index.js +1 -1
  28. package/dist/esm/isAssurBemlacha.js +1 -1
  29. package/dist/esm/locale.js +1 -1
  30. package/dist/esm/location.js +2 -2
  31. package/dist/esm/location.js.map +1 -1
  32. package/dist/esm/modern.js +1 -1
  33. package/dist/esm/molad.js +1 -1
  34. package/dist/esm/omer.js +1 -1
  35. package/dist/esm/parshaName.js +1 -1
  36. package/dist/esm/parshaYear.d.ts +2 -2
  37. package/dist/esm/parshaYear.js +1 -1
  38. package/dist/esm/parshaYear.js.map +1 -1
  39. package/dist/esm/pkgVersion.d.ts +1 -1
  40. package/dist/esm/pkgVersion.js +2 -2
  41. package/dist/esm/pkgVersion.js.map +1 -1
  42. package/dist/esm/reformatTimeStr.js +1 -1
  43. package/dist/esm/sedra.d.ts +5 -1
  44. package/dist/esm/sedra.js +9 -3
  45. package/dist/esm/sedra.js.map +1 -1
  46. package/dist/esm/staticHolidays.js +1 -2
  47. package/dist/esm/staticHolidays.js.map +1 -1
  48. package/dist/esm/tachanun.js +1 -1
  49. package/dist/esm/zmanim.js +1 -1
  50. package/dist/he-x-NoNikud.po.d.ts +3 -0
  51. package/dist/he.po.d.ts +1 -0
  52. package/dist/parshaYear.d.ts +2 -2
  53. package/dist/pkgVersion.d.ts +1 -1
  54. package/dist/po2json.d.ts +1 -0
  55. package/dist/po2json.js +41 -0
  56. package/dist/sedra.d.ts +5 -1
  57. package/dist/size-demo/dist/getHoliday.d.ts +1944 -0
  58. package/dist/size-demo/dist/getHoliday.js +3712 -0
  59. package/dist/size-demo/dist/parshiyot.js +10662 -0
  60. package/dist/size-demo/dist/sedra.d.ts +1411 -0
  61. package/dist/size-demo/dist/sedra.js +2359 -0
  62. package/dist/size-demo/dist/tachanun.d.ts +1015 -0
  63. package/dist/size-demo/dist/tachanun.js +1755 -0
  64. package/dist/size-demo/getHoliday.d.ts +1 -0
  65. package/dist/size-demo/getHoliday.js +3 -0
  66. package/dist/size-demo/parshiyot.d.ts +1 -0
  67. package/dist/size-demo/parshiyot.js +11 -0
  68. package/dist/size-demo/rollup.config.d.ts +3 -0
  69. package/dist/size-demo/rollup.config.js +47 -0
  70. package/dist/size-demo/sedra.d.ts +1 -0
  71. package/dist/size-demo/sedra.js +3 -0
  72. package/dist/size-demo/tachanun.d.ts +1 -0
  73. package/dist/size-demo/tachanun.js +3 -0
  74. package/dist/src/CalOptions.d.ts +168 -0
  75. package/dist/src/CalOptions.js +1 -0
  76. package/dist/src/DailyLearning.d.ts +32 -0
  77. package/dist/src/DailyLearning.js +55 -0
  78. package/dist/src/HebrewDateEvent.d.ts +37 -0
  79. package/dist/src/HebrewDateEvent.js +72 -0
  80. package/dist/src/HolidayEvent.d.ts +83 -0
  81. package/dist/src/HolidayEvent.js +186 -0
  82. package/dist/src/MevarchimChodeshEvent.d.ts +26 -0
  83. package/dist/src/MevarchimChodeshEvent.js +50 -0
  84. package/dist/src/ParshaEvent.d.ts +19 -0
  85. package/dist/src/ParshaEvent.js +43 -0
  86. package/dist/src/TimedEvent.d.ts +47 -0
  87. package/dist/src/TimedEvent.js +92 -0
  88. package/dist/src/YomKippurKatanEvent.d.ts +23 -0
  89. package/dist/src/YomKippurKatanEvent.js +38 -0
  90. package/dist/src/ashkenazi.po.d.ts +70 -0
  91. package/dist/src/ashkenazi.po.js +1 -0
  92. package/dist/src/calendar.d.ts +111 -0
  93. package/dist/src/calendar.js +660 -0
  94. package/dist/src/candles.d.ts +44 -0
  95. package/dist/src/candles.js +163 -0
  96. package/dist/src/event.d.ts +188 -0
  97. package/dist/src/event.js +233 -0
  98. package/dist/src/getStartAndEnd.d.ts +6 -0
  99. package/dist/src/getStartAndEnd.js +97 -0
  100. package/dist/src/hallel.d.ts +6 -0
  101. package/dist/src/hallel.js +47 -0
  102. package/dist/src/he-x-NoNikud.po.d.ts +16 -0
  103. package/dist/src/he-x-NoNikud.po.js +1 -0
  104. package/dist/src/he.po.d.ts +195 -0
  105. package/dist/src/he.po.js +1 -0
  106. package/dist/src/hebcal.d.ts +260 -0
  107. package/dist/src/hebcal.js +332 -0
  108. package/dist/src/holidays.d.ts +22 -0
  109. package/dist/src/holidays.js +288 -0
  110. package/dist/src/index.d.ts +26 -0
  111. package/dist/src/index.js +24 -0
  112. package/dist/src/isAssurBemlacha.d.ts +9 -0
  113. package/dist/src/isAssurBemlacha.js +62 -0
  114. package/dist/src/locale.d.ts +2 -0
  115. package/dist/src/locale.js +11 -0
  116. package/dist/src/location.d.ts +73 -0
  117. package/dist/src/location.js +306 -0
  118. package/dist/src/modern.d.ts +18 -0
  119. package/dist/src/modern.js +59 -0
  120. package/dist/src/molad.d.ts +62 -0
  121. package/dist/src/molad.js +169 -0
  122. package/dist/src/omer.d.ts +53 -0
  123. package/dist/src/omer.js +302 -0
  124. package/dist/src/parshaName.d.ts +2 -0
  125. package/dist/src/parshaName.js +13 -0
  126. package/dist/src/parshaYear.d.ts +9 -0
  127. package/dist/src/parshaYear.js +24 -0
  128. package/dist/src/pkgVersion.d.ts +2 -0
  129. package/dist/src/pkgVersion.js +2 -0
  130. package/dist/src/reformatTimeStr.d.ts +8 -0
  131. package/dist/src/reformatTimeStr.js +48 -0
  132. package/dist/src/sedra.d.ts +95 -0
  133. package/dist/src/sedra.js +477 -0
  134. package/dist/src/staticHolidays.d.ts +176 -0
  135. package/dist/src/staticHolidays.js +614 -0
  136. package/dist/src/tachanun.d.ts +29 -0
  137. package/dist/src/tachanun.js +120 -0
  138. package/dist/src/zmanim.d.ts +347 -0
  139. package/dist/src/zmanim.js +579 -0
  140. package/dist/version.d.ts +1 -0
  141. package/dist/version.js +9 -0
  142. package/package.json +11 -8
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,3 @@
1
+ import { HDate } from '@hebcal/hdate';
2
+ import { getHolidaysOnDate } from '../dist/esm/holidays';
3
+ console.log(getHolidaysOnDate(new HDate(1, 1, 5757)));
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,11 @@
1
+ import { calendar } from '../dist/esm/calendar';
2
+ const events = calendar({
3
+ year: new Date().getFullYear() - 1,
4
+ numYears: 2,
5
+ sedrot: true,
6
+ noHolidays: true,
7
+ });
8
+ console.log(events.map(event => ({
9
+ datetime: event.date.greg(),
10
+ label: event.render('he-x-NoNikud'),
11
+ })));
@@ -0,0 +1,3 @@
1
+ import { RollupOptions } from 'rollup';
2
+ declare const _default: RollupOptions[];
3
+ export default _default;
@@ -0,0 +1,47 @@
1
+ import prettyBytes from 'pretty-bytes';
2
+ import { defineConfig } from 'rollup';
3
+ import { nodeResolve } from '@rollup/plugin-node-resolve';
4
+ import bundleSize from 'rollup-plugin-bundle-size';
5
+ import terser from '@rollup/plugin-terser';
6
+ import typescript from '@rollup/plugin-typescript';
7
+ import { appendFileSync, readdirSync, writeFileSync } from 'fs';
8
+ import { basename } from 'path';
9
+ import { visualizer } from 'rollup-plugin-visualizer';
10
+ const sizeFile = './size-demo/sizes.md';
11
+ writeFileSync(sizeFile, '# Bundle sizes\n\n');
12
+ export default defineConfig(readdirSync('./size-demo')
13
+ .filter(f => f.endsWith('.ts'))
14
+ .filter(f => !f.endsWith('.d.ts') && !f.endsWith('.config.ts'))
15
+ .map((file) => {
16
+ const name = basename(file, '.ts');
17
+ return {
18
+ input: `size-demo/${name}.ts`,
19
+ output: [
20
+ {
21
+ file: `size-demo/dist/${name}.js`,
22
+ format: 'es',
23
+ inlineDynamicImports: true,
24
+ },
25
+ {
26
+ file: `size-demo/dist/${name}.min.js`,
27
+ format: 'es',
28
+ inlineDynamicImports: true,
29
+ plugins: [terser()],
30
+ },
31
+ ],
32
+ plugins: [
33
+ typescript({ tsconfig: './size-demo/tsconfig.json' }),
34
+ nodeResolve(),
35
+ bundleSize(),
36
+ {
37
+ name: 'record-size-to-file',
38
+ generateBundle(options, bundle) {
39
+ const asset = basename(options.file);
40
+ const result = bundle[asset];
41
+ appendFileSync(sizeFile, `- \`${asset}\`: ${prettyBytes(result.code.length)}\n`);
42
+ },
43
+ },
44
+ visualizer({ filename: `size-demo/dist/${name}.stats.html` }),
45
+ ],
46
+ };
47
+ }));
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,3 @@
1
+ import { getSedra } from '../dist/esm/sedra';
2
+ const sedra = getSedra(5757, false);
3
+ console.log(sedra.lookup(729122).parsha);
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,3 @@
1
+ import { tachanun } from '../dist/esm/tachanun';
2
+ import { HDate } from '@hebcal/hdate';
3
+ console.log(tachanun(new HDate(1, 1, 5757), true));
@@ -0,0 +1,168 @@
1
+ import { HDate } from '@hebcal/hdate';
2
+ import type { Location } from './location';
3
+ export type DailyLearningValue = boolean | number | string;
4
+ /**
5
+ * Options to configure which events are returned
6
+ */
7
+ export type CalOptions = {
8
+ /**
9
+ * latitude/longitude/tzid used for candle-lighting
10
+ */
11
+ location?: Location;
12
+ /**
13
+ * Gregorian or Hebrew year
14
+ */
15
+ year?: number;
16
+ /**
17
+ * to interpret year as Hebrew year
18
+ */
19
+ isHebrewYear?: boolean;
20
+ /**
21
+ * Gregorian or Hebrew month (to filter results to a single month)
22
+ */
23
+ month?: number | string;
24
+ /**
25
+ * generate calendar for multiple years (default 1)
26
+ */
27
+ numYears?: number;
28
+ /**
29
+ * use specific start date (requires end date)
30
+ */
31
+ start?: number | HDate | Date;
32
+ /**
33
+ * use specific end date (requires start date)
34
+ */
35
+ end?: number | HDate | Date;
36
+ /**
37
+ * calculate candle-lighting and havdalah times
38
+ */
39
+ candlelighting?: boolean;
40
+ /**
41
+ * minutes before sundown to light candles (default 18)
42
+ */
43
+ candleLightingMins?: number;
44
+ /**
45
+ * minutes after sundown for Havdalah (typical values are 42, 50, or 72).
46
+ * If `undefined` (the default), calculate Havdalah according to Tzeit Hakochavim -
47
+ * Nightfall (the point when 3 small stars are observable in the night time sky with
48
+ * the naked eye). If `0`, Havdalah times are suppressed.
49
+ */
50
+ havdalahMins?: number;
51
+ /**
52
+ * degrees for solar depression for Havdalah.
53
+ * Default is 8.5 degrees for 3 small stars. use 7.083 degrees for 3 medium-sized stars
54
+ * (observed by Dr. Baruch (Berthold) Cohn in his luach published in France in 1899).
55
+ * If `0`, Havdalah times are suppressed.
56
+ */
57
+ havdalahDeg?: number;
58
+ /**
59
+ * degrees for solar depression for end of fast days.
60
+ * Default is 7.083 degrees for 3 medium-sized stars. Other commonly-used values include
61
+ * 6.45 degrees, as calculated by Rabbi Yechiel Michel Tucazinsky.
62
+ */
63
+ fastEndDeg?: number;
64
+ /**
65
+ * use elevation for calculations (default `false`).
66
+ * If `true`, use elevation to affect the calculation of all sunrise/sunset based zmanim.
67
+ * Note: there are some zmanim such as degree-based zmanim that are driven by the amount
68
+ * of light in the sky and are not impacted by elevation.
69
+ * These zmanim intentionally do not support elevation adjustment.
70
+ */
71
+ useElevation?: boolean;
72
+ /**
73
+ * calculate parashah hashavua on Saturdays
74
+ */
75
+ sedrot?: boolean;
76
+ /**
77
+ * Israeli holiday and sedra schedule
78
+ */
79
+ il?: boolean;
80
+ /**
81
+ * suppress minor fasts
82
+ */
83
+ noMinorFast?: boolean;
84
+ /**
85
+ * suppress modern holidays
86
+ */
87
+ noModern?: boolean;
88
+ /**
89
+ * suppress Rosh Chodesh
90
+ */
91
+ noRoshChodesh?: boolean;
92
+ /**
93
+ * add Shabbat Mevarchim
94
+ */
95
+ shabbatMevarchim?: boolean;
96
+ /**
97
+ * suppress Special Shabbat
98
+ */
99
+ noSpecialShabbat?: boolean;
100
+ /**
101
+ * suppress regular holidays
102
+ */
103
+ noHolidays?: boolean;
104
+ /**
105
+ * include Days of the Omer
106
+ */
107
+ omer?: boolean;
108
+ /**
109
+ * include event announcing the molad
110
+ */
111
+ molad?: boolean;
112
+ /**
113
+ * use Ashkenazi transliterations for event titles (default Sephardi transliterations)
114
+ * @deprecated use `event.render('ashkenazi')` instead
115
+ */
116
+ ashkenazi?: boolean;
117
+ /**
118
+ * translate event titles according to a locale
119
+ * Default value is `en`, also built-in are `he` and `ashkenazi`.
120
+ * Additional locales (such as `ru` or `fr`) are provided by the
121
+ * {@link https://github.com/hebcal/hebcal-locales @hebcal/locales} package
122
+ */
123
+ locale?: string;
124
+ /**
125
+ * print the Hebrew date for the entire date range
126
+ */
127
+ addHebrewDates?: boolean;
128
+ /**
129
+ * print the Hebrew date for dates with some events
130
+ */
131
+ addHebrewDatesForEvents?: boolean;
132
+ /**
133
+ * use bitmask from `flags` to filter events
134
+ */
135
+ mask?: number;
136
+ /**
137
+ * include Yom Kippur Katan (default `false`).
138
+ * יוֹם כִּפּוּר קָטָן is a minor day of atonement occurring monthly on the day preceeding each Rosh Chodesh.
139
+ * Yom Kippur Katan is omitted in Elul (on the day before Rosh Hashanah),
140
+ * Tishrei (Yom Kippur has just passed), Kislev (due to Chanukah)
141
+ * and Nisan (fasting not permitted during Nisan).
142
+ * When Rosh Chodesh occurs on Shabbat or Sunday, Yom Kippur Katan is observed on the preceding Thursday.
143
+ * See {@link https://en.wikipedia.org/wiki/Yom_Kippur_Katan#Practices Wikipedia Yom Kippur Katan practices}
144
+ */
145
+ yomKippurKatan?: boolean;
146
+ /**
147
+ * Whether to use 12-hour time (as opposed to 24-hour time).
148
+ * Possible values are `true` and `false`; the default is locale dependent.
149
+ */
150
+ hour12?: boolean;
151
+ /**
152
+ * map of options to enable daily study calendars
153
+ * such as `dafYomi`, `mishnaYomi`, `nachYomi` with value `true`. For `yerushalmi`
154
+ * the value should be a `number` for edition (`1` for Vilna, `2` for Schottenstein).
155
+ */
156
+ dailyLearning?: Record<string, DailyLearningValue>;
157
+ /**
158
+ * Yizkor (Hebrew: יִזְכּוֹר) is an Ashkenazi Jewish memorial prayer service
159
+ * for the dead. Yizkor is recited in synagogue as part of the service
160
+ * during four holidays each year:
161
+ * 1. Yom Kippur
162
+ * 2. Shmini Atzeret
163
+ * 3. The final day of Passover (8th day Pesach in Diaspora, 7th day
164
+ * Pesach in Israel)
165
+ * 4. Shavuot (2nd day Shavuot in Diaspora)
166
+ */
167
+ yizkor?: boolean;
168
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,32 @@
1
+ import { HDate } from '@hebcal/hdate';
2
+ import { Event } from './event';
3
+ /**
4
+ * Plug-ins for daily learning calendars such as Daf Yomi, Mishna Yomi, Nach Yomi, etc.
5
+ *
6
+ * Learning schedules are provided by the `@hebcal/learning` package.
7
+ */
8
+ export declare class DailyLearning {
9
+ /**
10
+ * Register a new learning calendar.
11
+ * @param name case insensitive
12
+ * @param calendar a function that returns an `Event` or `null`
13
+ * @param startDate the first date for which this calendar is valid
14
+ */
15
+ static addCalendar(name: string, calendar: Function, startDate?: HDate): void;
16
+ /**
17
+ * Returns an event from daily calendar for a given date. Returns `null` if there
18
+ * is no learning from this calendar on this date.
19
+ * @param name case insensitive
20
+ * @param hd Hebrew Date
21
+ * @param il true for Israel, false for Diaspora
22
+ */
23
+ static lookup(name: string, hd: HDate, il: boolean): Event | null;
24
+ static getStartDate(name: string): HDate | undefined;
25
+ /**
26
+ * Tests to see if learning calendar has been registered
27
+ * @param name case insensitive
28
+ */
29
+ static has(name: string): boolean;
30
+ /** Returns the names of all calendars registered */
31
+ static getCalendars(): string[];
32
+ }
@@ -0,0 +1,55 @@
1
+ const cals = new Map();
2
+ /**
3
+ * Plug-ins for daily learning calendars such as Daf Yomi, Mishna Yomi, Nach Yomi, etc.
4
+ *
5
+ * Learning schedules are provided by the `@hebcal/learning` package.
6
+ */
7
+ export class DailyLearning {
8
+ /**
9
+ * Register a new learning calendar.
10
+ * @param name case insensitive
11
+ * @param calendar a function that returns an `Event` or `null`
12
+ * @param startDate the first date for which this calendar is valid
13
+ */
14
+ static addCalendar(name, calendar, startDate) {
15
+ if (typeof calendar !== 'function') {
16
+ throw new TypeError(`Invalid calendar function: ${calendar}`);
17
+ }
18
+ cals.set(name.toLowerCase(), {
19
+ fn: calendar,
20
+ startDate: startDate,
21
+ });
22
+ }
23
+ /**
24
+ * Returns an event from daily calendar for a given date. Returns `null` if there
25
+ * is no learning from this calendar on this date.
26
+ * @param name case insensitive
27
+ * @param hd Hebrew Date
28
+ * @param il true for Israel, false for Diaspora
29
+ */
30
+ static lookup(name, hd, il) {
31
+ const cal = cals.get(name.toLowerCase());
32
+ if (typeof cal === 'object') {
33
+ return cal.fn(hd, il);
34
+ }
35
+ return null;
36
+ }
37
+ static getStartDate(name) {
38
+ const cal = cals.get(name.toLowerCase());
39
+ if (typeof cal === 'object') {
40
+ return cal.startDate;
41
+ }
42
+ return undefined;
43
+ }
44
+ /**
45
+ * Tests to see if learning calendar has been registered
46
+ * @param name case insensitive
47
+ */
48
+ static has(name) {
49
+ return cals.has(name.toLowerCase());
50
+ }
51
+ /** Returns the names of all calendars registered */
52
+ static getCalendars() {
53
+ return Array.from(cals.keys());
54
+ }
55
+ }
@@ -0,0 +1,37 @@
1
+ import { HDate } from '@hebcal/hdate';
2
+ import { Event } from './event';
3
+ import './locale';
4
+ /** Daily Hebrew date ("11th of Sivan, 5780") */
5
+ export declare class HebrewDateEvent extends Event {
6
+ /**
7
+ * @param date
8
+ */
9
+ constructor(date: HDate);
10
+ /**
11
+ * @param [locale] Optional locale name (defaults to empty locale)
12
+ * @example
13
+ * import {HDate, HebrewDateEvent, months} from '@hebcal/core';
14
+ *
15
+ * const hd = new HDate(15, months.CHESHVAN, 5769);
16
+ * const ev = new HebrewDateEvent(hd);
17
+ * console.log(ev.render('en')); // '15th of Cheshvan, 5769'
18
+ * console.log(ev.render('he')); // 'ט״ו חֶשְׁוָן תשס״ט'
19
+ */
20
+ render(locale?: string): string;
21
+ /**
22
+ * @private
23
+ * @param locale
24
+ */
25
+ private renderBriefHebrew;
26
+ /**
27
+ * @param [locale] Optional locale name (defaults to empty locale)
28
+ * @example
29
+ * import {HDate, HebrewDateEvent, months} from '@hebcal/core';
30
+ *
31
+ * const hd = new HDate(15, months.CHESHVAN, 5769);
32
+ * const ev = new HebrewDateEvent(hd);
33
+ * console.log(ev.renderBrief()); // '15th of Cheshvan'
34
+ * console.log(ev.renderBrief('he')); // 'ט״ו חֶשְׁוָן'
35
+ */
36
+ renderBrief(locale?: string): string;
37
+ }
@@ -0,0 +1,72 @@
1
+ import { gematriya, months, Locale } from '@hebcal/hdate';
2
+ import { Event, flags } from './event';
3
+ import './locale'; // Adds Hebrew and Ashkenazic translations
4
+ /** Daily Hebrew date ("11th of Sivan, 5780") */
5
+ export class HebrewDateEvent extends Event {
6
+ /**
7
+ * @param date
8
+ */
9
+ constructor(date) {
10
+ super(date, date.toString(), flags.HEBREW_DATE);
11
+ }
12
+ /**
13
+ * @param [locale] Optional locale name (defaults to empty locale)
14
+ * @example
15
+ * import {HDate, HebrewDateEvent, months} from '@hebcal/core';
16
+ *
17
+ * const hd = new HDate(15, months.CHESHVAN, 5769);
18
+ * const ev = new HebrewDateEvent(hd);
19
+ * console.log(ev.render('en')); // '15th of Cheshvan, 5769'
20
+ * console.log(ev.render('he')); // 'ט״ו חֶשְׁוָן תשס״ט'
21
+ */
22
+ render(locale) {
23
+ const locale1 = locale === null || locale === void 0 ? void 0 : locale.toLowerCase();
24
+ const locale0 = locale1 !== null && locale1 !== void 0 ? locale1 : 'en';
25
+ const hd = this.getDate();
26
+ switch (locale0) {
27
+ case 'h':
28
+ case 'he':
29
+ return hd.renderGematriya(false);
30
+ case 'he-x-nonikud':
31
+ return hd.renderGematriya(true);
32
+ default:
33
+ return hd.render(locale0, true);
34
+ }
35
+ }
36
+ /**
37
+ * @private
38
+ * @param locale
39
+ */
40
+ renderBriefHebrew(locale) {
41
+ const hd = this.getDate();
42
+ const dd = hd.getDate();
43
+ const mm = Locale.gettext(hd.getMonthName(), locale);
44
+ return gematriya(dd) + ' ' + mm;
45
+ }
46
+ /**
47
+ * @param [locale] Optional locale name (defaults to empty locale)
48
+ * @example
49
+ * import {HDate, HebrewDateEvent, months} from '@hebcal/core';
50
+ *
51
+ * const hd = new HDate(15, months.CHESHVAN, 5769);
52
+ * const ev = new HebrewDateEvent(hd);
53
+ * console.log(ev.renderBrief()); // '15th of Cheshvan'
54
+ * console.log(ev.renderBrief('he')); // 'ט״ו חֶשְׁוָן'
55
+ */
56
+ renderBrief(locale) {
57
+ const locale1 = locale === null || locale === void 0 ? void 0 : locale.toLowerCase();
58
+ const locale0 = locale1 !== null && locale1 !== void 0 ? locale1 : 'en';
59
+ const hd = this.getDate();
60
+ if (hd.getMonth() === months.TISHREI && hd.getDate() === 1) {
61
+ return this.render(locale0);
62
+ }
63
+ switch (locale0) {
64
+ case 'h':
65
+ case 'he':
66
+ case 'he-x-nonikud':
67
+ return this.renderBriefHebrew(locale0);
68
+ default:
69
+ return hd.render(locale0, false);
70
+ }
71
+ }
72
+ }
@@ -0,0 +1,83 @@
1
+ import { HDate } from '@hebcal/hdate';
2
+ import { Event } from './event';
3
+ import './locale';
4
+ /** Represents a built-in holiday like Pesach, Purim or Tu BiShvat */
5
+ export declare class HolidayEvent extends Event {
6
+ /** During Sukkot or Pesach */
7
+ cholHaMoedDay?: number;
8
+ /**
9
+ * `true` if the fast day was postponed a day to avoid Shabbat.
10
+ * - Tish'a B'Av postponed from the 9th to the 10th
11
+ * - Tzom Tammuz postponed from the 17th to the 18th
12
+ */
13
+ observed?: boolean;
14
+ basename(): string;
15
+ url(): string | undefined;
16
+ urlDateSuffix(): string;
17
+ getEmoji(): string;
18
+ getCategories(): string[];
19
+ /**
20
+ * Returns (translated) description of this event
21
+ * @param [locale] Optional locale name (defaults to empty locale)
22
+ */
23
+ render(locale?: string): string;
24
+ /**
25
+ * Returns a brief (translated) description of this event.
26
+ * For most events, this is the same as render(). For some events, it procudes
27
+ * a shorter text (e.g. without a time or added description).
28
+ * @param [locale] Optional locale name (defaults to empty locale)
29
+ */
30
+ renderBrief(locale?: string): string;
31
+ }
32
+ /**
33
+ * Because Asara B'Tevet often occurs twice in the same Gregorian year,
34
+ * we subclass HolidayEvent to generate the correct URL.
35
+ */
36
+ export declare class AsaraBTevetEvent extends HolidayEvent {
37
+ urlDateSuffix(): string;
38
+ }
39
+ /**
40
+ * Because Chanukah sometimes starts in December and ends in January,
41
+ * we subclass HolidayEvent to generate the correct URL.
42
+ */
43
+ export declare class ChanukahEvent extends HolidayEvent {
44
+ readonly chanukahDay?: number;
45
+ /**
46
+ * @param chanukahDay should be undefined for 1st night of Chanukah
47
+ */
48
+ constructor(date: HDate, desc: string, mask: number, chanukahDay?: number);
49
+ urlDateSuffix(): string;
50
+ }
51
+ /** Represents Rosh Hashana, the Jewish New Year */
52
+ export declare class RoshHashanaEvent extends HolidayEvent {
53
+ private readonly hyear;
54
+ /**
55
+ * @private
56
+ * @param date Hebrew date event occurs
57
+ * @param hyear Hebrew year
58
+ * @param mask optional holiday flags
59
+ */
60
+ constructor(date: HDate, hyear: number, mask: number);
61
+ /**
62
+ * Returns (translated) description of this event
63
+ * @param [locale] Optional locale name (defaults to empty locale)
64
+ */
65
+ render(locale?: string): string;
66
+ getEmoji(): string;
67
+ }
68
+ /** Represents Rosh Chodesh, the beginning of a new month */
69
+ export declare class RoshChodeshEvent extends HolidayEvent {
70
+ /**
71
+ * Constructs Rosh Chodesh event
72
+ * @param date Hebrew date event occurs
73
+ * @param monthName Hebrew month name (not translated)
74
+ */
75
+ constructor(date: HDate, monthName: string);
76
+ /**
77
+ * Returns (translated) description of this event
78
+ * @param [locale] Optional locale name (defaults to empty locale)
79
+ */
80
+ render(locale?: string): string;
81
+ basename(): string;
82
+ getEmoji(): string;
83
+ }