@hebcal/core 5.8.8 → 5.8.10

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 (47) hide show
  1. package/dist/DailyLearning.d.ts +2 -0
  2. package/dist/HolidayEvent.d.ts +8 -1
  3. package/dist/bundle.js +66 -49
  4. package/dist/bundle.js.map +1 -1
  5. package/dist/bundle.min.js +21 -21
  6. package/dist/bundle.min.js.map +1 -1
  7. package/dist/esm/DailyLearning.d.ts +2 -0
  8. package/dist/esm/DailyLearning.js +5 -1
  9. package/dist/esm/DailyLearning.js.map +1 -1
  10. package/dist/esm/HebrewDateEvent.js +1 -1
  11. package/dist/esm/HolidayEvent.d.ts +8 -1
  12. package/dist/esm/HolidayEvent.js +17 -3
  13. package/dist/esm/HolidayEvent.js.map +1 -1
  14. package/dist/esm/MevarchimChodeshEvent.js +1 -1
  15. package/dist/esm/ParshaEvent.js +1 -1
  16. package/dist/esm/TimedEvent.js +1 -1
  17. package/dist/esm/YomKippurKatanEvent.js +1 -1
  18. package/dist/esm/ashkenazi.po.js +1 -1
  19. package/dist/esm/calendar.js +1 -1
  20. package/dist/esm/candles.js +1 -1
  21. package/dist/esm/event.js +1 -1
  22. package/dist/esm/getStartAndEnd.js +1 -1
  23. package/dist/esm/hallel.js +1 -1
  24. package/dist/esm/he.po.js +1 -1
  25. package/dist/esm/hebcal.js +1 -1
  26. package/dist/esm/holidays.js +4 -4
  27. package/dist/esm/holidays.js.map +1 -1
  28. package/dist/esm/index.js +1 -1
  29. package/dist/esm/locale.js +1 -1
  30. package/dist/esm/location.js +1 -1
  31. package/dist/esm/modern.js +1 -1
  32. package/dist/esm/molad.js +1 -1
  33. package/dist/esm/omer.js +1 -1
  34. package/dist/esm/parshaName.js +1 -1
  35. package/dist/esm/parshaYear.js +1 -1
  36. package/dist/esm/pkgVersion.d.ts +1 -1
  37. package/dist/esm/pkgVersion.js +2 -2
  38. package/dist/esm/pkgVersion.js.map +1 -1
  39. package/dist/esm/reformatTimeStr.js +1 -1
  40. package/dist/esm/sedra.js +1 -1
  41. package/dist/esm/staticHolidays.js +1 -1
  42. package/dist/esm/tachanun.js +1 -1
  43. package/dist/esm/zmanim.js +1 -1
  44. package/dist/index.cjs +23 -5
  45. package/dist/index.cjs.map +1 -1
  46. package/dist/pkgVersion.d.ts +1 -1
  47. package/package.json +4 -5
@@ -18,4 +18,6 @@ export declare class DailyLearning {
18
18
  * @param il
19
19
  */
20
20
  static lookup(name: string, hd: HDate, il: boolean): Event | null;
21
+ /** Returns the names of all calendars registered */
22
+ static getCalendars(): string[];
21
23
  }
@@ -37,11 +37,18 @@ export declare class HolidayEvent extends Event {
37
37
  }
38
38
  /**
39
39
  * Because Asara B'Tevet often occurs twice in the same Gregorian year,
40
- * we subclass HolidayEvent to override the `url()` method.
40
+ * we subclass HolidayEvent to generate the correct URL.
41
41
  */
42
42
  export declare class AsaraBTevetEvent extends HolidayEvent {
43
43
  urlDateSuffix(): string;
44
44
  }
45
+ /**
46
+ * Because Chanukah sometimes starts in December and ends in January,
47
+ * we subclass HolidayEvent to generate the correct URL.
48
+ */
49
+ export declare class ChanukahEvent extends HolidayEvent {
50
+ urlDateSuffix(): string;
51
+ }
45
52
  /** Represents Rosh Hashana, the Jewish New Year */
