@hebcal/core 3.37.0 → 3.38.0
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/bundle.js +1242 -1014
- package/dist/bundle.min.js +2 -2
- package/dist/hdate-bundle.js +451 -305
- package/dist/hdate-bundle.min.js +2 -2
- package/dist/hdate.js +474 -302
- package/dist/hdate.mjs +474 -302
- package/dist/hdate0-bundle.js +472 -0
- package/dist/hdate0-bundle.min.js +2 -0
- package/dist/index.js +458 -307
- package/dist/index.mjs +478 -307
- package/package.json +1 -1
package/dist/hdate.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! @hebcal/core v3.
|
|
1
|
+
/*! @hebcal/core v3.38.0 */
|
|
2
2
|
'use strict';
|
|
3
3
|
|
|
4
4
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
@@ -168,27 +168,12 @@ function gematriya(number) {
|
|
|
168
168
|
return str;
|
|
169
169
|
}
|
|
170
170
|
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
Copyright (c) 1994-2020 Danny Sadinoff
|
|
174
|
-
Portions copyright Eyal Schachter and Michael J. Radwin
|
|
175
|
-
|
|
176
|
-
https://github.com/hebcal/hebcal-es6
|
|
177
|
-
|
|
178
|
-
This program is free software; you can redistribute it and/or
|
|
179
|
-
modify it under the terms of the GNU General Public License
|
|
180
|
-
as published by the Free Software Foundation; either version 2
|
|
181
|
-
of the License, or (at your option) any later version.
|
|
182
|
-
|
|
183
|
-
This program is distributed in the hope that it will be useful,
|
|
184
|
-
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
185
|
-
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
186
|
-
GNU General Public License for more details.
|
|
187
|
-
|
|
188
|
-
You should have received a copy of the GNU General Public License
|
|
189
|
-
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
171
|
+
/**
|
|
172
|
+
* More minimal greg routines
|
|
190
173
|
*/
|
|
191
|
-
const
|
|
174
|
+
const lengths = [0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
|
|
175
|
+
const monthLengths = [lengths, lengths.slice()];
|
|
176
|
+
monthLengths[1][2] = 29;
|
|
192
177
|
/**
|
|
193
178
|
* @private
|
|
194
179
|
* @param {number} x
|
|
@@ -210,10 +195,169 @@ function quotient(x, y) {
|
|
|
210
195
|
return Math.floor(x / y);
|
|
211
196
|
}
|
|
212
197
|
/**
|
|
213
|
-
* Gregorian
|
|
198
|
+
* Returns true if the Gregorian year is a leap year
|
|
199
|
+
* @private
|
|
200
|
+
* @param {number} year Gregorian year
|
|
201
|
+
* @return {boolean}
|
|
214
202
|
*/
|
|
215
203
|
|
|
216
204
|
|
|
205
|
+
function isLeapYear$1(year) {
|
|
206
|
+
return !(year % 4) && (!!(year % 100) || !(year % 400));
|
|
207
|
+
}
|
|
208
|
+
/**
|
|
209
|
+
* Number of days in the Gregorian month for given year
|
|
210
|
+
* @private
|
|
211
|
+
* @param {number} month Gregorian month (1=January, 12=December)
|
|
212
|
+
* @param {number} year Gregorian year
|
|
213
|
+
* @return {number}
|
|
214
|
+
*/
|
|
215
|
+
|
|
216
|
+
function daysInMonth$1(month, year) {
|
|
217
|
+
// 1 based months
|
|
218
|
+
return monthLengths[+isLeapYear$1(year)][month];
|
|
219
|
+
}
|
|
220
|
+
/**
|
|
221
|
+
* Returns true if the object is a Javascript Date
|
|
222
|
+
* @private
|
|
223
|
+
* @param {Object} obj
|
|
224
|
+
* @return {boolean}
|
|
225
|
+
*/
|
|
226
|
+
|
|
227
|
+
function isDate(obj) {
|
|
228
|
+
return typeof obj === 'object' && Date.prototype === obj.__proto__;
|
|
229
|
+
}
|
|
230
|
+
/**
|
|
231
|
+
* Returns number of days since January 1 of that year
|
|
232
|
+
* @private
|
|
233
|
+
* @param {Date} date Gregorian date
|
|
234
|
+
* @return {number}
|
|
235
|
+
*/
|
|
236
|
+
|
|
237
|
+
function dayOfYear(date) {
|
|
238
|
+
if (!isDate(date)) {
|
|
239
|
+
throw new TypeError('Argument to greg.dayOfYear not a Date');
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
let doy = date.getDate() + 31 * date.getMonth();
|
|
243
|
+
|
|
244
|
+
if (date.getMonth() > 1) {
|
|
245
|
+
// FEB
|
|
246
|
+
doy -= Math.floor((4 * (date.getMonth() + 1) + 23) / 10);
|
|
247
|
+
|
|
248
|
+
if (isLeapYear$1(date.getFullYear())) {
|
|
249
|
+
doy++;
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
return doy;
|
|
254
|
+
}
|
|
255
|
+
/**
|
|
256
|
+
* Converts Gregorian date to absolute R.D. (Rata Die) days
|
|
257
|
+
* @private
|
|
258
|
+
* @param {Date} date Gregorian date
|
|
259
|
+
* @return {number}
|
|
260
|
+
*/
|
|
261
|
+
|
|
262
|
+
function greg2abs(date) {
|
|
263
|
+
if (!isDate(date)) {
|
|
264
|
+
throw new TypeError('Argument to greg.greg2abs not a Date');
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
const year = date.getFullYear() - 1;
|
|
268
|
+
return dayOfYear(date) + // days this year
|
|
269
|
+
365 * year + ( // + days in prior years
|
|
270
|
+
Math.floor(year / 4) - // + Julian Leap years
|
|
271
|
+
Math.floor(year / 100) + // - century years
|
|
272
|
+
Math.floor(year / 400)); // + Gregorian leap years
|
|
273
|
+
}
|
|
274
|
+
/**
|
|
275
|
+
* @private
|
|
276
|
+
* @param {number} abs - R.D. number of days
|
|
277
|
+
* @return {number}
|
|
278
|
+
*/
|
|
279
|
+
|
|
280
|
+
function yearFromFixed(abs) {
|
|
281
|
+
const l0 = abs - 1;
|
|
282
|
+
const n400 = quotient(l0, 146097);
|
|
283
|
+
const d1 = mod(l0, 146097);
|
|
284
|
+
const n100 = quotient(d1, 36524);
|
|
285
|
+
const d2 = mod(d1, 36524);
|
|
286
|
+
const n4 = quotient(d2, 1461);
|
|
287
|
+
const d3 = mod(d2, 1461);
|
|
288
|
+
const n1 = quotient(d3, 365);
|
|
289
|
+
const year = 400 * n400 + 100 * n100 + 4 * n4 + n1;
|
|
290
|
+
return n100 != 4 && n1 != 4 ? year + 1 : year;
|
|
291
|
+
}
|
|
292
|
+
/**
|
|
293
|
+
* @private
|
|
294
|
+
* @param {number} year
|
|
295
|
+
* @param {number} month
|
|
296
|
+
* @param {number} day
|
|
297
|
+
* @return {number}
|
|
298
|
+
*/
|
|
299
|
+
|
|
300
|
+
|
|
301
|
+
function toFixed(year, month, day) {
|
|
302
|
+
const py = year - 1;
|
|
303
|
+
return 0 + 365 * py + quotient(py, 4) - quotient(py, 100) + quotient(py, 400) + quotient(367 * month - 362, 12) + Math.floor(month <= 2 ? 0 : isLeapYear$1(year) ? -1 : -2) + day;
|
|
304
|
+
}
|
|
305
|
+
/**
|
|
306
|
+
* Converts from Rata Die (R.D. number) to Gregorian date.
|
|
307
|
+
* See the footnote on page 384 of ``Calendrical Calculations, Part II:
|
|
308
|
+
* Three Historical Calendars'' by E. M. Reingold, N. Dershowitz, and S. M.
|
|
309
|
+
* Clamen, Software--Practice and Experience, Volume 23, Number 4
|
|
310
|
+
* (April, 1993), pages 383-404 for an explanation.
|
|
311
|
+
* @private
|
|
312
|
+
* @param {number} abs - R.D. number of days
|
|
313
|
+
* @return {Date}
|
|
314
|
+
*/
|
|
315
|
+
|
|
316
|
+
|
|
317
|
+
function abs2greg(abs) {
|
|
318
|
+
if (typeof abs !== 'number') {
|
|
319
|
+
throw new TypeError('Argument to greg.abs2greg not a Number');
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
abs = Math.trunc(abs);
|
|
323
|
+
const year = yearFromFixed(abs);
|
|
324
|
+
const priorDays = abs - toFixed(year, 1, 1);
|
|
325
|
+
const correction = abs < toFixed(year, 3, 1) ? 0 : isLeapYear$1(year) ? 1 : 2;
|
|
326
|
+
const month = quotient(12 * (priorDays + correction) + 373, 367);
|
|
327
|
+
const day = abs - toFixed(year, month, 1) + 1;
|
|
328
|
+
const dt = new Date(year, month - 1, day);
|
|
329
|
+
|
|
330
|
+
if (year < 100 && year >= 0) {
|
|
331
|
+
dt.setFullYear(year);
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
return dt;
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
/*
|
|
338
|
+
Hebcal - A Jewish Calendar Generator
|
|
339
|
+
Copyright (c) 1994-2020 Danny Sadinoff
|
|
340
|
+
Portions copyright Eyal Schachter and Michael J. Radwin
|
|
341
|
+
|
|
342
|
+
https://github.com/hebcal/hebcal-es6
|
|
343
|
+
|
|
344
|
+
This program is free software; you can redistribute it and/or
|
|
345
|
+
modify it under the terms of the GNU General Public License
|
|
346
|
+
as published by the Free Software Foundation; either version 2
|
|
347
|
+
of the License, or (at your option) any later version.
|
|
348
|
+
|
|
349
|
+
This program is distributed in the hope that it will be useful,
|
|
350
|
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
351
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
352
|
+
GNU General Public License for more details.
|
|
353
|
+
|
|
354
|
+
You should have received a copy of the GNU General Public License
|
|
355
|
+
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
356
|
+
*/
|
|
357
|
+
/**
|
|
358
|
+
* Gregorian date helper functions.
|
|
359
|
+
*/
|
|
360
|
+
|
|
217
361
|
class greg {
|
|
218
362
|
/**
|
|
219
363
|
* Long names of the Gregorian months (1='January', 12='December')
|
|
@@ -228,7 +372,7 @@ class greg {
|
|
|
228
372
|
*/
|
|
229
373
|
|
|
230
374
|
static isLeapYear(year) {
|
|
231
|
-
return
|
|
375
|
+
return isLeapYear$1(year);
|
|
232
376
|
}
|
|
233
377
|
/**
|
|
234
378
|
* Number of days in the Gregorian month for given year
|
|
@@ -239,8 +383,7 @@ class greg {
|
|
|
239
383
|
|
|
240
384
|
|
|
241
385
|
static daysInMonth(month, year) {
|
|
242
|
-
|
|
243
|
-
return monthLengths[+this.isLeapYear(year)][month];
|
|
386
|
+
return daysInMonth$1(month, year);
|
|
244
387
|
}
|
|
245
388
|
/**
|
|
246
389
|
* Returns true if the object is a Javascript Date
|
|
@@ -250,7 +393,7 @@ class greg {
|
|
|
250
393
|
|
|
251
394
|
|
|
252
395
|
static isDate(obj) {
|
|
253
|
-
return
|
|
396
|
+
return isDate(obj);
|
|
254
397
|
}
|
|
255
398
|
/**
|
|
256
399
|
* Returns number of days since January 1 of that year
|
|
@@ -260,22 +403,7 @@ class greg {
|
|
|
260
403
|
|
|
261
404
|
|
|
262
405
|
static dayOfYear(date) {
|
|
263
|
-
|
|
264
|
-
throw new TypeError('Argument to greg.dayOfYear not a Date');
|
|
265
|
-
}
|
|
266
|
-
|
|
267
|
-
let doy = date.getDate() + 31 * date.getMonth();
|
|
268
|
-
|
|
269
|
-
if (date.getMonth() > 1) {
|
|
270
|
-
// FEB
|
|
271
|
-
doy -= Math.floor((4 * (date.getMonth() + 1) + 23) / 10);
|
|
272
|
-
|
|
273
|
-
if (this.isLeapYear(date.getFullYear())) {
|
|
274
|
-
doy++;
|
|
275
|
-
}
|
|
276
|
-
}
|
|
277
|
-
|
|
278
|
-
return doy;
|
|
406
|
+
return dayOfYear(date);
|
|
279
407
|
}
|
|
280
408
|
/**
|
|
281
409
|
* Converts Gregorian date to absolute R.D. (Rata Die) days
|
|
@@ -285,48 +413,7 @@ class greg {
|
|
|
285
413
|
|
|
286
414
|
|
|
287
415
|
static greg2abs(date) {
|
|
288
|
-
|
|
289
|
-
throw new TypeError('Argument to greg.greg2abs not a Date');
|
|
290
|
-
}
|
|
291
|
-
|
|
292
|
-
const year = date.getFullYear() - 1;
|
|
293
|
-
return this.dayOfYear(date) + // days this year
|
|
294
|
-
365 * year + ( // + days in prior years
|
|
295
|
-
Math.floor(year / 4) - // + Julian Leap years
|
|
296
|
-
Math.floor(year / 100) + // - century years
|
|
297
|
-
Math.floor(year / 400)); // + Gregorian leap years
|
|
298
|
-
}
|
|
299
|
-
/**
|
|
300
|
-
* @private
|
|
301
|
-
* @param {number} theDate - R.D. number of days
|
|
302
|
-
* @return {number}
|
|
303
|
-
*/
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
static yearFromFixed(theDate) {
|
|
307
|
-
const l0 = theDate - 1;
|
|
308
|
-
const n400 = quotient(l0, 146097);
|
|
309
|
-
const d1 = mod(l0, 146097);
|
|
310
|
-
const n100 = quotient(d1, 36524);
|
|
311
|
-
const d2 = mod(d1, 36524);
|
|
312
|
-
const n4 = quotient(d2, 1461);
|
|
313
|
-
const d3 = mod(d2, 1461);
|
|
314
|
-
const n1 = quotient(d3, 365);
|
|
315
|
-
const year = 400 * n400 + 100 * n100 + 4 * n4 + n1;
|
|
316
|
-
return n100 != 4 && n1 != 4 ? year + 1 : year;
|
|
317
|
-
}
|
|
318
|
-
/**
|
|
319
|
-
* @private
|
|
320
|
-
* @param {number} year
|
|
321
|
-
* @param {number} month
|
|
322
|
-
* @param {number} day
|
|
323
|
-
* @return {number}
|
|
324
|
-
*/
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
static toFixed(year, month, day) {
|
|
328
|
-
const py = year - 1;
|
|
329
|
-
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;
|
|
416
|
+
return greg2abs(date);
|
|
330
417
|
}
|
|
331
418
|
/**
|
|
332
419
|
* Converts from Rata Die (R.D. number) to Gregorian date.
|
|
@@ -340,23 +427,7 @@ class greg {
|
|
|
340
427
|
|
|
341
428
|
|
|
342
429
|
static abs2greg(theDate) {
|
|
343
|
-
|
|
344
|
-
throw new TypeError('Argument to greg.abs2greg not a Number');
|
|
345
|
-
}
|
|
346
|
-
|
|
347
|
-
theDate = Math.trunc(theDate);
|
|
348
|
-
const year = this.yearFromFixed(theDate);
|
|
349
|
-
const priorDays = theDate - this.toFixed(year, 1, 1);
|
|
350
|
-
const correction = theDate < this.toFixed(year, 3, 1) ? 0 : this.isLeapYear(year) ? 1 : 2;
|
|
351
|
-
const month = quotient(12 * (priorDays + correction) + 373, 367);
|
|
352
|
-
const day = theDate - this.toFixed(year, month, 1) + 1;
|
|
353
|
-
const dt = new Date(year, month - 1, day);
|
|
354
|
-
|
|
355
|
-
if (year < 100 && year >= 0) {
|
|
356
|
-
dt.setFullYear(year);
|
|
357
|
-
}
|
|
358
|
-
|
|
359
|
-
return dt;
|
|
430
|
+
return abs2greg(theDate);
|
|
360
431
|
}
|
|
361
432
|
|
|
362
433
|
}
|
|
@@ -548,37 +619,20 @@ Locale.addLocale('s', noopLocale);
|
|
|
548
619
|
Locale.addLocale('', noopLocale);
|
|
549
620
|
Locale.useLocale('en');
|
|
550
621
|
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
Copyright (c) 1994-2020 Danny Sadinoff
|
|
554
|
-
Portions copyright Eyal Schachter and Michael J. Radwin
|
|
555
|
-
|
|
556
|
-
https://github.com/hebcal/hebcal-es6
|
|
557
|
-
|
|
558
|
-
This program is free software; you can redistribute it and/or
|
|
559
|
-
modify it under the terms of the GNU General Public License
|
|
560
|
-
as published by the Free Software Foundation; either version 2
|
|
561
|
-
of the License, or (at your option) any later version.
|
|
562
|
-
|
|
563
|
-
This program is distributed in the hope that it will be useful,
|
|
564
|
-
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
565
|
-
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
566
|
-
GNU General Public License for more details.
|
|
567
|
-
|
|
568
|
-
You should have received a copy of the GNU General Public License
|
|
569
|
-
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
622
|
+
/**
|
|
623
|
+
* More minimal HDate
|
|
570
624
|
*/
|
|
571
625
|
const NISAN$1 = 1;
|
|
572
|
-
const IYYAR = 2;
|
|
573
|
-
|
|
574
|
-
const TAMUZ = 4;
|
|
575
|
-
|
|
626
|
+
const IYYAR = 2; // const SIVAN = 3;
|
|
627
|
+
|
|
628
|
+
const TAMUZ = 4; // const AV = 5;
|
|
629
|
+
|
|
576
630
|
const ELUL = 6;
|
|
577
631
|
const TISHREI = 7;
|
|
578
632
|
const CHESHVAN$1 = 8;
|
|
579
633
|
const KISLEV$1 = 9;
|
|
580
|
-
const TEVET$1 = 10;
|
|
581
|
-
|
|
634
|
+
const TEVET$1 = 10; // const SHVAT = 11;
|
|
635
|
+
|
|
582
636
|
const ADAR_I$1 = 12;
|
|
583
637
|
const ADAR_II$1 = 13;
|
|
584
638
|
/**
|
|
@@ -634,16 +688,244 @@ const monthNames0 = ['', 'Nisan', 'Iyyar', 'Sivan', 'Tamuz', 'Av', 'Elul', 'Tish
|
|
|
634
688
|
* @private
|
|
635
689
|
*/
|
|
636
690
|
|
|
637
|
-
const monthNames = [monthNames0.concat(['Adar', 'Nisan']), monthNames0.concat(['Adar I', 'Adar II', 'Nisan'])];
|
|
691
|
+
const monthNames = [monthNames0.concat(['Adar', 'Nisan']), monthNames0.concat(['Adar I', 'Adar II', 'Nisan'])];
|
|
692
|
+
const edCache = Object.create(null);
|
|
693
|
+
const EPOCH = -1373428; // Avg year length in the cycle (19 solar years with 235 lunar months)
|
|
694
|
+
|
|
695
|
+
const AVG_HEBYEAR_DAYS = 365.24682220597794;
|
|
696
|
+
/**
|
|
697
|
+
* Converts Hebrew date to R.D. (Rata Die) fixed days.
|
|
698
|
+
* R.D. 1 is the imaginary date Monday, January 1, 1 on the Gregorian
|
|
699
|
+
* Calendar.
|
|
700
|
+
* @param {number} year Hebrew year
|
|
701
|
+
* @param {number} month Hebrew month
|
|
702
|
+
* @param {number} day Hebrew date (1-30)
|
|
703
|
+
* @return {number}
|
|
704
|
+
*/
|
|
705
|
+
|
|
706
|
+
function hebrew2abs(year, month, day) {
|
|
707
|
+
let tempabs = day;
|
|
708
|
+
|
|
709
|
+
if (month < TISHREI) {
|
|
710
|
+
for (let m = TISHREI; m <= monthsInYear(year); m++) {
|
|
711
|
+
tempabs += daysInMonth(m, year);
|
|
712
|
+
}
|
|
713
|
+
|
|
714
|
+
for (let m = NISAN$1; m < month; m++) {
|
|
715
|
+
tempabs += daysInMonth(m, year);
|
|
716
|
+
}
|
|
717
|
+
} else {
|
|
718
|
+
for (let m = TISHREI; m < month; m++) {
|
|
719
|
+
tempabs += daysInMonth(m, year);
|
|
720
|
+
}
|
|
721
|
+
}
|
|
722
|
+
|
|
723
|
+
return EPOCH + elapsedDays(year) + tempabs - 1;
|
|
724
|
+
}
|
|
725
|
+
/**
|
|
726
|
+
* @private
|
|
727
|
+
* @param {number} year
|
|
728
|
+
* @return {number}
|
|
729
|
+
*/
|
|
730
|
+
|
|
731
|
+
function newYear(year) {
|
|
732
|
+
return EPOCH + elapsedDays(year) + newYearDelay(year);
|
|
733
|
+
}
|
|
734
|
+
/**
|
|
735
|
+
* @private
|
|
736
|
+
* @param {number} year
|
|
737
|
+
* @return {number}
|
|
738
|
+
*/
|
|
739
|
+
|
|
740
|
+
|
|
741
|
+
function newYearDelay(year) {
|
|
742
|
+
const ny1 = elapsedDays(year);
|
|
743
|
+
const ny2 = elapsedDays(year + 1);
|
|
744
|
+
|
|
745
|
+
if (ny2 - ny1 === 356) {
|
|
746
|
+
return 2;
|
|
747
|
+
} else {
|
|
748
|
+
const ny0 = elapsedDays(year - 1);
|
|
749
|
+
return ny1 - ny0 === 382 ? 1 : 0;
|
|
750
|
+
}
|
|
751
|
+
}
|
|
752
|
+
/**
|
|
753
|
+
* Converts absolute R.D. days to Hebrew date
|
|
754
|
+
* @private
|
|
755
|
+
* @param {number} abs absolute R.D. days
|
|
756
|
+
* @return {SimpleHebrewDate}
|
|
757
|
+
*/
|
|
758
|
+
|
|
759
|
+
|
|
760
|
+
function abs2hebrew(abs) {
|
|
761
|
+
if (typeof abs !== 'number' || isNaN(abs)) {
|
|
762
|
+
throw new TypeError(`invalid parameter to abs2hebrew ${abs}`);
|
|
763
|
+
}
|
|
764
|
+
|
|
765
|
+
abs = Math.trunc(abs); // first, quickly approximate year
|
|
766
|
+
|
|
767
|
+
let year = Math.floor((abs - EPOCH) / AVG_HEBYEAR_DAYS);
|
|
768
|
+
|
|
769
|
+
while (newYear(year) <= abs) {
|
|
770
|
+
++year;
|
|
771
|
+
}
|
|
772
|
+
|
|
773
|
+
--year;
|
|
774
|
+
let month = abs < hebrew2abs(year, 1, 1) ? 7 : 1;
|
|
775
|
+
|
|
776
|
+
while (abs > hebrew2abs(year, month, daysInMonth(month, year))) {
|
|
777
|
+
++month;
|
|
778
|
+
}
|
|
779
|
+
|
|
780
|
+
const day = 1 + abs - hebrew2abs(year, month, 1);
|
|
781
|
+
return {
|
|
782
|
+
yy: year,
|
|
783
|
+
mm: month,
|
|
784
|
+
dd: day
|
|
785
|
+
};
|
|
786
|
+
}
|
|
787
|
+
/**
|
|
788
|
+
* Returns true if Hebrew year is a leap year
|
|
789
|
+
* @param {number} year Hebrew year
|
|
790
|
+
* @return {boolean}
|
|
791
|
+
*/
|
|
792
|
+
|
|
793
|
+
function isLeapYear(year) {
|
|
794
|
+
return (1 + year * 7) % 19 < 7;
|
|
795
|
+
}
|
|
796
|
+
/**
|
|
797
|
+
* Number of months in this Hebrew year (either 12 or 13 depending on leap year)
|
|
798
|
+
* @param {number} year Hebrew year
|
|
799
|
+
* @return {number}
|
|
800
|
+
*/
|
|
801
|
+
|
|
802
|
+
function monthsInYear(year) {
|
|
803
|
+
return 12 + isLeapYear(year); // boolean is cast to 1 or 0
|
|
804
|
+
}
|
|
805
|
+
/**
|
|
806
|
+
* Number of days in Hebrew month in a given year (29 or 30)
|
|
807
|
+
* @param {number} month Hebrew month (e.g. months.TISHREI)
|
|
808
|
+
* @param {number} year Hebrew year
|
|
809
|
+
* @return {number}
|
|
810
|
+
*/
|
|
811
|
+
|
|
812
|
+
function daysInMonth(month, year) {
|
|
813
|
+
switch (month) {
|
|
814
|
+
case IYYAR:
|
|
815
|
+
case TAMUZ:
|
|
816
|
+
case ELUL:
|
|
817
|
+
case TEVET$1:
|
|
818
|
+
case ADAR_II$1:
|
|
819
|
+
return 29;
|
|
820
|
+
}
|
|
821
|
+
|
|
822
|
+
if (month === ADAR_I$1 && !isLeapYear(year) || month === CHESHVAN$1 && !longCheshvan(year) || month === KISLEV$1 && shortKislev(year)) {
|
|
823
|
+
return 29;
|
|
824
|
+
} else {
|
|
825
|
+
return 30;
|
|
826
|
+
}
|
|
827
|
+
}
|
|
828
|
+
/**
|
|
829
|
+
* Returns a transliterated string name of Hebrew month in year,
|
|
830
|
+
* for example 'Elul' or 'Cheshvan'.
|
|
831
|
+
* @param {number} month Hebrew month (e.g. months.TISHREI)
|
|
832
|
+
* @param {number} year Hebrew year
|
|
833
|
+
* @return {string}
|
|
834
|
+
*/
|
|
835
|
+
|
|
836
|
+
function getMonthName(month, year) {
|
|
837
|
+
if (typeof month !== 'number' || month < 1 || month > 14) {
|
|
838
|
+
throw new TypeError(`bad month argument ${month}`);
|
|
839
|
+
}
|
|
840
|
+
|
|
841
|
+
return monthNames[+isLeapYear(year)][month];
|
|
842
|
+
}
|
|
843
|
+
/**
|
|
844
|
+
* Days from sunday prior to start of Hebrew calendar to mean
|
|
845
|
+
* conjunction of Tishrei in Hebrew YEAR
|
|
846
|
+
* @param {number} year Hebrew year
|
|
847
|
+
* @return {number}
|
|
848
|
+
*/
|
|
849
|
+
|
|
850
|
+
function elapsedDays(year) {
|
|
851
|
+
const elapsed = edCache[year] = edCache[year] || elapsedDays0(year);
|
|
852
|
+
return elapsed;
|
|
853
|
+
}
|
|
854
|
+
/**
|
|
855
|
+
* Days from sunday prior to start of Hebrew calendar to mean
|
|
856
|
+
* conjunction of Tishrei in Hebrew YEAR
|
|
857
|
+
* @private
|
|
858
|
+
* @param {number} year Hebrew year
|
|
859
|
+
* @return {number}
|
|
860
|
+
*/
|
|
861
|
+
|
|
862
|
+
function elapsedDays0(year) {
|
|
863
|
+
const prevYear = year - 1;
|
|
864
|
+
const mElapsed = 235 * Math.floor(prevYear / 19) + // Months in complete 19 year lunar (Metonic) cycles so far
|
|
865
|
+
12 * (prevYear % 19) + // Regular months in this cycle
|
|
866
|
+
Math.floor((prevYear % 19 * 7 + 1) / 19); // Leap months this cycle
|
|
867
|
+
|
|
868
|
+
const pElapsed = 204 + 793 * (mElapsed % 1080);
|
|
869
|
+
const hElapsed = 5 + 12 * mElapsed + 793 * Math.floor(mElapsed / 1080) + Math.floor(pElapsed / 1080);
|
|
870
|
+
const parts = pElapsed % 1080 + 1080 * (hElapsed % 24);
|
|
871
|
+
const day = 1 + 29 * mElapsed + Math.floor(hElapsed / 24);
|
|
872
|
+
const altDay = day + (parts >= 19440 || 2 === day % 7 && parts >= 9924 && !isLeapYear(year) || 1 === day % 7 && parts >= 16789 && isLeapYear(prevYear));
|
|
873
|
+
return altDay + (altDay % 7 === 0 || altDay % 7 === 3 || altDay % 7 === 5);
|
|
874
|
+
}
|
|
875
|
+
/**
|
|
876
|
+
* Number of days in the hebrew YEAR
|
|
877
|
+
* @param {number} year Hebrew year
|
|
878
|
+
* @return {number}
|
|
879
|
+
*/
|
|
880
|
+
|
|
881
|
+
|
|
882
|
+
function daysInYear(year) {
|
|
883
|
+
return elapsedDays(year + 1) - elapsedDays(year);
|
|
884
|
+
}
|
|
885
|
+
/**
|
|
886
|
+
* true if Cheshvan is long in Hebrew year
|
|
887
|
+
* @param {number} year Hebrew year
|
|
888
|
+
* @return {boolean}
|
|
889
|
+
*/
|
|
890
|
+
|
|
891
|
+
function longCheshvan(year) {
|
|
892
|
+
return daysInYear(year) % 10 === 5;
|
|
893
|
+
}
|
|
894
|
+
/**
|
|
895
|
+
* true if Kislev is short in Hebrew year
|
|
896
|
+
* @param {number} year Hebrew year
|
|
897
|
+
* @return {boolean}
|
|
898
|
+
*/
|
|
899
|
+
|
|
900
|
+
function shortKislev(year) {
|
|
901
|
+
return daysInYear(year) % 10 === 3;
|
|
902
|
+
}
|
|
903
|
+
|
|
904
|
+
/*
|
|
905
|
+
Hebcal - A Jewish Calendar Generator
|
|
906
|
+
Copyright (c) 1994-2020 Danny Sadinoff
|
|
907
|
+
Portions copyright Eyal Schachter and Michael J. Radwin
|
|
908
|
+
|
|
909
|
+
https://github.com/hebcal/hebcal-es6
|
|
910
|
+
|
|
911
|
+
This program is free software; you can redistribute it and/or
|
|
912
|
+
modify it under the terms of the GNU General Public License
|
|
913
|
+
as published by the Free Software Foundation; either version 2
|
|
914
|
+
of the License, or (at your option) any later version.
|
|
915
|
+
|
|
916
|
+
This program is distributed in the hope that it will be useful,
|
|
917
|
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
918
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
919
|
+
GNU General Public License for more details.
|
|
920
|
+
|
|
921
|
+
You should have received a copy of the GNU General Public License
|
|
922
|
+
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
923
|
+
*/
|
|
638
924
|
|
|
639
925
|
function throwTypeError(msg) {
|
|
640
926
|
throw new TypeError(msg);
|
|
641
927
|
}
|
|
642
928
|
|
|
643
|
-
const edCache = Object.create(null);
|
|
644
|
-
const EPOCH = -1373428; // Avg year length in the cycle (19 solar years with 235 lunar months)
|
|
645
|
-
|
|
646
|
-
const AVG_HEBYEAR_DAYS = 365.24682220597794;
|
|
647
929
|
const UNITS_DAY = 'day';
|
|
648
930
|
const UNITS_WEEK = 'week';
|
|
649
931
|
const UNITS_MONTH = 'month';
|
|
@@ -746,7 +1028,7 @@ class HDate {
|
|
|
746
1028
|
yy: day.year
|
|
747
1029
|
} : throwTypeError(`HDate called with bad argument: ${day}`);
|
|
748
1030
|
const isNumber = typeof abs0 === 'number';
|
|
749
|
-
const d = isNumber ?
|
|
1031
|
+
const d = isNumber ? abs2hebrew(abs0) : abs0;
|
|
750
1032
|
/**
|
|
751
1033
|
* @private
|
|
752
1034
|
* @type {number}
|
|
@@ -791,7 +1073,7 @@ class HDate {
|
|
|
791
1073
|
|
|
792
1074
|
|
|
793
1075
|
isLeapYear() {
|
|
794
|
-
return
|
|
1076
|
+
return isLeapYear(this.year);
|
|
795
1077
|
}
|
|
796
1078
|
/**
|
|
797
1079
|
* Gets the Hebrew month (1=NISAN, 7=TISHREI) of this Hebrew date
|
|
@@ -809,7 +1091,7 @@ class HDate {
|
|
|
809
1091
|
|
|
810
1092
|
|
|
811
1093
|
getTishreiMonth() {
|
|
812
|
-
const nummonths =
|
|
1094
|
+
const nummonths = monthsInYear(this.getFullYear());
|
|
813
1095
|
return (this.getMonth() + nummonths - 6) % nummonths || nummonths;
|
|
814
1096
|
}
|
|
815
1097
|
/**
|
|
@@ -819,7 +1101,7 @@ class HDate {
|
|
|
819
1101
|
|
|
820
1102
|
|
|
821
1103
|
daysInMonth() {
|
|
822
|
-
return
|
|
1104
|
+
return daysInMonth(this.getMonth(), this.getFullYear());
|
|
823
1105
|
}
|
|
824
1106
|
/**
|
|
825
1107
|
* Gets the day within the month (1-30)
|
|
@@ -898,7 +1180,7 @@ class HDate {
|
|
|
898
1180
|
|
|
899
1181
|
abs() {
|
|
900
1182
|
if (typeof this.abs0 !== 'number') {
|
|
901
|
-
this.abs0 =
|
|
1183
|
+
this.abs0 = hebrew2abs(this.year, this.month, this.day);
|
|
902
1184
|
}
|
|
903
1185
|
|
|
904
1186
|
return this.abs0;
|
|
@@ -915,51 +1197,7 @@ class HDate {
|
|
|
915
1197
|
|
|
916
1198
|
|
|
917
1199
|
static hebrew2abs(year, month, day) {
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
if (month < TISHREI) {
|
|
921
|
-
for (let m = TISHREI; m <= HDate.monthsInYear(year); m++) {
|
|
922
|
-
tempabs += HDate.daysInMonth(m, year);
|
|
923
|
-
}
|
|
924
|
-
|
|
925
|
-
for (let m = NISAN$1; m < month; m++) {
|
|
926
|
-
tempabs += HDate.daysInMonth(m, year);
|
|
927
|
-
}
|
|
928
|
-
} else {
|
|
929
|
-
for (let m = TISHREI; m < month; m++) {
|
|
930
|
-
tempabs += HDate.daysInMonth(m, year);
|
|
931
|
-
}
|
|
932
|
-
}
|
|
933
|
-
|
|
934
|
-
return EPOCH + HDate.elapsedDays(year) + tempabs - 1;
|
|
935
|
-
}
|
|
936
|
-
/**
|
|
937
|
-
* @private
|
|
938
|
-
* @param {number} year
|
|
939
|
-
* @return {number}
|
|
940
|
-
*/
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
static newYear(year) {
|
|
944
|
-
return EPOCH + HDate.elapsedDays(year) + HDate.newYearDelay(year);
|
|
945
|
-
}
|
|
946
|
-
/**
|
|
947
|
-
* @private
|
|
948
|
-
* @param {number} year
|
|
949
|
-
* @return {number}
|
|
950
|
-
*/
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
static newYearDelay(year) {
|
|
954
|
-
const ny1 = HDate.elapsedDays(year);
|
|
955
|
-
const ny2 = HDate.elapsedDays(year + 1);
|
|
956
|
-
|
|
957
|
-
if (ny2 - ny1 === 356) {
|
|
958
|
-
return 2;
|
|
959
|
-
} else {
|
|
960
|
-
const ny0 = HDate.elapsedDays(year - 1);
|
|
961
|
-
return ny1 - ny0 === 382 ? 1 : 0;
|
|
962
|
-
}
|
|
1200
|
+
return hebrew2abs(year, month, day);
|
|
963
1201
|
}
|
|
964
1202
|
/**
|
|
965
1203
|
* Converts absolute R.D. days to Hebrew date
|
|
@@ -970,31 +1208,7 @@ class HDate {
|
|
|
970
1208
|
|
|
971
1209
|
|
|
972
1210
|
static abs2hebrew(abs) {
|
|
973
|
-
|
|
974
|
-
throw new TypeError(`invalid parameter to abs2hebrew ${abs}`);
|
|
975
|
-
}
|
|
976
|
-
|
|
977
|
-
abs = Math.trunc(abs); // first, quickly approximate year
|
|
978
|
-
|
|
979
|
-
let year = Math.floor((abs - EPOCH) / AVG_HEBYEAR_DAYS);
|
|
980
|
-
|
|
981
|
-
while (HDate.newYear(year) <= abs) {
|
|
982
|
-
++year;
|
|
983
|
-
}
|
|
984
|
-
|
|
985
|
-
--year;
|
|
986
|
-
let month = abs < HDate.hebrew2abs(year, 1, 1) ? 7 : 1;
|
|
987
|
-
|
|
988
|
-
while (abs > HDate.hebrew2abs(year, month, HDate.daysInMonth(month, year))) {
|
|
989
|
-
++month;
|
|
990
|
-
}
|
|
991
|
-
|
|
992
|
-
const day = 1 + abs - HDate.hebrew2abs(year, month, 1);
|
|
993
|
-
return {
|
|
994
|
-
yy: year,
|
|
995
|
-
mm: month,
|
|
996
|
-
dd: day
|
|
997
|
-
};
|
|
1211
|
+
return abs2hebrew(abs);
|
|
998
1212
|
}
|
|
999
1213
|
/**
|
|
1000
1214
|
* Returns a transliterated Hebrew month name, e.g. `'Elul'` or `'Cheshvan'`.
|
|
@@ -1003,7 +1217,7 @@ class HDate {
|
|
|
1003
1217
|
|
|
1004
1218
|
|
|
1005
1219
|
getMonthName() {
|
|
1006
|
-
return
|
|
1220
|
+
return getMonthName(this.getMonth(), this.getFullYear());
|
|
1007
1221
|
}
|
|
1008
1222
|
/**
|
|
1009
1223
|
* Renders this Hebrew date as a translated or transliterated string,
|
|
@@ -1309,7 +1523,7 @@ class HDate {
|
|
|
1309
1523
|
|
|
1310
1524
|
|
|
1311
1525
|
static isLeapYear(year) {
|
|
1312
|
-
return (
|
|
1526
|
+
return isLeapYear(year);
|
|
1313
1527
|
}
|
|
1314
1528
|
/**
|
|
1315
1529
|
* Number of months in this Hebrew year (either 12 or 13 depending on leap year)
|
|
@@ -1319,7 +1533,7 @@ class HDate {
|
|
|
1319
1533
|
|
|
1320
1534
|
|
|
1321
1535
|
static monthsInYear(year) {
|
|
1322
|
-
return
|
|
1536
|
+
return monthsInYear(year);
|
|
1323
1537
|
}
|
|
1324
1538
|
/**
|
|
1325
1539
|
* Number of days in Hebrew month in a given year (29 or 30)
|
|
@@ -1330,11 +1544,7 @@ class HDate {
|
|
|
1330
1544
|
|
|
1331
1545
|
|
|
1332
1546
|
static daysInMonth(month, year) {
|
|
1333
|
-
|
|
1334
|
-
return 29;
|
|
1335
|
-
} else {
|
|
1336
|
-
return 30;
|
|
1337
|
-
}
|
|
1547
|
+
return daysInMonth(month, year);
|
|
1338
1548
|
}
|
|
1339
1549
|
/**
|
|
1340
1550
|
* Returns a transliterated string name of Hebrew month in year,
|
|
@@ -1346,11 +1556,7 @@ class HDate {
|
|
|
1346
1556
|
|
|
1347
1557
|
|
|
1348
1558
|
static getMonthName(month, year) {
|
|
1349
|
-
|
|
1350
|
-
throw new TypeError(`bad month argument ${month}`);
|
|
1351
|
-
}
|
|
1352
|
-
|
|
1353
|
-
return monthNames[+HDate.isLeapYear(year)][month];
|
|
1559
|
+
return getMonthName(month, year);
|
|
1354
1560
|
}
|
|
1355
1561
|
/**
|
|
1356
1562
|
* Returns the Hebrew month number (NISAN=1, TISHREI=7)
|
|
@@ -1364,40 +1570,6 @@ class HDate {
|
|
|
1364
1570
|
/* number */
|
|
1365
1571
|
parseInt(month, 10) : HDate.monthFromName(month);
|
|
1366
1572
|
}
|
|
1367
|
-
/**
|
|
1368
|
-
* Days from sunday prior to start of Hebrew calendar to mean
|
|
1369
|
-
* conjunction of Tishrei in Hebrew YEAR
|
|
1370
|
-
* @param {number} year Hebrew year
|
|
1371
|
-
* @return {number}
|
|
1372
|
-
*/
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
static elapsedDays(year) {
|
|
1376
|
-
const elapsed = edCache[year] = edCache[year] || HDate.elapsedDays0(year);
|
|
1377
|
-
return elapsed;
|
|
1378
|
-
}
|
|
1379
|
-
/**
|
|
1380
|
-
* Days from sunday prior to start of Hebrew calendar to mean
|
|
1381
|
-
* conjunction of Tishrei in Hebrew YEAR
|
|
1382
|
-
* @private
|
|
1383
|
-
* @param {number} year Hebrew year
|
|
1384
|
-
* @return {number}
|
|
1385
|
-
*/
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
static elapsedDays0(year) {
|
|
1389
|
-
const prevYear = year - 1;
|
|
1390
|
-
const mElapsed = 235 * Math.floor(prevYear / 19) + // Months in complete 19 year lunar (Metonic) cycles so far
|
|
1391
|
-
12 * (prevYear % 19) + // Regular months in this cycle
|
|
1392
|
-
Math.floor((prevYear % 19 * 7 + 1) / 19); // Leap months this cycle
|
|
1393
|
-
|
|
1394
|
-
const pElapsed = 204 + 793 * (mElapsed % 1080);
|
|
1395
|
-
const hElapsed = 5 + 12 * mElapsed + 793 * Math.floor(mElapsed / 1080) + Math.floor(pElapsed / 1080);
|
|
1396
|
-
const parts = pElapsed % 1080 + 1080 * (hElapsed % 24);
|
|
1397
|
-
const day = 1 + 29 * mElapsed + Math.floor(hElapsed / 24);
|
|
1398
|
-
const altDay = day + (parts >= 19440 || 2 == day % 7 && parts >= 9924 && !HDate.isLeapYear(year) || 1 == day % 7 && parts >= 16789 && HDate.isLeapYear(prevYear));
|
|
1399
|
-
return altDay + (altDay % 7 === 0 || altDay % 7 == 3 || altDay % 7 == 5);
|
|
1400
|
-
}
|
|
1401
1573
|
/**
|
|
1402
1574
|
* Number of days in the hebrew YEAR
|
|
1403
1575
|
* @param {number} year Hebrew year
|
|
@@ -1406,7 +1578,7 @@ class HDate {
|
|
|
1406
1578
|
|
|
1407
1579
|
|
|
1408
1580
|
static daysInYear(year) {
|
|
1409
|
-
return
|
|
1581
|
+
return daysInYear(year);
|
|
1410
1582
|
}
|
|
1411
1583
|
/**
|
|
1412
1584
|
* true if Cheshvan is long in Hebrew year
|
|
@@ -1416,7 +1588,7 @@ class HDate {
|
|
|
1416
1588
|
|
|
1417
1589
|
|
|
1418
1590
|
static longCheshvan(year) {
|
|
1419
|
-
return
|
|
1591
|
+
return longCheshvan(year);
|
|
1420
1592
|
}
|
|
1421
1593
|
/**
|
|
1422
1594
|
* true if Kislev is short in Hebrew year
|
|
@@ -1426,7 +1598,7 @@ class HDate {
|
|
|
1426
1598
|
|
|
1427
1599
|
|
|
1428
1600
|
static shortKislev(year) {
|
|
1429
|
-
return
|
|
1601
|
+
return shortKislev(year);
|
|
1430
1602
|
}
|
|
1431
1603
|
/**
|
|
1432
1604
|
* Converts Hebrew month string name to numeric
|
|
@@ -1468,41 +1640,41 @@ class HDate {
|
|
|
1468
1640
|
/* this catches "november" */
|
|
1469
1641
|
}
|
|
1470
1642
|
|
|
1471
|
-
return NISAN
|
|
1643
|
+
return months.NISAN;
|
|
1472
1644
|
|
|
1473
1645
|
case 'i':
|
|
1474
|
-
return IYYAR;
|
|
1646
|
+
return months.IYYAR;
|
|
1475
1647
|
|
|
1476
1648
|
case 'e':
|
|
1477
|
-
return ELUL;
|
|
1649
|
+
return months.ELUL;
|
|
1478
1650
|
|
|
1479
1651
|
case 'c':
|
|
1480
1652
|
case 'ח':
|
|
1481
|
-
return CHESHVAN
|
|
1653
|
+
return months.CHESHVAN;
|
|
1482
1654
|
|
|
1483
1655
|
case 'k':
|
|
1484
1656
|
case 'כ':
|
|
1485
|
-
return KISLEV
|
|
1657
|
+
return months.KISLEV;
|
|
1486
1658
|
|
|
1487
1659
|
case 's':
|
|
1488
1660
|
switch (c[1]) {
|
|
1489
1661
|
case 'i':
|
|
1490
|
-
return SIVAN;
|
|
1662
|
+
return months.SIVAN;
|
|
1491
1663
|
|
|
1492
1664
|
case 'h':
|
|
1493
|
-
return SHVAT
|
|
1665
|
+
return months.SHVAT;
|
|
1494
1666
|
}
|
|
1495
1667
|
|
|
1496
1668
|
case 't':
|
|
1497
1669
|
switch (c[1]) {
|
|
1498
1670
|
case 'a':
|
|
1499
|
-
return TAMUZ;
|
|
1671
|
+
return months.TAMUZ;
|
|
1500
1672
|
|
|
1501
1673
|
case 'i':
|
|
1502
|
-
return TISHREI;
|
|
1674
|
+
return months.TISHREI;
|
|
1503
1675
|
|
|
1504
1676
|
case 'e':
|
|
1505
|
-
return TEVET
|
|
1677
|
+
return months.TEVET;
|
|
1506
1678
|
}
|
|
1507
1679
|
|
|
1508
1680
|
break;
|
|
@@ -1510,46 +1682,46 @@ class HDate {
|
|
|
1510
1682
|
case 'a':
|
|
1511
1683
|
switch (c[1]) {
|
|
1512
1684
|
case 'v':
|
|
1513
|
-
return AV;
|
|
1685
|
+
return months.AV;
|
|
1514
1686
|
|
|
1515
1687
|
case 'd':
|
|
1516
1688
|
if (/(1|[^i]i|a|א)$/i.test(monthName)) {
|
|
1517
|
-
return ADAR_I
|
|
1689
|
+
return months.ADAR_I;
|
|
1518
1690
|
}
|
|
1519
1691
|
|
|
1520
|
-
return ADAR_II
|
|
1692
|
+
return months.ADAR_II;
|
|
1521
1693
|
// else assume sheini
|
|
1522
1694
|
}
|
|
1523
1695
|
|
|
1524
1696
|
break;
|
|
1525
1697
|
|
|
1526
1698
|
case 'ס':
|
|
1527
|
-
return SIVAN;
|
|
1699
|
+
return months.SIVAN;
|
|
1528
1700
|
|
|
1529
1701
|
case 'ט':
|
|
1530
|
-
return TEVET
|
|
1702
|
+
return months.TEVET;
|
|
1531
1703
|
|
|
1532
1704
|
case 'ש':
|
|
1533
|
-
return SHVAT
|
|
1705
|
+
return months.SHVAT;
|
|
1534
1706
|
|
|
1535
1707
|
case 'א':
|
|
1536
1708
|
switch (c[1]) {
|
|
1537
1709
|
case 'ב':
|
|
1538
|
-
return AV;
|
|
1710
|
+
return months.AV;
|
|
1539
1711
|
|
|
1540
1712
|
case 'ד':
|
|
1541
1713
|
if (/(1|[^i]i|a|א)$/i.test(monthName)) {
|
|
1542
|
-
return ADAR_I
|
|
1714
|
+
return months.ADAR_I;
|
|
1543
1715
|
}
|
|
1544
1716
|
|
|
1545
|
-
return ADAR_II
|
|
1717
|
+
return months.ADAR_II;
|
|
1546
1718
|
// else assume sheini
|
|
1547
1719
|
|
|
1548
1720
|
case 'י':
|
|
1549
|
-
return IYYAR;
|
|
1721
|
+
return months.IYYAR;
|
|
1550
1722
|
|
|
1551
1723
|
case 'ל':
|
|
1552
|
-
return ELUL;
|
|
1724
|
+
return months.ELUL;
|
|
1553
1725
|
}
|
|
1554
1726
|
|
|
1555
1727
|
break;
|
|
@@ -1557,10 +1729,10 @@ class HDate {
|
|
|
1557
1729
|
case 'ת':
|
|
1558
1730
|
switch (c[1]) {
|
|
1559
1731
|
case 'מ':
|
|
1560
|
-
return TAMUZ;
|
|
1732
|
+
return months.TAMUZ;
|
|
1561
1733
|
|
|
1562
1734
|
case 'ש':
|
|
1563
|
-
return TISHREI;
|
|
1735
|
+
return months.TISHREI;
|
|
1564
1736
|
}
|
|
1565
1737
|
|
|
1566
1738
|
break;
|
|
@@ -1611,21 +1783,21 @@ function fix(date) {
|
|
|
1611
1783
|
|
|
1612
1784
|
function fixDate(date) {
|
|
1613
1785
|
if (date.day < 1) {
|
|
1614
|
-
if (date.month == TISHREI) {
|
|
1786
|
+
if (date.month == months.TISHREI) {
|
|
1615
1787
|
date.year -= 1;
|
|
1616
1788
|
}
|
|
1617
1789
|
|
|
1618
|
-
date.day +=
|
|
1790
|
+
date.day += daysInMonth(date.month, date.year);
|
|
1619
1791
|
date.month -= 1;
|
|
1620
1792
|
fix(date);
|
|
1621
1793
|
}
|
|
1622
1794
|
|
|
1623
|
-
if (date.day >
|
|
1624
|
-
if (date.month
|
|
1795
|
+
if (date.day > daysInMonth(date.month, date.year)) {
|
|
1796
|
+
if (date.month === months.ELUL) {
|
|
1625
1797
|
date.year += 1;
|
|
1626
1798
|
}
|
|
1627
1799
|
|
|
1628
|
-
date.day -=
|
|
1800
|
+
date.day -= daysInMonth(date.month, date.year);
|
|
1629
1801
|
date.month += 1;
|
|
1630
1802
|
fix(date);
|
|
1631
1803
|
}
|
|
@@ -1639,16 +1811,16 @@ function fixDate(date) {
|
|
|
1639
1811
|
|
|
1640
1812
|
|
|
1641
1813
|
function fixMonth(date) {
|
|
1642
|
-
if (date.month
|
|
1814
|
+
if (date.month === months.ADAR_II && !date.isLeapYear()) {
|
|
1643
1815
|
date.month -= 1; // to Adar I
|
|
1644
1816
|
|
|
1645
1817
|
fix(date);
|
|
1646
1818
|
} else if (date.month < 1) {
|
|
1647
|
-
date.month +=
|
|
1819
|
+
date.month += monthsInYear(date.year);
|
|
1648
1820
|
date.year -= 1;
|
|
1649
1821
|
fix(date);
|
|
1650
|
-
} else if (date.month >
|
|
1651
|
-
date.month -=
|
|
1822
|
+
} else if (date.month > monthsInYear(date.year)) {
|
|
1823
|
+
date.month -= monthsInYear(date.year);
|
|
1652
1824
|
date.year += 1;
|
|
1653
1825
|
fix(date);
|
|
1654
1826
|
}
|
|
@@ -1695,18 +1867,18 @@ function getYahrzeit_(hyear, gdate) {
|
|
|
1695
1867
|
return undefined;
|
|
1696
1868
|
}
|
|
1697
1869
|
|
|
1698
|
-
if (hDeath.mm == CHESHVAN && hDeath.dd == 30 && !
|
|
1870
|
+
if (hDeath.mm == CHESHVAN && hDeath.dd == 30 && !longCheshvan(hDeath.yy + 1)) {
|
|
1699
1871
|
// If it's Heshvan 30 it depends on the first anniversary;
|
|
1700
1872
|
// if that was not Heshvan 30, use the day before Kislev 1.
|
|
1701
|
-
hDeath =
|
|
1702
|
-
} else if (hDeath.mm == KISLEV && hDeath.dd == 30 &&
|
|
1873
|
+
hDeath = abs2hebrew(hebrew2abs(hyear, KISLEV, 1) - 1);
|
|
1874
|
+
} else if (hDeath.mm == KISLEV && hDeath.dd == 30 && shortKislev(hDeath.yy + 1)) {
|
|
1703
1875
|
// If it's Kislev 30 it depends on the first anniversary;
|
|
1704
1876
|
// if that was not Kislev 30, use the day before Teveth 1.
|
|
1705
|
-
hDeath =
|
|
1877
|
+
hDeath = abs2hebrew(hebrew2abs(hyear, TEVET, 1) - 1);
|
|
1706
1878
|
} else if (hDeath.mm == ADAR_II) {
|
|
1707
1879
|
// If it's Adar II, use the same day in last month of year (Adar or Adar II).
|
|
1708
|
-
hDeath.mm =
|
|
1709
|
-
} else if (hDeath.mm == ADAR_I && hDeath.dd == 30 && !
|
|
1880
|
+
hDeath.mm = monthsInYear(hyear);
|
|
1881
|
+
} else if (hDeath.mm == ADAR_I && hDeath.dd == 30 && !isLeapYear(hyear)) {
|
|
1710
1882
|
// If it's the 30th in Adar I and year is not a leap year
|
|
1711
1883
|
// (so Adar has only 29 days), use the last day in Shevat.
|
|
1712
1884
|
hDeath.dd = 30;
|
|
@@ -1715,10 +1887,10 @@ function getYahrzeit_(hyear, gdate) {
|
|
|
1715
1887
|
// advance day to rosh chodesh if needed
|
|
1716
1888
|
|
|
1717
1889
|
|
|
1718
|
-
if (hDeath.mm == CHESHVAN && hDeath.dd == 30 && !
|
|
1890
|
+
if (hDeath.mm == CHESHVAN && hDeath.dd == 30 && !longCheshvan(hyear)) {
|
|
1719
1891
|
hDeath.mm = KISLEV;
|
|
1720
1892
|
hDeath.dd = 1;
|
|
1721
|
-
} else if (hDeath.mm == KISLEV && hDeath.dd == 30 &&
|
|
1893
|
+
} else if (hDeath.mm == KISLEV && hDeath.dd == 30 && shortKislev(hyear)) {
|
|
1722
1894
|
hDeath.mm = TEVET;
|
|
1723
1895
|
hDeath.dd = 1;
|
|
1724
1896
|
}
|
|
@@ -1741,19 +1913,19 @@ function getBirthdayOrAnniversary_(hyear, gdate) {
|
|
|
1741
1913
|
return undefined;
|
|
1742
1914
|
}
|
|
1743
1915
|
|
|
1744
|
-
const isOrigLeap =
|
|
1916
|
+
const isOrigLeap = isLeapYear(origYear);
|
|
1745
1917
|
let month = orig.getMonth();
|
|
1746
1918
|
let day = orig.getDate();
|
|
1747
1919
|
|
|
1748
1920
|
if (month == ADAR_I && !isOrigLeap || month == ADAR_II && isOrigLeap) {
|
|
1749
|
-
month =
|
|
1750
|
-
} else if (month == CHESHVAN && day == 30 && !
|
|
1921
|
+
month = monthsInYear(hyear);
|
|
1922
|
+
} else if (month == CHESHVAN && day == 30 && !longCheshvan(hyear)) {
|
|
1751
1923
|
month = KISLEV;
|
|
1752
1924
|
day = 1;
|
|
1753
|
-
} else if (month == KISLEV && day == 30 &&
|
|
1925
|
+
} else if (month == KISLEV && day == 30 && shortKislev(hyear)) {
|
|
1754
1926
|
month = TEVET;
|
|
1755
1927
|
day = 1;
|
|
1756
|
-
} else if (month == ADAR_I && day == 30 && isOrigLeap && !
|
|
1928
|
+
} else if (month == ADAR_I && day == 30 && isOrigLeap && !isLeapYear(hyear)) {
|
|
1757
1929
|
month = NISAN;
|
|
1758
1930
|
day = 1;
|
|
1759
1931
|
}
|
|
@@ -1761,7 +1933,7 @@ function getBirthdayOrAnniversary_(hyear, gdate) {
|
|
|
1761
1933
|
return new HDate(day, month, hyear);
|
|
1762
1934
|
}
|
|
1763
1935
|
|
|
1764
|
-
const version="3.
|
|
1936
|
+
const version="3.38.0";
|
|
1765
1937
|
|
|
1766
1938
|
const headers={"plural-forms":"nplurals=2; plural=(n > 1);",language:"he"};const contexts={"":{Adar:["אַדָר"],"Adar I":["אַדָר א׳"],"Adar II":["אַדָר ב׳"],Av:["אָב"],Cheshvan:["חֶשְׁוָן"],Elul:["אֱלוּל"],Iyyar:["אִיָיר"],Kislev:["כִּסְלֵו"],Nisan:["נִיסָן"],"Sh'vat":["שְׁבָט"],Sivan:["סִיוָן"],Tamuz:["תַּמּוּז"],Tevet:["טֵבֵת"],Tishrei:["תִשְׁרֵי"]}};var poHeMin = {headers:headers,contexts:contexts};
|
|
1767
1939
|
|