@hebcal/core 3.33.4 → 3.33.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- /*! @hebcal/core v3.33.4 */
1
+ /*! @hebcal/core v3.33.5 */
2
2
  /*
3
3
  Hebcal - A Jewish Calendar Generator
4
4
  Copyright (c) 1994-2020 Danny Sadinoff
@@ -42,53 +42,55 @@ function quotient(x, y) {
42
42
  }
43
43
  /**
44
44
  * Gregorian date helper functions.
45
- * @namespace
46
45
  */
47
46
 
48
47
 
49
- const greg = {
48
+ class greg {
50
49
  /**
51
50
  * Long names of the Gregorian months (1='January', 12='December')
52
51
  * @readonly
53
52
  * @type {string[]}
54
53
  */
55
- monthNames: ['', 'January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'],
56
-
54
+ static monthNames = ['', 'January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'];
57
55
  /**
58
56
  * Returns true if the Gregorian year is a leap year
59
57
  * @param {number} year Gregorian year
60
58
  * @return {boolean}
61
59
  */
62
- isLeapYear: function (year) {
63
- return !(year % 4) && (!!(year % 100) || !(year % 400));
64
- },
65
60
 
61
+ static isLeapYear(year) {
62
+ return !(year % 4) && (!!(year % 100) || !(year % 400));
63
+ }
66
64
  /**
67
65
  * Number of days in the Gregorian month for given year
68
66
  * @param {number} month Gregorian month (1=January, 12=December)
69
67
  * @param {number} year Gregorian year
70
68
  * @return {number}
71
69
  */
72
- daysInMonth: function (month, year) {
70
+
71
+
72
+ static daysInMonth(month, year) {
73
73
  // 1 based months
74
74
  return monthLengths[+this.isLeapYear(year)][month];
75
- },
76
-
75
+ }
77
76
  /**
78
77
  * Returns true if the object is a Javascript Date
79
78
  * @param {Object} obj
80
79
  * @return {boolean}
81
80
  */
82
- isDate: function (obj) {
83
- return typeof obj === 'object' && Date.prototype === obj.__proto__;
84
- },
85
81
 
82
+
83
+ static isDate(obj) {
84
+ return typeof obj === 'object' && Date.prototype === obj.__proto__;
85
+ }
86
86
  /**
87
87
  * Returns number of days since January 1 of that year
88
88
  * @param {Date} date Gregorian date
89
89
  * @return {number}
90
90
  */
91
- dayOfYear: function (date) {
91
+
92
+
93
+ static dayOfYear(date) {
92
94
  if (!this.isDate(date)) {
93
95
  throw new TypeError('Argument to greg.dayOfYear not a Date');
94
96
  }
@@ -105,14 +107,15 @@ const greg = {
105
107
  }
106
108
 
107
109
  return doy;
108
- },
109
-
110
+ }
110
111
  /**
111
112
  * Converts Gregorian date to absolute R.D. (Rata Die) days
112
113
  * @param {Date} date Gregorian date
113
114
  * @return {number}
114
115
  */
115
- greg2abs: function (date) {
116
+
117
+
118
+ static greg2abs(date) {
116
119
  if (!this.isDate(date)) {
117
120
  throw new TypeError('Argument to greg.greg2abs not a Date');
118
121
  }
@@ -123,14 +126,15 @@ const greg = {
123
126
  Math.floor(year / 4) - // + Julian Leap years
124
127
  Math.floor(year / 100) + // - century years
125
128
  Math.floor(year / 400)); // + Gregorian leap years
126
- },
127
-
129
+ }
128
130
  /**
129
131
  * @private
130
132
  * @param {number} theDate - R.D. number of days
131
133
  * @return {number}
132
134
  */
133
- yearFromFixed: function (theDate) {
135
+
136
+
137
+ static yearFromFixed(theDate) {
134
138
  const l0 = theDate - 1;
135
139
  const n400 = quotient(l0, 146097);
136
140
  const d1 = mod(l0, 146097);
@@ -141,8 +145,7 @@ const greg = {
141
145
  const n1 = quotient(d3, 365);
142
146
  const year = 400 * n400 + 100 * n100 + 4 * n4 + n1;
143
147
  return n100 != 4 && n1 != 4 ? year + 1 : year;
144
- },
145
-
148
+ }
146
149
  /**
147
150
  * @private
148
151
  * @param {number} year
@@ -150,11 +153,12 @@ const greg = {
150
153
  * @param {number} day
151
154
  * @return {number}
152
155
  */
153
- toFixed: function (year, month, day) {
156
+
157
+
158
+ static toFixed(year, month, day) {
154
159
  const py = year - 1;
155
160
  return 0 + 365 * py + quotient(py, 4) - quotient(py, 100) + quotient(py, 400) + quotient(367 * month - 362, 12) + Math.floor(month <= 2 ? 0 : this.isLeapYear(year) ? -1 : -2) + day;
156
- },
157
-
161
+ }
158
162
  /**
159
163
  * Converts from Rata Die (R.D. number) to Gregorian date.
160
164
  * See the footnote on page 384 of ``Calendrical Calculations, Part II:
@@ -164,7 +168,9 @@ const greg = {
164
168
  * @param {number} theDate - R.D. number of days
165
169
  * @return {Date}
166
170
  */
167
- abs2greg: function (theDate) {
171
+
172
+
173
+ static abs2greg(theDate) {
168
174
  if (typeof theDate !== 'number') {
169
175
  throw new TypeError('Argument to greg.abs2greg not a Number');
170
176
  }
@@ -183,7 +189,8 @@ const greg = {
183
189
 
184
190
  return dt;
185
191
  }
186
- };
192
+
193
+ }
187
194
 
188
195
  const GERESH = '׳';
189
196
  const GERSHAYIM = '״';
@@ -371,19 +378,17 @@ const alias = {
371
378
  * * `ashkenazi` - Ashkenazi transliterations (e.g. "Shabbos")
372
379
  * * `he` - Hebrew (e.g. "שַׁבָּת")
373
380
  * * `he-x-NoNikud` - Hebrew without nikud (e.g. "שבת")
374
- * @namespace
375
381
  */
376
382
 
377
- const Locale = {
383
+ class Locale {
378
384
  /** @private */
379
- locales: Object.create(null),
380
-
385
+ static locales = Object.create(null);
381
386
  /** @private */
382
- activeLocale: null,
383
387
 
388
+ static activeLocale = null;
384
389
  /** @private */
385
- activeName: null,
386
390
 
391
+ static activeName = null;
387
392
  /**
388
393
  * Returns translation only if `locale` offers a non-empty translation for `id`.
389
394
  * Otherwise, returns `undefined`.
@@ -391,7 +396,8 @@ const Locale = {
391
396
  * @param {string} [locale] Optional locale name (i.e: `'he'`, `'fr'`). Defaults to active locale.
392
397
  * @return {string}
393
398
  */
394
- lookupTranslation: function lookupTranslation(id, locale) {
399
+
400
+ static lookupTranslation(id, locale) {
395
401
  const locale0 = locale && locale.toLowerCase();
396
402
  const loc = typeof locale == 'string' && this.locales[locale0] || this.activeLocale;
397
403
  const array = loc[id];
@@ -401,15 +407,16 @@ const Locale = {
401
407
  }
402
408
 
403
409
  return undefined;
404
- },
405
-
410
+ }
406
411
  /**
407
412
  * By default, if no translation was found, returns `id`.
408
413
  * @param {string} id Message ID to translate
409
414
  * @param {string} [locale] Optional locale name (i.e: `'he'`, `'fr'`). Defaults to active locale.
410
415
  * @return {string}
411
416
  */
412
- gettext: function gettext(id, locale) {
417
+
418
+
419
+ static gettext(id, locale) {
413
420
  const text = this.lookupTranslation(id, locale);
414
421
 
415
422
  if (typeof text == 'undefined') {
@@ -417,21 +424,21 @@ const Locale = {
417
424
  }
418
425
 
419
426
  return text;
420
- },
421
-
427
+ }
422
428
  /**
423
429
  * Register locale translations.
424
430
  * @param {string} locale Locale name (i.e.: `'he'`, `'fr'`)
425
431
  * @param {LocaleDate} data parsed data from a `.po` file.
426
432
  */
427
- addLocale: function addLocale(locale, data) {
433
+
434
+
435
+ static addLocale(locale, data) {
428
436
  if (typeof data.contexts !== 'object' || typeof data.contexts[''] !== 'object') {
429
437
  throw new TypeError(`Locale '${locale}' invalid compact format`);
430
438
  }
431
439
 
432
440
  this.locales[locale.toLowerCase()] = data.contexts[''];
433
- },
434
-
441
+ }
435
442
  /**
436
443
  * Activates a locale. Throws an error if the locale has not been previously added.
437
444
  * After setting the locale to be used, all strings marked for translations
@@ -439,7 +446,9 @@ const Locale = {
439
446
  * @param {string} locale Locale name (i.e: `'he'`, `'fr'`)
440
447
  * @return {LocaleData}
441
448
  */
442
- useLocale: function useLocale(locale) {
449
+
450
+
451
+ static useLocale(locale) {
443
452
  const locale0 = locale.toLowerCase();
444
453
  const obj = this.locales[locale0];
445
454
 
@@ -450,30 +459,33 @@ const Locale = {
450
459
  this.activeName = alias[locale0] || locale0;
451
460
  this.activeLocale = obj;
452
461
  return this.activeLocale;
453
- },
454
-
462
+ }
455
463
  /**
456
464
  * Returns the name of the active locale (i.e. 'he', 'ashkenazi', 'fr')
457
465
  * @return {string}
458
466
  */
459
- getLocaleName: function getLocaleName() {
460
- return this.activeName;
461
- },
462
467
 
468
+
469
+ static getLocaleName() {
470
+ return this.activeName;
471
+ }
463
472
  /**
464
473
  * Returns the names of registered locales
465
474
  * @return {string[]}
466
475
  */
467
- getLocaleNames: function getLocaleNames() {
468
- return Object.keys(this.locales).sort();
469
- },
470
476
 
477
+
478
+ static getLocaleNames() {
479
+ return Object.keys(this.locales).sort();
480
+ }
471
481
  /**
472
482
  * @param {number} n
473
483
  * @param {string} [locale] Optional locale name (i.e: `'he'`, `'fr'`). Defaults to active locale.
474
484
  * @return {string}
475
485
  */
476
- ordinal: function ordinal(n, locale) {
486
+
487
+
488
+ static ordinal(n, locale) {
477
489
  const locale1 = locale && locale.toLowerCase();
478
490
  const locale0 = locale1 || this.activeName;
479
491
 
@@ -502,28 +514,31 @@ const Locale = {
502
514
  default:
503
515
  return n + '.';
504
516
  }
505
- },
506
-
517
+ }
507
518
  /**
508
519
  * @private
509
520
  * @param {number} n
510
521
  * @return {string}
511
522
  */
512
- getEnOrdinal: function getEnOrdinal(n) {
523
+
524
+
525
+ static getEnOrdinal(n) {
513
526
  const s = ['th', 'st', 'nd', 'rd'];
514
527
  const v = n % 100;
515
528
  return n + (s[(v - 20) % 10] || s[v] || s[0]);
516
- },
517
-
529
+ }
518
530
  /**
519
531
  * Removes nekudot from Hebrew string
520
532
  * @param {string} str
521
533
  * @return {string}
522
534
  */
523
- hebrewStripNikkud: function hebrewStripNikkud(str) {
535
+
536
+
537
+ static hebrewStripNikkud(str) {
524
538
  return str.replace(/[\u0590-\u05bd]/g, '').replace(/[\u05bf-\u05c7]/g, '');
525
539
  }
526
- };
540
+
541
+ }
527
542
  Locale.addLocale('en', noopLocale);
528
543
  Locale.addLocale('s', noopLocale);
529
544
  Locale.addLocale('', noopLocale);
@@ -3052,7 +3067,7 @@ const TZEIT_3MEDIUM_STARS = 7.083;
3052
3067
  * @param {HDate} hd
3053
3068
  * @param {number} dow
3054
3069
  * @param {Location} location
3055
- * @param {HebrewCalendar.Options} options
3070
+ * @param {CalOptions} options
3056
3071
  * @return {Event}
3057
3072
  */
3058
3073
 
@@ -4998,7 +5013,7 @@ function getBirthdayOrAnniversary_(hyear, gdate) {
4998
5013
  return new HDate(day, month, hyear);
4999
5014
  }
5000
5015
 
5001
- var version="3.33.4";
5016
+ var version="3.33.5";
5002
5017
 
5003
5018
  var headers$1={"plural-forms":"nplurals=2; plural=(n > 1);",language:"en_CA@ashkenazi"};var contexts$1={"":{Berachot:["Berachos"],Shabbat:["Shabbos"],Taanit:["Taanis"],Yevamot:["Yevamos"],Ketubot:["Kesubos"],"Baba Batra":["Baba Basra"],Makkot:["Makkos"],Shevuot:["Shevuos"],Horayot:["Horayos"],Menachot:["Menachos"],Bechorot:["Bechoros"],Keritot:["Kerisos"],Midot:["Midos"],"Achrei Mot":["Achrei Mos"],Bechukotai:["Bechukosai"],"Beha'alotcha":["Beha'aloscha"],Bereshit:["Bereshis"],Chukat:["Chukas"],"Erev Shavuot":["Erev Shavuos"],"Erev Sukkot":["Erev Sukkos"],"Ki Tavo":["Ki Savo"],"Ki Teitzei":["Ki Seitzei"],"Ki Tisa":["Ki Sisa"],Matot:["Matos"],"Purim Katan":["Purim Koton"],Tazria:["Sazria"],"Shabbat Chazon":["Shabbos Chazon"],"Shabbat HaChodesh":["Shabbos HaChodesh"],"Shabbat HaGadol":["Shabbos HaGadol"],"Shabbat Nachamu":["Shabbos Nachamu"],"Shabbat Parah":["Shabbos Parah"],"Shabbat Shekalim":["Shabbos Shekalim"],"Shabbat Shuva":["Shabbos Shuvah"],"Shabbat Zachor":["Shabbos Zachor"],Shavuot:["Shavuos"],"Shavuot I":["Shavuos I"],"Shavuot II":["Shavuos II"],Shemot:["Shemos"],"Shmini Atzeret":["Shmini Atzeres"],"Simchat Torah":["Simchas Torah"],Sukkot:["Sukkos"],"Sukkot I":["Sukkos I"],"Sukkot II":["Sukkos II"],"Sukkot II (CH''M)":["Sukkos II (CH''M)"],"Sukkot III (CH''M)":["Sukkos III (CH''M)"],"Sukkot IV (CH''M)":["Sukkos IV (CH''M)"],"Sukkot V (CH''M)":["Sukkos V (CH''M)"],"Sukkot VI (CH''M)":["Sukkos VI (CH''M)"],"Sukkot VII (Hoshana Raba)":["Sukkos VII (Hoshana Raba)"],"Ta'anit Bechorot":["Ta'anis Bechoros"],"Ta'anit Esther":["Ta'anis Esther"],Toldot:["Toldos"],Vaetchanan:["Vaeschanan"],Yitro:["Yisro"],"Vezot Haberakhah":["Vezos Haberakhah"],Parashat:["Parshas"],"Leil Selichot":["Leil Selichos"],"Shabbat Mevarchim Chodesh":["Shabbos Mevorchim Chodesh"],"Shabbat Shirah":["Shabbos Shirah"],Tevet:["Teves"],"Asara B'Tevet":["Asara B'Teves"],Berakhot:["Berakhos"],Sheviit:["Sheviis"],Terumot:["Terumos"],Maasrot:["Maasros"],Eduyot:["Eduyos"],Avot:["Avos"],Bekhorot:["Bekhoros"],Middot:["Middos"],Oholot:["Oholos"],Tahorot:["Tahoros"],Mikvaot:["Mikvaos"]}};var poAshkenazi = {headers:headers$1,contexts:contexts$1};
5004
5019
 
@@ -5108,7 +5123,7 @@ const RECOGNIZED_OPTIONS = {
5108
5123
  };
5109
5124
  /**
5110
5125
  * @private
5111
- * @param {HebrewCalendar.Options} options
5126
+ * @param {CalOptions} options
5112
5127
  */
5113
5128
 
5114
5129
  function warnUnrecognizedOptions(options) {
@@ -5135,7 +5150,7 @@ function shallowCopy(target, source) {
5135
5150
  /**
5136
5151
  * Modifies options in-place
5137
5152
  * @private
5138
- * @param {HebrewCalendar.Options} options
5153
+ * @param {CalOptions} options
5139
5154
  */
5140
5155
 
5141
5156
 
@@ -5170,7 +5185,7 @@ function checkCandleOptions(options) {
5170
5185
  }
5171
5186
  /**
5172
5187
  * Options to configure which events are returned
5173
- * @typedef {Object} HebrewCalendar.Options
5188
+ * @typedef {Object} CalOptions
5174
5189
  * @property {Location} location - latitude/longitude/tzid used for candle-lighting
5175
5190
  * @property {number} year - Gregorian or Hebrew year
5176
5191
  * @property {boolean} isHebrewYear - to interpret year as Hebrew year
@@ -5226,7 +5241,7 @@ function getAbs(d) {
5226
5241
  /**
5227
5242
  * Parse options object to determine start & end days
5228
5243
  * @private
5229
- * @param {HebrewCalendar.Options} options
5244
+ * @param {CalOptions} options
5230
5245
  * @return {number[]}
5231
5246
  */
5232
5247
 
@@ -5303,7 +5318,7 @@ function getStartAndEnd(options) {
5303
5318
  /**
5304
5319
  * Mask to filter Holiday array
5305
5320
  * @private
5306
- * @param {HebrewCalendar.Options} options
5321
+ * @param {CalOptions} options
5307
5322
  * @return {number}
5308
5323
  */
5309
5324
 
@@ -5427,7 +5442,7 @@ function observedInDiaspora(ev) {
5427
5442
 
5428
5443
  class HebrewCalendar {
5429
5444
  /**
5430
- * Calculates holidays and other Hebrew calendar events based on {@link HebrewCalendar.Options}.
5445
+ * Calculates holidays and other Hebrew calendar events based on {@link CalOptions}.
5431
5446
  *
5432
5447
  * Each holiday is represented by an {@link Event} object which includes a date,
5433
5448
  * a description, flags and optional attributes.
@@ -5523,7 +5538,7 @@ class HebrewCalendar {
5523
5538
  * const date = hd.greg();
5524
5539
  * console.log(date.toLocaleDateString(), ev.render(), hd.toString());
5525
5540
  * }
5526
- * @param {HebrewCalendar.Options} [options={}]
5541
+ * @param {CalOptions} [options={}]
5527
5542
  * @return {Event[]}
5528
5543
  */
5529
5544
  static calendar(options = {}) {
@@ -5788,11 +5803,11 @@ class HebrewCalendar {
5788
5803
  }
5789
5804
  /**
5790
5805
  * Helper function to format a 23-hour (00:00-23:59) time in US format ("8:13pm") or
5791
- * keep as "20:13" for any other locale/country. Uses `HebrewCalendar.Options` to determine
5806
+ * keep as "20:13" for any other locale/country. Uses `CalOptions` to determine
5792
5807
  * locale.
5793
5808
  * @param {string} timeStr - original time like "20:30"
5794
5809
  * @param {string} suffix - "p" or "pm" or " P.M.". Add leading space if you want it
5795
- * @param {HebrewCalendar.Options} options
5810
+ * @param {CalOptions} options
5796
5811
  * @return {string}
5797
5812
  */
5798
5813
 
@@ -5843,7 +5858,7 @@ class HebrewCalendar {
5843
5858
  * @private
5844
5859
  * @param {Event[]} events
5845
5860
  * @param {Event} ev
5846
- * @param {HebrewCalendar.Options} options
5861
+ * @param {CalOptions} options
5847
5862
  * @param {Event} candlesEv
5848
5863
  * @param {number} dow
5849
5864
  * @return {Event}