46
53
  export declare class RoshHashanaEvent extends HolidayEvent {
47
54
  private readonly hyear;
package/dist/bundle.js CHANGED
@@ -1,11 +1,11 @@
1
- /*! @hebcal/core v5.8.8 */
1
+ /*! @hebcal/core v5.8.10, distributed under GPLv2 https://www.gnu.org/licenses/gpl-2.0.txt */
2
2
  var hebcal = (function (exports) {
3
3
  'use strict';
4
4
 
5
5
  /** DO NOT EDIT THIS AUTO-GENERATED FILE! */
6
- const version = '5.8.8';
6
+ const version = '5.8.10';
7
7
 
8
- /*! @hebcal/hdate v0.13.2 */
8
+ /*! @hebcal/hdate v0.13.5, distributed under GPLv2 https://www.gnu.org/licenses/gpl-2.0.txt */
9
9
  /* eslint-disable @typescript-eslint/no-namespace, no-inner-declarations */
10
10
  /** @private */
11
11
  const lengths = [0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
@@ -86,7 +86,7 @@ function toFixed(year, month, day) {
86
86
  */
87
87
  function greg2abs(date) {
88
88
  if (!isDate(date)) {
89
- throw new TypeError(`Argument not a Date: ${date}`);
89
+ throw new TypeError(`not a Date: ${date}`);
90
90
  }
91
91
  const abs = toFixed(date.getFullYear(), date.getMonth() + 1, date.getDate());
92
92
  /*
@@ -117,7 +117,7 @@ function greg2abs(date) {
117
117
  */
118
118
  function abs2greg(abs) {
119
119
  if (typeof abs !== 'number') {
120
- throw new TypeError(`Argument not a Number: ${abs}`);
120
+ throw new TypeError(`not a Number: ${abs}`);
121
121
  }
122
122
  abs = Math.trunc(abs);
123
123
  /*
@@ -137,7 +137,7 @@ function abs2greg(abs) {
137
137
  return dt;
138
138
  }
139
139
 
140
- /*! @hebcal/hdate v0.13.2 */
140
+ /*! @hebcal/hdate v0.13.5, distributed under GPLv2 https://www.gnu.org/licenses/gpl-2.0.txt */
141
141
 
142
142
  /* eslint-disable @typescript-eslint/no-explicit-any, @typescript-eslint/no-namespace */
143
143
  /**
@@ -151,7 +151,7 @@ exports.greg.greg2abs = greg2abs;
151
151
  exports.greg.isDate = isDate;
152
152
  exports.greg.isLeapYear = isGregLeapYear;
153
153
 
154
- /*! @hebcal/hdate v0.13.2 */
154
+ /*! @hebcal/hdate v0.13.5, distributed under GPLv2 https://www.gnu.org/licenses/gpl-2.0.txt */
155
155
  /*
156
156
  * More minimal HDate
157
157
  */
@@ -201,13 +201,14 @@ const months = {
201
201
  /** Adar Sheini (only on leap years) / אדר ב׳ */
202
202
  ADAR_II: ADAR_II$2
203
203
  };
204
- const monthNames0 = ['', 'Nisan', 'Iyyar', 'Sivan', 'Tamuz', 'Av', 'Elul', 'Tishrei', 'Cheshvan', 'Kislev', 'Tevet', "Sh'vat"];
205
- /**
204
+ const NISAN_STR = 'Nisan';
205
+ const monthNames0 = ['', NISAN_STR, 'Iyyar', 'Sivan', 'Tamuz', 'Av', 'Elul', 'Tishrei', 'Cheshvan', 'Kislev', 'Tevet', "Sh'vat"];
206
+ /*
206
207
  * Transliterations of Hebrew month names.
207
208
  * Regular years are index 0 and leap years are index 1.
208
209
  * @private
209
210
  */
210
- const monthNames = [[...monthNames0, 'Adar', 'Nisan'], [...monthNames0, 'Adar I', 'Adar II', 'Nisan']];
211
+ const monthNames = [[...monthNames0, 'Adar', NISAN_STR], [...monthNames0, 'Adar I', 'Adar II', NISAN_STR]];
211
212
  const edCache = new Map();
212
213
  const EPOCH = -1373428;
213
214
  // Avg year length in the cycle (19 solar years with 235 lunar months)
@@ -217,7 +218,7 @@ const AVG_HEBYEAR_DAYS = 365.24682220597794;
217
218
  */
218
219
  function assertNumber(n, name) {
219
220
  if (typeof n !== 'number' || isNaN(n)) {
220
- throw new TypeError(`invalid parameter '${name}' not a number: ${n}`);
221
+ throw new TypeError(`param '${name}' not a number: ${n}`);
221
222
  }
222
223
  }
223
224
  /**
@@ -329,7 +330,7 @@ function getMonthName(month, year) {
329
330
  assertNumber(month, 'month');
330
331
  assertNumber(year, 'year');
331
332
  if (month < 1 || month > 14) {
332
- throw new TypeError(`bad month argument ${month}`);
333
+ throw new TypeError(`bad monthNum: ${month}`);
333
334
  }
334
335
  return monthNames[+isLeapYear(year)][month];
335
336
  }
@@ -404,7 +405,7 @@ function shortKislev(year) {
404
405
  function monthFromName(monthName) {
405
406
  if (typeof monthName === 'number') {
406
407
  if (isNaN(monthName) || monthName < 1 || monthName > 14) {
407
- throw new RangeError(`Invalid month name: ${monthName}`);
408
+ throw new RangeError(`bad monthName: ${monthName}`);
408
409
  }
409
410
  return monthName;
410
411
  }
@@ -512,10 +513,10 @@ function monthFromName(monthName) {
512
513
  }
513
514
  break;
514
515
  }
515
- throw new RangeError(`Unable to parse month name: ${monthName}`);
516
+ throw new RangeError(`bad monthName: ${monthName}`);
516
517
  }
517
518
 
518
- /*! @hebcal/hdate v0.13.2 */
519
+ /*! @hebcal/hdate v0.13.5, distributed under GPLv2 https://www.gnu.org/licenses/gpl-2.0.txt */
519
520
  const NISAN$3 = months.NISAN;
520
521
  const CHESHVAN = months.CHESHVAN;
521
522
  const KISLEV$1 = months.KISLEV;
@@ -610,10 +611,10 @@ function getBirthdayHD(hyear, date) {
610
611
  };
611
612
  }
612
613
 
613
- /*! @hebcal/hdate v0.13.2 */
614
+ /*! @hebcal/hdate v0.13.5, distributed under GPLv2 https://www.gnu.org/licenses/gpl-2.0.txt */
614
615
  const GERESH = '׳';
615
616
  const GERSHAYIM = '״';
616
- const alefbet = {
617
+ const heb2num = {
617
618
  א: 1,
618
619
  ב: 2,
619
620
  ג: 3,
@@ -637,11 +638,9 @@ const alefbet = {
637
638
  ש: 300,
638
639
  ת: 400
639
640
  };
640
- const heb2num = new Map();
641
- const num2heb = new Map();
642
- for (const [key, val] of Object.entries(alefbet)) {
643
- heb2num.set(key, val);
644
- num2heb.set(val, key);
641
+ const num2heb = {};
642
+ for (const [key, val] of Object.entries(heb2num)) {
643
+ num2heb[val] = key;
645
644
  }
646
645
  function num2digits(num) {
647
646
  const digits = [];
@@ -676,29 +675,28 @@ function num2digits(num) {
676
675
  * gematriya(1123) // 'א׳קכ״ג'
677
676
  */
678
677
  function gematriya(num) {
679
- const num0 = num;
680
- const num1 = parseInt(num0, 10);
678
+ const num1 = parseInt(num, 10);
681
679
  if (!num1 || num1 < 0) {
682
- throw new TypeError(`invalid gematriya number: ${num}`);
680
+ throw new TypeError(`invalid number: ${num}`);
683
681
  }
684
682
  let str = '';
685
683
  const thousands = Math.floor(num1 / 1000);
686
684
  if (thousands > 0 && thousands !== 5) {
687
685
  const tdigits = num2digits(thousands);
688
686
  for (const tdig of tdigits) {
689
- str += num2heb.get(tdig);
687
+ str += num2heb[tdig];
690
688
  }
691
689
  str += GERESH;
692
690
  }
693
691
  const digits = num2digits(num1 % 1000);
694
692
  if (digits.length === 1) {
695
- return str + num2heb.get(digits[0]) + GERESH;
693
+ return str + num2heb[digits[0]] + GERESH;
696
694
  }
697
695
  for (let i = 0; i < digits.length; i++) {
698
696
  if (i + 1 === digits.length) {
699
697
  str += GERSHAYIM;
700
698
  }
701
- str += num2heb.get(digits[i]);
699
+ str += num2heb[digits[i]];
702
700
  }
703
701
  return str;
704
702
  }
@@ -718,7 +716,7 @@ function gematriyaStrToNum(str) {
718
716
  str = str.substring(gereshIdx);
719
717
  }
720
718
  for (const ch of str) {
721
- const n = heb2num.get(ch);
719
+ const n = heb2num[ch];
722
720
  if (typeof n === 'number') {
723
721
  num += n;
724
722
  }
@@ -726,7 +724,7 @@ function gematriyaStrToNum(str) {
726
724
  return num;
727
725
  }
728
726
 
729
- /*! @hebcal/hdate v0.13.2 */
727
+ /*! @hebcal/hdate v0.13.5, distributed under GPLv2 https://www.gnu.org/licenses/gpl-2.0.txt */
730
728
  const sefirot = {
731
729
  en: {
732
730
  infix: 'within ',
@@ -901,7 +899,7 @@ function omerEmoji(omerDay) {
901
899
  return String.fromCodePoint(codePoint);
902
900
  }
903
901
 
904
- /*! @hebcal/hdate v0.13.2 */
902
+ /*! @hebcal/hdate v0.13.5, distributed under GPLv2 https://www.gnu.org/licenses/gpl-2.0.txt */
905
903
 
906
904
  /**
907
905
  * Calculates the molad for a Hebrew month
@@ -933,7 +931,7 @@ function molad(year, month) {
933
931
  };
934
932
  }
935
933
 
936
- /*! @hebcal/hdate v0.13.2 */
934
+ /*! @hebcal/hdate v0.13.5, distributed under GPLv2 https://www.gnu.org/licenses/gpl-2.0.txt */
937
935
  /**
938
936
  * Formats a number with leading zeros so the resulting string is 4 digits long.
939
937
  * Similar to `string.padStart(4, '0')` but will also format
@@ -963,7 +961,7 @@ function pad2(num) {
963
961
  return String(num);
964
962
  }
965
963
 
966
- /*! @hebcal/hdate v0.13.2 */
964
+ /*! @hebcal/hdate v0.13.5, distributed under GPLv2 https://www.gnu.org/licenses/gpl-2.0.txt */
967
965
  const _formatters = new Map();
968
966
  /**
969
967
  * @private
@@ -1019,10 +1017,11 @@ function isoDateString(dt) {
1019
1017
  return pad4(dt.getFullYear()) + '-' + pad2(dt.getMonth() + 1) + '-' + pad2(dt.getDate());
1020
1018
  }
1021
1019
 
1022
- /*! @hebcal/hdate v0.13.2 */
1020
+ /*! @hebcal/hdate v0.13.5, distributed under GPLv2 https://www.gnu.org/licenses/gpl-2.0.txt */
1023
1021
  var poAshkenazi$1 = {
1024
1022
  "headers": {
1025
- "plural-forms": "nplurals=2; plural=(n > 1);"
1023
+ "plural-forms": "nplurals=2; plural=(n > 1);",
1024
+ "language": "en_CA@ashkenazi"
1026
1025
  },
1027
1026
  "contexts": {
1028
1027
  "": {
@@ -1031,10 +1030,11 @@ var poAshkenazi$1 = {
1031
1030
  }
1032
1031
  };
1033
1032
 
1034
- /*! @hebcal/hdate v0.13.2 */
1033
+ /*! @hebcal/hdate v0.13.5, distributed under GPLv2 https://www.gnu.org/licenses/gpl-2.0.txt */
1035
1034
  var poHe$1 = {
1036
1035
  "headers": {
1037
- "plural-forms": "nplurals=2; plural=(n > 1);"
1036
+ "plural-forms": "nplurals=2; plural=(n > 1);",
1037
+ "language": "he"
1038
1038
  },
1039
1039
  "contexts": {
1040
1040
  "": {
@@ -1056,7 +1056,7 @@ var poHe$1 = {
1056
1056
  }
1057
1057
  };
1058
1058
 
1059
- /*! @hebcal/hdate v0.13.2 */
1059
+ /*! @hebcal/hdate v0.13.5, distributed under GPLv2 https://www.gnu.org/licenses/gpl-2.0.txt */
1060
1060
  const noopLocale = {
1061
1061
  headers: {
1062
1062
  'plural-forms': 'nplurals=2; plural=(n!=1);'
@@ -1267,7 +1267,7 @@ const poHeNoNikud$1 = {
1267
1267
  };
1268
1268
  Locale.addLocale('he-x-NoNikud', poHeNoNikud$1);
1269
1269
 
1270
- /*! @hebcal/hdate v0.13.2 */
1270
+ /*! @hebcal/hdate v0.13.5, distributed under GPLv2 https://www.gnu.org/licenses/gpl-2.0.txt */
1271
1271
 
1272
1272
  /*
1273
1273
  Hebcal - A Jewish Calendar Generator
@@ -1292,7 +1292,6 @@ Locale.addLocale('he-x-NoNikud', poHeNoNikud$1);
1292
1292
  function mod(x, y) {
1293
1293
  return x - y * Math.floor(x / y);
1294
1294
  }
1295
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
1296
1295
  function isSimpleHebrewDate(obj) {
1297
1296
  return obj.yy !== undefined;
1298
1297
  }
@@ -1358,13 +1357,13 @@ class HDate {
1358
1357
  this.dd = this.mm = 1;
1359
1358
  const yy = typeof year === 'string' ? parseInt(year, 10) : year;
1360
1359
  if (isNaN(yy)) {
1361
- throw new TypeError(`HDate called with bad year argument: ${year}`);
1360
+ throw new TypeError(`HDate called with bad year: ${year}`);
1362
1361
  }
1363
1362
  this.yy = yy;
1364
1363
  setMonth(this, month); // will throw if we can't parse
1365
1364
  const dd = typeof day === 'string' ? parseInt(day, 10) : day;
1366
1365
  if (isNaN(dd)) {
1367
- throw new TypeError(`HDate called with bad day argument: ${day}`);
1366
+ throw new TypeError(`HDate called with bad day: ${day}`);
1368
1367
  }
1369
1368
  setDate(this, dd);
1370
1369
  } else {
@@ -1375,7 +1374,7 @@ class HDate {
1375
1374
  // 1 argument
1376
1375
  const abs0 = typeof day === 'number' && !isNaN(day) ? day : isDate(day) ? greg2abs(day) : isSimpleHebrewDate(day) ? day : null;
1377
1376
  if (abs0 === null) {
1378
- throw new TypeError(`HDate called with bad argument: ${day}`);
1377
+ throw new TypeError(`HDate called with bad arg: ${day}`);
1379
1378
  }
1380
1379
  const isNumber = typeof abs0 === 'number';
1381
1380
  const d = isNumber ? abs2hebrew(abs0) : abs0;
@@ -1797,7 +1796,7 @@ class HDate {
1797
1796
  static monthNum(month) {
1798
1797
  if (typeof month === 'number') {
1799
1798
  if (isNaN(month) || month > 14) {
1800
- throw new RangeError(`Invalid month number: ${month}`);
1799
+ throw new RangeError(`bad monthNum: ${month}`);
1801
1800
  }
1802
1801
  return month;
1803
1802
  }
@@ -1846,7 +1845,7 @@ class HDate {
1846
1845
  static monthFromName(monthName) {
1847
1846
  if (typeof monthName === 'number') {
1848
1847
  if (isNaN(monthName) || monthName < 1 || monthName > 14) {
1849
- throw new RangeError(`Invalid month name: ${monthName}`);
1848
+ throw new RangeError(`bad monthName: ${monthName}`);
1850
1849
  }
1851
1850
  return monthName;
1852
1851
  }
@@ -1890,7 +1889,7 @@ class HDate {
1890
1889
  const parts = str.split(' ').filter(x => x.length !== 0);
1891
1890
  const numParts = parts.length;
1892
1891
  if (numParts !== 3 && numParts !== 4) {
1893
- throw new RangeError(`Unable to parse gematriya string: "${str}"`);
1892
+ throw new RangeError(`cannot parse gematriya str: "${str}"`);
1894
1893
  }
1895
1894
  const day = gematriyaStrToNum(parts[0]);
1896
1895
  const monthStr = numParts === 3 ? parts[1] : parts[1] + ' ' + parts[2];
@@ -11237,7 +11236,7 @@ class HolidayEvent extends Event {
11237
11236
  }
11238
11237
  /**
11239
11238
  * Because Asara B'Tevet often occurs twice in the same Gregorian year,
11240
- * we subclass HolidayEvent to override the `url()` method.
11239
+ * we subclass HolidayEvent to generate the correct URL.
11241
11240
  */
11242
11241
  class AsaraBTevetEvent extends HolidayEvent {
11243
11242
  urlDateSuffix() {
@@ -11245,6 +11244,20 @@ class AsaraBTevetEvent extends HolidayEvent {
11245
11244
  return isoDate.replace(/-/g, '');
11246
11245
  }
11247
11246
  }
11247
+ /**
11248
+ * Because Chanukah sometimes starts in December and ends in January,
11249
+ * we subclass HolidayEvent to generate the correct URL.
11250
+ */
11251
+ class ChanukahEvent extends HolidayEvent {
11252
+ urlDateSuffix() {
11253
+ const dt = this.getDate().greg();
11254
+ let year = dt.getFullYear();
11255
+ if (dt.getMonth() === 0) {
11256
+ year--;
11257
+ }
11258
+ return String(year);
11259
+ }
11260
+ }
11248
11261
  /** Represents Rosh Hashana, the Jewish New Year */
11249
11262
  class RoshHashanaEvent extends HolidayEvent {
11250
11263
  /**
@@ -12723,12 +12736,12 @@ function getHolidaysForYear_(year) {
12723
12736
  // HDate() corrects the month automatically
12724
12737
  for (let candles = 2; candles <= 8; candles++) {
12725
12738
  const hd = new HDate(23 + candles, KISLEV, year);
12726
- add(new HolidayEvent(hd, `Chanukah: ${candles} Candles`, MINOR_HOLIDAY$1 | CHANUKAH_CANDLES$1, {
12739
+ add(new ChanukahEvent(hd, `Chanukah: ${candles} Candles`, MINOR_HOLIDAY$1 | CHANUKAH_CANDLES$1, {
12727
12740
  chanukahDay: candles - 1,
12728
12741
  emoji: chanukahEmoji + KEYCAP_DIGITS[candles],
12729
12742
  }));
12730
12743
  }
12731
- add(new HolidayEvent(new HDate(32, KISLEV, year), holidayDesc.CHANUKAH_8TH_DAY, MINOR_HOLIDAY$1, { chanukahDay: 8, emoji: chanukahEmoji }));
12744
+ add(new ChanukahEvent(new HDate(32, KISLEV, year), holidayDesc.CHANUKAH_8TH_DAY, MINOR_HOLIDAY$1, { chanukahDay: 8, emoji: chanukahEmoji }));
12732
12745
  add(new AsaraBTevetEvent(new HDate(10, TEVET, year), holidayDesc.ASARA_BTEVET, MINOR_FAST$1));
12733
12746
  const pesachAbs = pesach.abs();
12734
12747
  add(new HolidayEvent(new HDate(HDate.dayOnOrBefore(SAT$1, pesachAbs - 43)), holidayDesc.SHABBAT_SHEKALIM, SPECIAL_SHABBAT$1), new HolidayEvent(new HDate(HDate.dayOnOrBefore(SAT$1, pesachAbs - 30)), holidayDesc.SHABBAT_ZACHOR, SPECIAL_SHABBAT$1), new HolidayEvent(new HDate(pesachAbs - (pesach.getDay() === TUE ? 33 : 31)), holidayDesc.TAANIT_ESTHER, MINOR_FAST$1));
@@ -12961,6 +12974,10 @@ class DailyLearning {
12961
12974
  }
12962
12975
  return null;
12963
12976
  }
12977
+ /** Returns the names of all calendars registered */
12978
+ static getCalendars() {
12979
+ return Array.from(cals.keys());
12980
+ }
12964
12981
  }
12965
12982
 
12966
12983
  const NONE$1 = 0;