@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/README.md +250 -261
- package/dist/bundle.js +323 -255
- package/dist/bundle.min.js +2 -2
- package/dist/hdate-bundle.js +312 -244
- package/dist/hdate-bundle.min.js +2 -2
- package/dist/hdate.js +76 -61
- package/dist/hdate.mjs +76 -61
- package/dist/index.js +105 -70
- package/dist/index.mjs +87 -72
- package/hebcal.d.ts +116 -115
- package/package.json +1 -1
package/dist/hdate.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! @hebcal/core v3.33.
|
|
1
|
+
/*! @hebcal/core v3.33.5 */
|
|
2
2
|
const GERESH = '׳';
|
|
3
3
|
const GERSHAYIM = '״';
|
|
4
4
|
/**
|
|
@@ -207,53 +207,55 @@ function quotient(x, y) {
|
|
|
207
207
|
}
|
|
208
208
|
/**
|
|
209
209
|
* Gregorian date helper functions.
|
|
210
|
-
* @namespace
|
|
211
210
|
*/
|
|
212
211
|
|
|
213
212
|
|
|
214
|
-
|
|
213
|
+
class greg {
|
|
215
214
|
/**
|
|
216
215
|
* Long names of the Gregorian months (1='January', 12='December')
|
|
217
216
|
* @readonly
|
|
218
217
|
* @type {string[]}
|
|
219
218
|
*/
|
|
220
|
-
monthNames
|
|
221
|
-
|
|
219
|
+
static monthNames = ['', 'January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'];
|
|
222
220
|
/**
|
|
223
221
|
* Returns true if the Gregorian year is a leap year
|
|
224
222
|
* @param {number} year Gregorian year
|
|
225
223
|
* @return {boolean}
|
|
226
224
|
*/
|
|
227
|
-
isLeapYear: function (year) {
|
|
228
|
-
return !(year % 4) && (!!(year % 100) || !(year % 400));
|
|
229
|
-
},
|
|
230
225
|
|
|
226
|
+
static isLeapYear(year) {
|
|
227
|
+
return !(year % 4) && (!!(year % 100) || !(year % 400));
|
|
228
|
+
}
|
|
231
229
|
/**
|
|
232
230
|
* Number of days in the Gregorian month for given year
|
|
233
231
|
* @param {number} month Gregorian month (1=January, 12=December)
|
|
234
232
|
* @param {number} year Gregorian year
|
|
235
233
|
* @return {number}
|
|
236
234
|
*/
|
|
237
|
-
|
|
235
|
+
|
|
236
|
+
|
|
237
|
+
static daysInMonth(month, year) {
|
|
238
238
|
// 1 based months
|
|
239
239
|
return monthLengths[+this.isLeapYear(year)][month];
|
|
240
|
-
}
|
|
241
|
-
|
|
240
|
+
}
|
|
242
241
|
/**
|
|
243
242
|
* Returns true if the object is a Javascript Date
|
|
244
243
|
* @param {Object} obj
|
|
245
244
|
* @return {boolean}
|
|
246
245
|
*/
|
|
247
|
-
isDate: function (obj) {
|
|
248
|
-
return typeof obj === 'object' && Date.prototype === obj.__proto__;
|
|
249
|
-
},
|
|
250
246
|
|
|
247
|
+
|
|
248
|
+
static isDate(obj) {
|
|
249
|
+
return typeof obj === 'object' && Date.prototype === obj.__proto__;
|
|
250
|
+
}
|
|
251
251
|
/**
|
|
252
252
|
* Returns number of days since January 1 of that year
|
|
253
253
|
* @param {Date} date Gregorian date
|
|
254
254
|
* @return {number}
|
|
255
255
|
*/
|
|
256
|
-
|
|
256
|
+
|
|
257
|
+
|
|
258
|
+
static dayOfYear(date) {
|
|
257
259
|
if (!this.isDate(date)) {
|
|
258
260
|
throw new TypeError('Argument to greg.dayOfYear not a Date');
|
|
259
261
|
}
|
|
@@ -270,14 +272,15 @@ const greg = {
|
|
|
270
272
|
}
|
|
271
273
|
|
|
272
274
|
return doy;
|
|
273
|
-
}
|
|
274
|
-
|
|
275
|
+
}
|
|
275
276
|
/**
|
|
276
277
|
* Converts Gregorian date to absolute R.D. (Rata Die) days
|
|
277
278
|
* @param {Date} date Gregorian date
|
|
278
279
|
* @return {number}
|
|
279
280
|
*/
|
|
280
|
-
|
|
281
|
+
|
|
282
|
+
|
|
283
|
+
static greg2abs(date) {
|
|
281
284
|
if (!this.isDate(date)) {
|
|
282
285
|
throw new TypeError('Argument to greg.greg2abs not a Date');
|
|
283
286
|
}
|
|
@@ -288,14 +291,15 @@ const greg = {
|
|
|
288
291
|
Math.floor(year / 4) - // + Julian Leap years
|
|
289
292
|
Math.floor(year / 100) + // - century years
|
|
290
293
|
Math.floor(year / 400)); // + Gregorian leap years
|
|
291
|
-
}
|
|
292
|
-
|
|
294
|
+
}
|
|
293
295
|
/**
|
|
294
296
|
* @private
|
|
295
297
|
* @param {number} theDate - R.D. number of days
|
|
296
298
|
* @return {number}
|
|
297
299
|
*/
|
|
298
|
-
|
|
300
|
+
|
|
301
|
+
|
|
302
|
+
static yearFromFixed(theDate) {
|
|
299
303
|
const l0 = theDate - 1;
|
|
300
304
|
const n400 = quotient(l0, 146097);
|
|
301
305
|
const d1 = mod(l0, 146097);
|
|
@@ -306,8 +310,7 @@ const greg = {
|
|
|
306
310
|
const n1 = quotient(d3, 365);
|
|
307
311
|
const year = 400 * n400 + 100 * n100 + 4 * n4 + n1;
|
|
308
312
|
return n100 != 4 && n1 != 4 ? year + 1 : year;
|
|
309
|
-
}
|
|
310
|
-
|
|
313
|
+
}
|
|
311
314
|
/**
|
|
312
315
|
* @private
|
|
313
316
|
* @param {number} year
|
|
@@ -315,11 +318,12 @@ const greg = {
|
|
|
315
318
|
* @param {number} day
|
|
316
319
|
* @return {number}
|
|
317
320
|
*/
|
|
318
|
-
|
|
321
|
+
|
|
322
|
+
|
|
323
|
+
static toFixed(year, month, day) {
|
|
319
324
|
const py = year - 1;
|
|
320
325
|
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;
|
|
321
|
-
}
|
|
322
|
-
|
|
326
|
+
}
|
|
323
327
|
/**
|
|
324
328
|
* Converts from Rata Die (R.D. number) to Gregorian date.
|
|
325
329
|
* See the footnote on page 384 of ``Calendrical Calculations, Part II:
|
|
@@ -329,7 +333,9 @@ const greg = {
|
|
|
329
333
|
* @param {number} theDate - R.D. number of days
|
|
330
334
|
* @return {Date}
|
|
331
335
|
*/
|
|
332
|
-
|
|
336
|
+
|
|
337
|
+
|
|
338
|
+
static abs2greg(theDate) {
|
|
333
339
|
if (typeof theDate !== 'number') {
|
|
334
340
|
throw new TypeError('Argument to greg.abs2greg not a Number');
|
|
335
341
|
}
|
|
@@ -348,7 +354,8 @@ const greg = {
|
|
|
348
354
|
|
|
349
355
|
return dt;
|
|
350
356
|
}
|
|
351
|
-
|
|
357
|
+
|
|
358
|
+
}
|
|
352
359
|
|
|
353
360
|
const noopLocale = {
|
|
354
361
|
headers: {
|
|
@@ -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
|
-
|
|
383
|
+
class Locale {
|
|
378
384
|
/** @private */
|
|
379
|
-
locales
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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);
|
|
@@ -1742,7 +1757,7 @@ function getBirthdayOrAnniversary_(hyear, gdate) {
|
|
|
1742
1757
|
return new HDate(day, month, hyear);
|
|
1743
1758
|
}
|
|
1744
1759
|
|
|
1745
|
-
var version="3.33.
|
|
1760
|
+
var version="3.33.5";
|
|
1746
1761
|
|
|
1747
1762
|
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};
|
|
1748
1763
|
|