@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.
@@ -1,4 +1,4 @@
1
- /*! @hebcal/core v3.33.4 */
1
+ /*! @hebcal/core v3.33.5 */
2
2
  var hebcal = (function (exports) {
3
3
  'use strict';
4
4
 
@@ -202,6 +202,21 @@ function _createClass(Constructor, protoProps, staticProps) {
202
202
  return Constructor;
203
203
  }
204
204
 
205
+ function _defineProperty(obj, key, value) {
206
+ if (key in obj) {
207
+ Object.defineProperty(obj, key, {
208
+ value: value,
209
+ enumerable: true,
210
+ configurable: true,
211
+ writable: true
212
+ });
213
+ } else {
214
+ obj[key] = value;
215
+ }
216
+
217
+ return obj;
218
+ }
219
+
205
220
  /*
206
221
  Hebcal - A Jewish Calendar Generator
207
222
  Copyright (c) 1994-2020 Danny Sadinoff
@@ -245,148 +260,172 @@ function quotient(x, y) {
245
260
  }
246
261
  /**
247
262
  * Gregorian date helper functions.
248
- * @namespace
249
263
  */
250
264
 
251
265
 
252
- var greg = {
253
- /**
254
- * Long names of the Gregorian months (1='January', 12='December')
255
- * @readonly
256
- * @type {string[]}
257
- */
258
- monthNames: ['', 'January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'],
266
+ var greg = /*#__PURE__*/function () {
267
+ function greg() {
268
+ _classCallCheck(this, greg);
269
+ }
259
270
 
260
- /**
261
- * Returns true if the Gregorian year is a leap year
262
- * @param {number} year Gregorian year
263
- * @return {boolean}
264
- */
265
- isLeapYear: function isLeapYear(year) {
266
- return !(year % 4) && (!!(year % 100) || !(year % 400));
267
- },
271
+ _createClass(greg, null, [{
272
+ key: "isLeapYear",
273
+ value:
274
+ /**
275
+ * Long names of the Gregorian months (1='January', 12='December')
276
+ * @readonly
277
+ * @type {string[]}
278
+ */
268
279
 
269
- /**
270
- * Number of days in the Gregorian month for given year
271
- * @param {number} month Gregorian month (1=January, 12=December)
272
- * @param {number} year Gregorian year
273
- * @return {number}
274
- */
275
- daysInMonth: function daysInMonth(month, year) {
276
- // 1 based months
277
- return monthLengths[+this.isLeapYear(year)][month];
278
- },
280
+ /**
281
+ * Returns true if the Gregorian year is a leap year
282
+ * @param {number} year Gregorian year
283
+ * @return {boolean}
284
+ */
285
+ function isLeapYear(year) {
286
+ return !(year % 4) && (!!(year % 100) || !(year % 400));
287
+ }
288
+ /**
289
+ * Number of days in the Gregorian month for given year
290
+ * @param {number} month Gregorian month (1=January, 12=December)
291
+ * @param {number} year Gregorian year
292
+ * @return {number}
293
+ */
279
294
 
280
- /**
281
- * Returns true if the object is a Javascript Date
282
- * @param {Object} obj
283
- * @return {boolean}
284
- */
285
- isDate: function isDate(obj) {
286
- return _typeof(obj) === 'object' && Date.prototype === obj.__proto__;
287
- },
295
+ }, {
296
+ key: "daysInMonth",
297
+ value: function daysInMonth(month, year) {
298
+ // 1 based months
299
+ return monthLengths[+this.isLeapYear(year)][month];
300
+ }
301
+ /**
302
+ * Returns true if the object is a Javascript Date
303
+ * @param {Object} obj
304
+ * @return {boolean}
305
+ */
288
306
 
289
- /**
290
- * Returns number of days since January 1 of that year
291
- * @param {Date} date Gregorian date
292
- * @return {number}
293
- */
294
- dayOfYear: function dayOfYear(date) {
295
- if (!this.isDate(date)) {
296
- throw new TypeError('Argument to greg.dayOfYear not a Date');
307
+ }, {
308
+ key: "isDate",
309
+ value: function isDate(obj) {
310
+ return _typeof(obj) === 'object' && Date.prototype === obj.__proto__;
297
311
  }
312
+ /**
313
+ * Returns number of days since January 1 of that year
314
+ * @param {Date} date Gregorian date
315
+ * @return {number}
316
+ */
298
317
 
299
- var doy = date.getDate() + 31 * date.getMonth();
318
+ }, {
319
+ key: "dayOfYear",
320
+ value: function dayOfYear(date) {
321
+ if (!this.isDate(date)) {
322
+ throw new TypeError('Argument to greg.dayOfYear not a Date');
323
+ }
300
324
 
301
- if (date.getMonth() > 1) {
302
- // FEB
303
- doy -= Math.floor((4 * (date.getMonth() + 1) + 23) / 10);
325
+ var doy = date.getDate() + 31 * date.getMonth();
304
326
 
305
- if (this.isLeapYear(date.getFullYear())) {
306
- doy++;
327
+ if (date.getMonth() > 1) {
328
+ // FEB
329
+ doy -= Math.floor((4 * (date.getMonth() + 1) + 23) / 10);
330
+
331
+ if (this.isLeapYear(date.getFullYear())) {
332
+ doy++;
333
+ }
307
334
  }
335
+
336
+ return doy;
308
337
  }
338
+ /**
339
+ * Converts Gregorian date to absolute R.D. (Rata Die) days
340
+ * @param {Date} date Gregorian date
341
+ * @return {number}
342
+ */
309
343
 
310
- return doy;
311
- },
344
+ }, {
345
+ key: "greg2abs",
346
+ value: function greg2abs(date) {
347
+ if (!this.isDate(date)) {
348
+ throw new TypeError('Argument to greg.greg2abs not a Date');
349
+ }
312
350
 
313
- /**
314
- * Converts Gregorian date to absolute R.D. (Rata Die) days
315
- * @param {Date} date Gregorian date
316
- * @return {number}
317
- */
318
- greg2abs: function greg2abs(date) {
319
- if (!this.isDate(date)) {
320
- throw new TypeError('Argument to greg.greg2abs not a Date');
351
+ var year = date.getFullYear() - 1;
352
+ return this.dayOfYear(date) + // days this year
353
+ 365 * year + ( // + days in prior years
354
+ Math.floor(year / 4) - // + Julian Leap years
355
+ Math.floor(year / 100) + // - century years
356
+ Math.floor(year / 400)); // + Gregorian leap years
321
357
  }
358
+ /**
359
+ * @private
360
+ * @param {number} theDate - R.D. number of days
361
+ * @return {number}
362
+ */
322
363
 
323
- var year = date.getFullYear() - 1;
324
- return this.dayOfYear(date) + // days this year
325
- 365 * year + ( // + days in prior years
326
- Math.floor(year / 4) - // + Julian Leap years
327
- Math.floor(year / 100) + // - century years
328
- Math.floor(year / 400)); // + Gregorian leap years
329
- },
364
+ }, {
365
+ key: "yearFromFixed",
366
+ value: function yearFromFixed(theDate) {
367
+ var l0 = theDate - 1;
368
+ var n400 = quotient(l0, 146097);
369
+ var d1 = mod(l0, 146097);
370
+ var n100 = quotient(d1, 36524);
371
+ var d2 = mod(d1, 36524);
372
+ var n4 = quotient(d2, 1461);
373
+ var d3 = mod(d2, 1461);
374
+ var n1 = quotient(d3, 365);
375
+ var year = 400 * n400 + 100 * n100 + 4 * n4 + n1;
376
+ return n100 != 4 && n1 != 4 ? year + 1 : year;
377
+ }
378
+ /**
379
+ * @private
380
+ * @param {number} year
381
+ * @param {number} month
382
+ * @param {number} day
383
+ * @return {number}
384
+ */
330
385
 
331
- /**
332
- * @private
333
- * @param {number} theDate - R.D. number of days
334
- * @return {number}
335
- */
336
- yearFromFixed: function yearFromFixed(theDate) {
337
- var l0 = theDate - 1;
338
- var n400 = quotient(l0, 146097);
339
- var d1 = mod(l0, 146097);
340
- var n100 = quotient(d1, 36524);
341
- var d2 = mod(d1, 36524);
342
- var n4 = quotient(d2, 1461);
343
- var d3 = mod(d2, 1461);
344
- var n1 = quotient(d3, 365);
345
- var year = 400 * n400 + 100 * n100 + 4 * n4 + n1;
346
- return n100 != 4 && n1 != 4 ? year + 1 : year;
347
- },
386
+ }, {
387
+ key: "toFixed",
388
+ value: function toFixed(year, month, day) {
389
+ var py = year - 1;
390
+ 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;
391
+ }
392
+ /**
393
+ * Converts from Rata Die (R.D. number) to Gregorian date.
394
+ * See the footnote on page 384 of ``Calendrical Calculations, Part II:
395
+ * Three Historical Calendars'' by E. M. Reingold, N. Dershowitz, and S. M.
396
+ * Clamen, Software--Practice and Experience, Volume 23, Number 4
397
+ * (April, 1993), pages 383-404 for an explanation.
398
+ * @param {number} theDate - R.D. number of days
399
+ * @return {Date}
400
+ */
348
401
 
349
- /**
350
- * @private
351
- * @param {number} year
352
- * @param {number} month
353
- * @param {number} day
354
- * @return {number}
355
- */
356
- toFixed: function toFixed(year, month, day) {
357
- var py = year - 1;
358
- 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;
359
- },
402
+ }, {
403
+ key: "abs2greg",
404
+ value: function abs2greg(theDate) {
405
+ if (typeof theDate !== 'number') {
406
+ throw new TypeError('Argument to greg.abs2greg not a Number');
407
+ }
360
408
 
361
- /**
362
- * Converts from Rata Die (R.D. number) to Gregorian date.
363
- * See the footnote on page 384 of ``Calendrical Calculations, Part II:
364
- * Three Historical Calendars'' by E. M. Reingold, N. Dershowitz, and S. M.
365
- * Clamen, Software--Practice and Experience, Volume 23, Number 4
366
- * (April, 1993), pages 383-404 for an explanation.
367
- * @param {number} theDate - R.D. number of days
368
- * @return {Date}
369
- */
370
- abs2greg: function abs2greg(theDate) {
371
- if (typeof theDate !== 'number') {
372
- throw new TypeError('Argument to greg.abs2greg not a Number');
373
- }
409
+ theDate = Math.trunc(theDate);
410
+ var year = this.yearFromFixed(theDate);
411
+ var priorDays = theDate - this.toFixed(year, 1, 1);
412
+ var correction = theDate < this.toFixed(year, 3, 1) ? 0 : this.isLeapYear(year) ? 1 : 2;
413
+ var month = quotient(12 * (priorDays + correction) + 373, 367);
414
+ var day = theDate - this.toFixed(year, month, 1) + 1;
415
+ var dt = new Date(year, month - 1, day);
374
416
 
375
- theDate = Math.trunc(theDate);
376
- var year = this.yearFromFixed(theDate);
377
- var priorDays = theDate - this.toFixed(year, 1, 1);
378
- var correction = theDate < this.toFixed(year, 3, 1) ? 0 : this.isLeapYear(year) ? 1 : 2;
379
- var month = quotient(12 * (priorDays + correction) + 373, 367);
380
- var day = theDate - this.toFixed(year, month, 1) + 1;
381
- var dt = new Date(year, month - 1, day);
417
+ if (year < 100 && year >= 0) {
418
+ dt.setFullYear(year);
419
+ }
382
420
 
383
- if (year < 100 && year >= 0) {
384
- dt.setFullYear(year);
421
+ return dt;
385
422
  }
423
+ }]);
386
424
 
387
- return dt;
388
- }
389
- };
425
+ return greg;
426
+ }();
427
+
428
+ _defineProperty(greg, "monthNames", ['', 'January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December']);
390
429
 
391
430
  var noopLocale = {
392
431
  headers: {
@@ -409,159 +448,188 @@ var alias = {
409
448
  * * `ashkenazi` - Ashkenazi transliterations (e.g. "Shabbos")
410
449
  * * `he` - Hebrew (e.g. "שַׁבָּת")
411
450
  * * `he-x-NoNikud` - Hebrew without nikud (e.g. "שבת")
412
- * @namespace
413
451
  */
414
452
 
415
- var Locale = {
416
- /** @private */
417
- locales: Object.create(null),
453
+ var Locale = /*#__PURE__*/function () {
454
+ function Locale() {
455
+ _classCallCheck(this, Locale);
456
+ }
418
457
 
419
- /** @private */
420
- activeLocale: null,
458
+ _createClass(Locale, null, [{
459
+ key: "lookupTranslation",
460
+ value:
461
+ /** @private */
421
462
 
422
- /** @private */
423
- activeName: null,
463
+ /** @private */
424
464
 
425
- /**
426
- * Returns translation only if `locale` offers a non-empty translation for `id`.
427
- * Otherwise, returns `undefined`.
428
- * @param {string} id Message ID to translate
429
- * @param {string} [locale] Optional locale name (i.e: `'he'`, `'fr'`). Defaults to active locale.
430
- * @return {string}
431
- */
432
- lookupTranslation: function lookupTranslation(id, locale) {
433
- var locale0 = locale && locale.toLowerCase();
434
- var loc = typeof locale == 'string' && this.locales[locale0] || this.activeLocale;
435
- var array = loc[id];
465
+ /** @private */
466
+
467
+ /**
468
+ * Returns translation only if `locale` offers a non-empty translation for `id`.
469
+ * Otherwise, returns `undefined`.
470
+ * @param {string} id Message ID to translate
471
+ * @param {string} [locale] Optional locale name (i.e: `'he'`, `'fr'`). Defaults to active locale.
472
+ * @return {string}
473
+ */
474
+ function lookupTranslation(id, locale) {
475
+ var locale0 = locale && locale.toLowerCase();
476
+ var loc = typeof locale == 'string' && this.locales[locale0] || this.activeLocale;
477
+ var array = loc[id];
478
+
479
+ if (array && array.length && array[0].length) {
480
+ return array[0];
481
+ }
436
482
 
437
- if (array && array.length && array[0].length) {
438
- return array[0];
483
+ return undefined;
439
484
  }
485
+ /**
486
+ * By default, if no translation was found, returns `id`.
487
+ * @param {string} id Message ID to translate
488
+ * @param {string} [locale] Optional locale name (i.e: `'he'`, `'fr'`). Defaults to active locale.
489
+ * @return {string}
490
+ */
440
491
 
441
- return undefined;
442
- },
492
+ }, {
493
+ key: "gettext",
494
+ value: function gettext(id, locale) {
495
+ var text = this.lookupTranslation(id, locale);
443
496
 
444
- /**
445
- * By default, if no translation was found, returns `id`.
446
- * @param {string} id Message ID to translate
447
- * @param {string} [locale] Optional locale name (i.e: `'he'`, `'fr'`). Defaults to active locale.
448
- * @return {string}
449
- */
450
- gettext: function gettext(id, locale) {
451
- var text = this.lookupTranslation(id, locale);
497
+ if (typeof text == 'undefined') {
498
+ return id;
499
+ }
452
500
 
453
- if (typeof text == 'undefined') {
454
- return id;
501
+ return text;
455
502
  }
503
+ /**
504
+ * Register locale translations.
505
+ * @param {string} locale Locale name (i.e.: `'he'`, `'fr'`)
506
+ * @param {LocaleDate} data parsed data from a `.po` file.
507
+ */
456
508
 
457
- return text;
458
- },
509
+ }, {
510
+ key: "addLocale",
511
+ value: function addLocale(locale, data) {
512
+ if (_typeof(data.contexts) !== 'object' || _typeof(data.contexts['']) !== 'object') {
513
+ throw new TypeError("Locale '".concat(locale, "' invalid compact format"));
514
+ }
459
515
 
460
- /**
461
- * Register locale translations.
462
- * @param {string} locale Locale name (i.e.: `'he'`, `'fr'`)
463
- * @param {LocaleDate} data parsed data from a `.po` file.
464
- */
465
- addLocale: function addLocale(locale, data) {
466
- if (_typeof(data.contexts) !== 'object' || _typeof(data.contexts['']) !== 'object') {
467
- throw new TypeError("Locale '".concat(locale, "' invalid compact format"));
516
+ this.locales[locale.toLowerCase()] = data.contexts[''];
468
517
  }
518
+ /**
519
+ * Activates a locale. Throws an error if the locale has not been previously added.
520
+ * After setting the locale to be used, all strings marked for translations
521
+ * will be represented by the corresponding translation in the specified locale.
522
+ * @param {string} locale Locale name (i.e: `'he'`, `'fr'`)
523
+ * @return {LocaleData}
524
+ */
469
525
 
470
- this.locales[locale.toLowerCase()] = data.contexts[''];
471
- },
526
+ }, {
527
+ key: "useLocale",
528
+ value: function useLocale(locale) {
529
+ var locale0 = locale.toLowerCase();
530
+ var obj = this.locales[locale0];
472
531
 
473
- /**
474
- * Activates a locale. Throws an error if the locale has not been previously added.
475
- * After setting the locale to be used, all strings marked for translations
476
- * will be represented by the corresponding translation in the specified locale.
477
- * @param {string} locale Locale name (i.e: `'he'`, `'fr'`)
478
- * @return {LocaleData}
479
- */
480
- useLocale: function useLocale(locale) {
481
- var locale0 = locale.toLowerCase();
482
- var obj = this.locales[locale0];
532
+ if (!obj) {
533
+ throw new RangeError("Locale '".concat(locale, "' not found"));
534
+ }
483
535
 
484
- if (!obj) {
485
- throw new RangeError("Locale '".concat(locale, "' not found"));
536
+ this.activeName = alias[locale0] || locale0;
537
+ this.activeLocale = obj;
538
+ return this.activeLocale;
486
539
  }
540
+ /**
541
+ * Returns the name of the active locale (i.e. 'he', 'ashkenazi', 'fr')
542
+ * @return {string}
543
+ */
487
544
 
488
- this.activeName = alias[locale0] || locale0;
489
- this.activeLocale = obj;
490
- return this.activeLocale;
491
- },
545
+ }, {
546
+ key: "getLocaleName",
547
+ value: function getLocaleName() {
548
+ return this.activeName;
549
+ }
550
+ /**
551
+ * Returns the names of registered locales
552
+ * @return {string[]}
553
+ */
492
554
 
493
- /**
494
- * Returns the name of the active locale (i.e. 'he', 'ashkenazi', 'fr')
495
- * @return {string}
496
- */
497
- getLocaleName: function getLocaleName() {
498
- return this.activeName;
499
- },
555
+ }, {
556
+ key: "getLocaleNames",
557
+ value: function getLocaleNames() {
558
+ return Object.keys(this.locales).sort();
559
+ }
560
+ /**
561
+ * @param {number} n
562
+ * @param {string} [locale] Optional locale name (i.e: `'he'`, `'fr'`). Defaults to active locale.
563
+ * @return {string}
564
+ */
500
565
 
501
- /**
502
- * Returns the names of registered locales
503
- * @return {string[]}
504
- */
505
- getLocaleNames: function getLocaleNames() {
506
- return Object.keys(this.locales).sort();
507
- },
566
+ }, {
567
+ key: "ordinal",
568
+ value: function ordinal(n, locale) {
569
+ var locale1 = locale && locale.toLowerCase();
570
+ var locale0 = locale1 || this.activeName;
508
571
 
509
- /**
510
- * @param {number} n
511
- * @param {string} [locale] Optional locale name (i.e: `'he'`, `'fr'`). Defaults to active locale.
512
- * @return {string}
513
- */
514
- ordinal: function ordinal(n, locale) {
515
- var locale1 = locale && locale.toLowerCase();
516
- var locale0 = locale1 || this.activeName;
517
-
518
- if (!locale0) {
519
- return this.getEnOrdinal(n);
520
- }
521
-
522
- switch (locale0) {
523
- case 'en':
524
- case 's':
525
- case 'a':
526
- case 'ashkenazi':
527
- case 'ashkenazi_litvish':
528
- case 'ashkenazi_poylish':
529
- case 'ashkenazi_standard':
572
+ if (!locale0) {
530
573
  return this.getEnOrdinal(n);
574
+ }
575
+
576
+ switch (locale0) {
577
+ case 'en':
578
+ case 's':
579
+ case 'a':
580
+ case 'ashkenazi':
581
+ case 'ashkenazi_litvish':
582
+ case 'ashkenazi_poylish':
583
+ case 'ashkenazi_standard':
584
+ return this.getEnOrdinal(n);
531
585
 
532
- case 'es':
533
- return n + 'º';
586
+ case 'es':
587
+ return n + 'º';
534
588
 
535
- case 'h':
536
- case 'he':
537
- case 'he-x-nonikud':
538
- return String(n);
589
+ case 'h':
590
+ case 'he':
591
+ case 'he-x-nonikud':
592
+ return String(n);
539
593
 
540
- default:
541
- return n + '.';
594
+ default:
595
+ return n + '.';
596
+ }
542
597
  }
543
- },
598
+ /**
599
+ * @private
600
+ * @param {number} n
601
+ * @return {string}
602
+ */
544
603
 
545
- /**
546
- * @private
547
- * @param {number} n
548
- * @return {string}
549
- */
550
- getEnOrdinal: function getEnOrdinal(n) {
551
- var s = ['th', 'st', 'nd', 'rd'];
552
- var v = n % 100;
553
- return n + (s[(v - 20) % 10] || s[v] || s[0]);
554
- },
604
+ }, {
605
+ key: "getEnOrdinal",
606
+ value: function getEnOrdinal(n) {
607
+ var s = ['th', 'st', 'nd', 'rd'];
608
+ var v = n % 100;
609
+ return n + (s[(v - 20) % 10] || s[v] || s[0]);
610
+ }
611
+ /**
612
+ * Removes nekudot from Hebrew string
613
+ * @param {string} str
614
+ * @return {string}
615
+ */
616
+
617
+ }, {
618
+ key: "hebrewStripNikkud",
619
+ value: function hebrewStripNikkud(str) {
620
+ return str.replace(/[\u0590-\u05bd]/g, '').replace(/[\u05bf-\u05c7]/g, '');
621
+ }
622
+ }]);
623
+
624
+ return Locale;
625
+ }();
626
+
627
+ _defineProperty(Locale, "locales", Object.create(null));
628
+
629
+ _defineProperty(Locale, "activeLocale", null);
630
+
631
+ _defineProperty(Locale, "activeName", null);
555
632
 
556
- /**
557
- * Removes nekudot from Hebrew string
558
- * @param {string} str
559
- * @return {string}
560
- */
561
- hebrewStripNikkud: function hebrewStripNikkud(str) {
562
- return str.replace(/[\u0590-\u05bd]/g, '').replace(/[\u05bf-\u05c7]/g, '');
563
- }
564
- };
565
633
  Locale.addLocale('en', noopLocale);
566
634
  Locale.addLocale('s', noopLocale);
567
635
  Locale.addLocale('', noopLocale);
@@ -1815,7 +1883,7 @@ function getBirthdayOrAnniversary_(hyear, gdate) {
1815
1883
  return new HDate(day, month, hyear);
1816
1884
  }
1817
1885
 
1818
- var version="3.33.4";
1886
+ var version="3.33.5";
1819
1887
 
1820
1888
  var headers={"plural-forms":"nplurals=2; plural=(n > 1);",language:"he"};var contexts={"":{Adar:["אַדָר"],"Adar I":["אַדָר א׳"],"Adar II":["אַדָר ב׳"],Av:["אָב"],Cheshvan:["חֶשְׁוָן"],Elul:["אֱלוּל"],Iyyar:["אִיָיר"],Kislev:["כִּסְלֵו"],Nisan:["נִיסָן"],"Sh'vat":["שְׁבָט"],Sivan:["סִיוָן"],Tamuz:["תַּמּוּז"],Tevet:["טֵבֵת"],Tishrei:["תִשְׁרֵי"]}};var poHeMin = {headers:headers,contexts:contexts};
1821
1889