@hebcal/core 3.37.1 → 3.38.1
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 +39 -37
- package/dist/bundle.js +1367 -1149
- package/dist/bundle.min.js +2 -2
- package/dist/hdate-bundle.js +473 -312
- package/dist/hdate-bundle.min.js +2 -2
- package/dist/hdate.js +494 -307
- package/dist/hdate.mjs +494 -307
- package/dist/hdate0-bundle.js +469 -0
- package/dist/hdate0-bundle.min.js +2 -0
- package/dist/index.js +510 -369
- package/dist/index.mjs +530 -369
- package/package.json +9 -9
package/dist/index.mjs
CHANGED
|
@@ -1,25 +1,14 @@
|
|
|
1
|
-
/*! @hebcal/core v3.
|
|
1
|
+
/*! @hebcal/core v3.38.0 */
|
|
2
2
|
/*
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
Portions copyright Eyal Schachter and Michael J. Radwin
|
|
6
|
-
|
|
7
|
-
https://github.com/hebcal/hebcal-es6
|
|
8
|
-
|
|
9
|
-
This program is free software; you can redistribute it and/or
|
|
10
|
-
modify it under the terms of the GNU General Public License
|
|
11
|
-
as published by the Free Software Foundation; either version 2
|
|
12
|
-
of the License, or (at your option) any later version.
|
|
3
|
+
* More minimal greg routines
|
|
4
|
+
*/
|
|
13
5
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
GNU General Public License for more details.
|
|
6
|
+
/** @private */
|
|
7
|
+
const lengths = [0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
|
|
8
|
+
/** @private */
|
|
18
9
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
*/
|
|
22
|
-
const monthLengths = [[0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31], [0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]];
|
|
10
|
+
const monthLengths = [lengths, lengths.slice()];
|
|
11
|
+
monthLengths[1][2] = 29;
|
|
23
12
|
/**
|
|
24
13
|
* @private
|
|
25
14
|
* @param {number} x
|
|
@@ -41,10 +30,169 @@ function quotient(x, y) {
|
|
|
41
30
|
return Math.floor(x / y);
|
|
42
31
|
}
|
|
43
32
|
/**
|
|
44
|
-
* Gregorian
|
|
33
|
+
* Returns true if the Gregorian year is a leap year
|
|
34
|
+
* @private
|
|
35
|
+
* @param {number} year Gregorian year
|
|
36
|
+
* @return {boolean}
|
|
37
|
+
*/
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
function isLeapYear$1(year) {
|
|
41
|
+
return !(year % 4) && (!!(year % 100) || !(year % 400));
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Number of days in the Gregorian month for given year
|
|
45
|
+
* @private
|
|
46
|
+
* @param {number} month Gregorian month (1=January, 12=December)
|
|
47
|
+
* @param {number} year Gregorian year
|
|
48
|
+
* @return {number}
|
|
49
|
+
*/
|
|
50
|
+
|
|
51
|
+
function daysInMonth$1(month, year) {
|
|
52
|
+
// 1 based months
|
|
53
|
+
return monthLengths[+isLeapYear$1(year)][month];
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Returns true if the object is a Javascript Date
|
|
57
|
+
* @private
|
|
58
|
+
* @param {Object} obj
|
|
59
|
+
* @return {boolean}
|
|
60
|
+
*/
|
|
61
|
+
|
|
62
|
+
function isDate(obj) {
|
|
63
|
+
return typeof obj === 'object' && Date.prototype === obj.__proto__;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Returns number of days since January 1 of that year
|
|
67
|
+
* @private
|
|
68
|
+
* @param {Date} date Gregorian date
|
|
69
|
+
* @return {number}
|
|
70
|
+
*/
|
|
71
|
+
|
|
72
|
+
function dayOfYear(date) {
|
|
73
|
+
if (!isDate(date)) {
|
|
74
|
+
throw new TypeError(`Argument not a Date: ${date}`);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
let doy = date.getDate() + 31 * date.getMonth();
|
|
78
|
+
|
|
79
|
+
if (date.getMonth() > 1) {
|
|
80
|
+
// FEB
|
|
81
|
+
doy -= Math.floor((4 * (date.getMonth() + 1) + 23) / 10);
|
|
82
|
+
|
|
83
|
+
if (isLeapYear$1(date.getFullYear())) {
|
|
84
|
+
doy++;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
return doy;
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Converts Gregorian date to absolute R.D. (Rata Die) days
|
|
92
|
+
* @private
|
|
93
|
+
* @param {Date} date Gregorian date
|
|
94
|
+
* @return {number}
|
|
95
|
+
*/
|
|
96
|
+
|
|
97
|
+
function greg2abs(date) {
|
|
98
|
+
if (!isDate(date)) {
|
|
99
|
+
throw new TypeError(`Argument not a Date: ${date}`);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
const year = date.getFullYear() - 1;
|
|
103
|
+
return dayOfYear(date) + // days this year
|
|
104
|
+
365 * year + ( // + days in prior years
|
|
105
|
+
Math.floor(year / 4) - // + Julian Leap years
|
|
106
|
+
Math.floor(year / 100) + // - century years
|
|
107
|
+
Math.floor(year / 400)); // + Gregorian leap years
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* @private
|
|
111
|
+
* @param {number} abs - R.D. number of days
|
|
112
|
+
* @return {number}
|
|
113
|
+
*/
|
|
114
|
+
|
|
115
|
+
function yearFromFixed(abs) {
|
|
116
|
+
const l0 = abs - 1;
|
|
117
|
+
const n400 = quotient(l0, 146097);
|
|
118
|
+
const d1 = mod(l0, 146097);
|
|
119
|
+
const n100 = quotient(d1, 36524);
|
|
120
|
+
const d2 = mod(d1, 36524);
|
|
121
|
+
const n4 = quotient(d2, 1461);
|
|
122
|
+
const d3 = mod(d2, 1461);
|
|
123
|
+
const n1 = quotient(d3, 365);
|
|
124
|
+
const year = 400 * n400 + 100 * n100 + 4 * n4 + n1;
|
|
125
|
+
return n100 != 4 && n1 != 4 ? year + 1 : year;
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* @private
|
|
129
|
+
* @param {number} year
|
|
130
|
+
* @param {number} month
|
|
131
|
+
* @param {number} day
|
|
132
|
+
* @return {number}
|
|
133
|
+
*/
|
|
134
|
+
|
|
135
|
+
|
|
136
|
+
function toFixed(year, month, day) {
|
|
137
|
+
const py = year - 1;
|
|
138
|
+
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;
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* Converts from Rata Die (R.D. number) to Gregorian date.
|
|
142
|
+
* See the footnote on page 384 of ``Calendrical Calculations, Part II:
|
|
143
|
+
* Three Historical Calendars'' by E. M. Reingold, N. Dershowitz, and S. M.
|
|
144
|
+
* Clamen, Software--Practice and Experience, Volume 23, Number 4
|
|
145
|
+
* (April, 1993), pages 383-404 for an explanation.
|
|
146
|
+
* @private
|
|
147
|
+
* @param {number} abs - R.D. number of days
|
|
148
|
+
* @return {Date}
|
|
45
149
|
*/
|
|
46
150
|
|
|
47
151
|
|
|
152
|
+
function abs2greg(abs) {
|
|
153
|
+
if (typeof abs !== 'number') {
|
|
154
|
+
throw new TypeError(`Argument not a Number: ${abs}`);
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
abs = Math.trunc(abs);
|
|
158
|
+
const year = yearFromFixed(abs);
|
|
159
|
+
const priorDays = abs - toFixed(year, 1, 1);
|
|
160
|
+
const correction = abs < toFixed(year, 3, 1) ? 0 : isLeapYear$1(year) ? 1 : 2;
|
|
161
|
+
const month = quotient(12 * (priorDays + correction) + 373, 367);
|
|
162
|
+
const day = abs - toFixed(year, month, 1) + 1;
|
|
163
|
+
const dt = new Date(year, month - 1, day);
|
|
164
|
+
|
|
165
|
+
if (year < 100 && year >= 0) {
|
|
166
|
+
dt.setFullYear(year);
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
return dt;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
/*
|
|
173
|
+
Hebcal - A Jewish Calendar Generator
|
|
174
|
+
Copyright (c) 1994-2020 Danny Sadinoff
|
|
175
|
+
Portions copyright Eyal Schachter and Michael J. Radwin
|
|
176
|
+
|
|
177
|
+
https://github.com/hebcal/hebcal-es6
|
|
178
|
+
|
|
179
|
+
This program is free software; you can redistribute it and/or
|
|
180
|
+
modify it under the terms of the GNU General Public License
|
|
181
|
+
as published by the Free Software Foundation; either version 2
|
|
182
|
+
of the License, or (at your option) any later version.
|
|
183
|
+
|
|
184
|
+
This program is distributed in the hope that it will be useful,
|
|
185
|
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
186
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
187
|
+
GNU General Public License for more details.
|
|
188
|
+
|
|
189
|
+
You should have received a copy of the GNU General Public License
|
|
190
|
+
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
191
|
+
*/
|
|
192
|
+
/**
|
|
193
|
+
* Gregorian date helper functions.
|
|
194
|
+
*/
|
|
195
|
+
|
|
48
196
|
class greg {
|
|
49
197
|
/**
|
|
50
198
|
* Long names of the Gregorian months (1='January', 12='December')
|
|
@@ -59,7 +207,7 @@ class greg {
|
|
|
59
207
|
*/
|
|
60
208
|
|
|
61
209
|
static isLeapYear(year) {
|
|
62
|
-
return
|
|
210
|
+
return isLeapYear$1(year);
|
|
63
211
|
}
|
|
64
212
|
/**
|
|
65
213
|
* Number of days in the Gregorian month for given year
|
|
@@ -70,8 +218,7 @@ class greg {
|
|
|
70
218
|
|
|
71
219
|
|
|
72
220
|
static daysInMonth(month, year) {
|
|
73
|
-
|
|
74
|
-
return monthLengths[+this.isLeapYear(year)][month];
|
|
221
|
+
return daysInMonth$1(month, year);
|
|
75
222
|
}
|
|
76
223
|
/**
|
|
77
224
|
* Returns true if the object is a Javascript Date
|
|
@@ -81,7 +228,7 @@ class greg {
|
|
|
81
228
|
|
|
82
229
|
|
|
83
230
|
static isDate(obj) {
|
|
84
|
-
return
|
|
231
|
+
return isDate(obj);
|
|
85
232
|
}
|
|
86
233
|
/**
|
|
87
234
|
* Returns number of days since January 1 of that year
|
|
@@ -91,22 +238,7 @@ class greg {
|
|
|
91
238
|
|
|
92
239
|
|
|
93
240
|
static dayOfYear(date) {
|
|
94
|
-
|
|
95
|
-
throw new TypeError('Argument to greg.dayOfYear not a Date');
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
let doy = date.getDate() + 31 * date.getMonth();
|
|
99
|
-
|
|
100
|
-
if (date.getMonth() > 1) {
|
|
101
|
-
// FEB
|
|
102
|
-
doy -= Math.floor((4 * (date.getMonth() + 1) + 23) / 10);
|
|
103
|
-
|
|
104
|
-
if (this.isLeapYear(date.getFullYear())) {
|
|
105
|
-
doy++;
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
return doy;
|
|
241
|
+
return dayOfYear(date);
|
|
110
242
|
}
|
|
111
243
|
/**
|
|
112
244
|
* Converts Gregorian date to absolute R.D. (Rata Die) days
|
|
@@ -116,48 +248,7 @@ class greg {
|
|
|
116
248
|
|
|
117
249
|
|
|
118
250
|
static greg2abs(date) {
|
|
119
|
-
|
|
120
|
-
throw new TypeError('Argument to greg.greg2abs not a Date');
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
const year = date.getFullYear() - 1;
|
|
124
|
-
return this.dayOfYear(date) + // days this year
|
|
125
|
-
365 * year + ( // + days in prior years
|
|
126
|
-
Math.floor(year / 4) - // + Julian Leap years
|
|
127
|
-
Math.floor(year / 100) + // - century years
|
|
128
|
-
Math.floor(year / 400)); // + Gregorian leap years
|
|
129
|
-
}
|
|
130
|
-
/**
|
|
131
|
-
* @private
|
|
132
|
-
* @param {number} theDate - R.D. number of days
|
|
133
|
-
* @return {number}
|
|
134
|
-
*/
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
static yearFromFixed(theDate) {
|
|
138
|
-
const l0 = theDate - 1;
|
|
139
|
-
const n400 = quotient(l0, 146097);
|
|
140
|
-
const d1 = mod(l0, 146097);
|
|
141
|
-
const n100 = quotient(d1, 36524);
|
|
142
|
-
const d2 = mod(d1, 36524);
|
|
143
|
-
const n4 = quotient(d2, 1461);
|
|
144
|
-
const d3 = mod(d2, 1461);
|
|
145
|
-
const n1 = quotient(d3, 365);
|
|
146
|
-
const year = 400 * n400 + 100 * n100 + 4 * n4 + n1;
|
|
147
|
-
return n100 != 4 && n1 != 4 ? year + 1 : year;
|
|
148
|
-
}
|
|
149
|
-
/**
|
|
150
|
-
* @private
|
|
151
|
-
* @param {number} year
|
|
152
|
-
* @param {number} month
|
|
153
|
-
* @param {number} day
|
|
154
|
-
* @return {number}
|
|
155
|
-
*/
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
static toFixed(year, month, day) {
|
|
159
|
-
const py = year - 1;
|
|
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;
|
|
251
|
+
return greg2abs(date);
|
|
161
252
|
}
|
|
162
253
|
/**
|
|
163
254
|
* Converts from Rata Die (R.D. number) to Gregorian date.
|
|
@@ -171,23 +262,7 @@ class greg {
|
|
|
171
262
|
|
|
172
263
|
|
|
173
264
|
static abs2greg(theDate) {
|
|
174
|
-
|
|
175
|
-
throw new TypeError('Argument to greg.abs2greg not a Number');
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
theDate = Math.trunc(theDate);
|
|
179
|
-
const year = this.yearFromFixed(theDate);
|
|
180
|
-
const priorDays = theDate - this.toFixed(year, 1, 1);
|
|
181
|
-
const correction = theDate < this.toFixed(year, 3, 1) ? 0 : this.isLeapYear(year) ? 1 : 2;
|
|
182
|
-
const month = quotient(12 * (priorDays + correction) + 373, 367);
|
|
183
|
-
const day = theDate - this.toFixed(year, month, 1) + 1;
|
|
184
|
-
const dt = new Date(year, month - 1, day);
|
|
185
|
-
|
|
186
|
-
if (year < 100 && year >= 0) {
|
|
187
|
-
dt.setFullYear(year);
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
return dt;
|
|
265
|
+
return abs2greg(theDate);
|
|
191
266
|
}
|
|
192
267
|
|
|
193
268
|
}
|
|
@@ -545,36 +620,19 @@ Locale.addLocale('', noopLocale);
|
|
|
545
620
|
Locale.useLocale('en');
|
|
546
621
|
|
|
547
622
|
/*
|
|
548
|
-
|
|
549
|
-
Copyright (c) 1994-2020 Danny Sadinoff
|
|
550
|
-
Portions copyright Eyal Schachter and Michael J. Radwin
|
|
551
|
-
|
|
552
|
-
https://github.com/hebcal/hebcal-es6
|
|
553
|
-
|
|
554
|
-
This program is free software; you can redistribute it and/or
|
|
555
|
-
modify it under the terms of the GNU General Public License
|
|
556
|
-
as published by the Free Software Foundation; either version 2
|
|
557
|
-
of the License, or (at your option) any later version.
|
|
558
|
-
|
|
559
|
-
This program is distributed in the hope that it will be useful,
|
|
560
|
-
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
561
|
-
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
562
|
-
GNU General Public License for more details.
|
|
563
|
-
|
|
564
|
-
You should have received a copy of the GNU General Public License
|
|
565
|
-
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
623
|
+
* More minimal HDate
|
|
566
624
|
*/
|
|
567
625
|
const NISAN$3 = 1;
|
|
568
|
-
const IYYAR$1 = 2;
|
|
569
|
-
|
|
570
|
-
const TAMUZ$1 = 4;
|
|
571
|
-
|
|
626
|
+
const IYYAR$1 = 2; // const SIVAN = 3;
|
|
627
|
+
|
|
628
|
+
const TAMUZ$1 = 4; // const AV = 5;
|
|
629
|
+
|
|
572
630
|
const ELUL$2 = 6;
|
|
573
631
|
const TISHREI$2 = 7;
|
|
574
632
|
const CHESHVAN$2 = 8;
|
|
575
633
|
const KISLEV$2 = 9;
|
|
576
|
-
const TEVET$2 = 10;
|
|
577
|
-
|
|
634
|
+
const TEVET$2 = 10; // const SHVAT = 11;
|
|
635
|
+
|
|
578
636
|
const ADAR_I$2 = 12;
|
|
579
637
|
const ADAR_II$2 = 13;
|
|
580
638
|
/**
|
|
@@ -630,16 +688,237 @@ const monthNames0 = ['', 'Nisan', 'Iyyar', 'Sivan', 'Tamuz', 'Av', 'Elul', 'Tish
|
|
|
630
688
|
* @private
|
|
631
689
|
*/
|
|
632
690
|
|
|
633
|
-
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
|
+
* @private
|
|
701
|
+
* @param {number} year Hebrew year
|
|
702
|
+
* @param {number} month Hebrew month
|
|
703
|
+
* @param {number} day Hebrew date (1-30)
|
|
704
|
+
* @return {number}
|
|
705
|
+
*/
|
|
706
|
+
|
|
707
|
+
function hebrew2abs(year, month, day) {
|
|
708
|
+
let tempabs = day;
|
|
709
|
+
|
|
710
|
+
if (month < TISHREI$2) {
|
|
711
|
+
for (let m = TISHREI$2; m <= monthsInYear(year); m++) {
|
|
712
|
+
tempabs += daysInMonth(m, year);
|
|
713
|
+
}
|
|
714
|
+
|
|
715
|
+
for (let m = NISAN$3; m < month; m++) {
|
|
716
|
+
tempabs += daysInMonth(m, year);
|
|
717
|
+
}
|
|
718
|
+
} else {
|
|
719
|
+
for (let m = TISHREI$2; m < month; m++) {
|
|
720
|
+
tempabs += daysInMonth(m, year);
|
|
721
|
+
}
|
|
722
|
+
}
|
|
723
|
+
|
|
724
|
+
return EPOCH + elapsedDays(year) + tempabs - 1;
|
|
725
|
+
}
|
|
726
|
+
/**
|
|
727
|
+
* @private
|
|
728
|
+
* @param {number} year
|
|
729
|
+
* @return {number}
|
|
730
|
+
*/
|
|
731
|
+
|
|
732
|
+
function newYear(year) {
|
|
733
|
+
return EPOCH + elapsedDays(year);
|
|
734
|
+
}
|
|
735
|
+
/**
|
|
736
|
+
* Converts absolute R.D. days to Hebrew date
|
|
737
|
+
* @private
|
|
738
|
+
* @param {number} abs absolute R.D. days
|
|
739
|
+
* @return {SimpleHebrewDate}
|
|
740
|
+
*/
|
|
741
|
+
|
|
742
|
+
|
|
743
|
+
function abs2hebrew(abs) {
|
|
744
|
+
if (typeof abs !== 'number' || isNaN(abs)) {
|
|
745
|
+
throw new TypeError(`invalid parameter to abs2hebrew ${abs}`);
|
|
746
|
+
}
|
|
747
|
+
|
|
748
|
+
abs = Math.trunc(abs); // first, quickly approximate year
|
|
749
|
+
|
|
750
|
+
let year = Math.floor((abs - EPOCH) / AVG_HEBYEAR_DAYS);
|
|
751
|
+
|
|
752
|
+
while (newYear(year) <= abs) {
|
|
753
|
+
++year;
|
|
754
|
+
}
|
|
755
|
+
|
|
756
|
+
--year;
|
|
757
|
+
let month = abs < hebrew2abs(year, 1, 1) ? 7 : 1;
|
|
758
|
+
|
|
759
|
+
while (abs > hebrew2abs(year, month, daysInMonth(month, year))) {
|
|
760
|
+
++month;
|
|
761
|
+
}
|
|
762
|
+
|
|
763
|
+
const day = 1 + abs - hebrew2abs(year, month, 1);
|
|
764
|
+
return {
|
|
765
|
+
yy: year,
|
|
766
|
+
mm: month,
|
|
767
|
+
dd: day
|
|
768
|
+
};
|
|
769
|
+
}
|
|
770
|
+
/**
|
|
771
|
+
* Returns true if Hebrew year is a leap year
|
|
772
|
+
* @private
|
|
773
|
+
* @param {number} year Hebrew year
|
|
774
|
+
* @return {boolean}
|
|
775
|
+
*/
|
|
776
|
+
|
|
777
|
+
function isLeapYear(year) {
|
|
778
|
+
return (1 + year * 7) % 19 < 7;
|
|
779
|
+
}
|
|
780
|
+
/**
|
|
781
|
+
* Number of months in this Hebrew year (either 12 or 13 depending on leap year)
|
|
782
|
+
* @private
|
|
783
|
+
* @param {number} year Hebrew year
|
|
784
|
+
* @return {number}
|
|
785
|
+
*/
|
|
786
|
+
|
|
787
|
+
function monthsInYear(year) {
|
|
788
|
+
return 12 + isLeapYear(year); // boolean is cast to 1 or 0
|
|
789
|
+
}
|
|
790
|
+
/**
|
|
791
|
+
* Number of days in Hebrew month in a given year (29 or 30)
|
|
792
|
+
* @private
|
|
793
|
+
* @param {number} month Hebrew month (e.g. months.TISHREI)
|
|
794
|
+
* @param {number} year Hebrew year
|
|
795
|
+
* @return {number}
|
|
796
|
+
*/
|
|
797
|
+
|
|
798
|
+
function daysInMonth(month, year) {
|
|
799
|
+
switch (month) {
|
|
800
|
+
case IYYAR$1:
|
|
801
|
+
case TAMUZ$1:
|
|
802
|
+
case ELUL$2:
|
|
803
|
+
case TEVET$2:
|
|
804
|
+
case ADAR_II$2:
|
|
805
|
+
return 29;
|
|
806
|
+
}
|
|
807
|
+
|
|
808
|
+
if (month === ADAR_I$2 && !isLeapYear(year) || month === CHESHVAN$2 && !longCheshvan(year) || month === KISLEV$2 && shortKislev(year)) {
|
|
809
|
+
return 29;
|
|
810
|
+
} else {
|
|
811
|
+
return 30;
|
|
812
|
+
}
|
|
813
|
+
}
|
|
814
|
+
/**
|
|
815
|
+
* Returns a transliterated string name of Hebrew month in year,
|
|
816
|
+
* for example 'Elul' or 'Cheshvan'.
|
|
817
|
+
* @private
|
|
818
|
+
* @param {number} month Hebrew month (e.g. months.TISHREI)
|
|
819
|
+
* @param {number} year Hebrew year
|
|
820
|
+
* @return {string}
|
|
821
|
+
*/
|
|
822
|
+
|
|
823
|
+
function getMonthName(month, year) {
|
|
824
|
+
if (typeof month !== 'number' || isNaN(month) || month < 1 || month > 14) {
|
|
825
|
+
throw new TypeError(`bad month argument ${month}`);
|
|
826
|
+
}
|
|
827
|
+
|
|
828
|
+
return monthNames[+isLeapYear(year)][month];
|
|
829
|
+
}
|
|
830
|
+
/**
|
|
831
|
+
* Days from sunday prior to start of Hebrew calendar to mean
|
|
832
|
+
* conjunction of Tishrei in Hebrew YEAR
|
|
833
|
+
* @private
|
|
834
|
+
* @param {number} year Hebrew year
|
|
835
|
+
* @return {number}
|
|
836
|
+
*/
|
|
837
|
+
|
|
838
|
+
function elapsedDays(year) {
|
|
839
|
+
const elapsed = edCache[year] = edCache[year] || elapsedDays0(year);
|
|
840
|
+
return elapsed;
|
|
841
|
+
}
|
|
842
|
+
/**
|
|
843
|
+
* Days from sunday prior to start of Hebrew calendar to mean
|
|
844
|
+
* conjunction of Tishrei in Hebrew YEAR
|
|
845
|
+
* @private
|
|
846
|
+
* @param {number} year Hebrew year
|
|
847
|
+
* @return {number}
|
|
848
|
+
*/
|
|
849
|
+
|
|
850
|
+
function elapsedDays0(year) {
|
|
851
|
+
const prevYear = year - 1;
|
|
852
|
+
const mElapsed = 235 * Math.floor(prevYear / 19) + // Months in complete 19 year lunar (Metonic) cycles so far
|
|
853
|
+
12 * (prevYear % 19) + // Regular months in this cycle
|
|
854
|
+
Math.floor((prevYear % 19 * 7 + 1) / 19); // Leap months this cycle
|
|
855
|
+
|
|
856
|
+
const pElapsed = 204 + 793 * (mElapsed % 1080);
|
|
857
|
+
const hElapsed = 5 + 12 * mElapsed + 793 * Math.floor(mElapsed / 1080) + Math.floor(pElapsed / 1080);
|
|
858
|
+
const parts = pElapsed % 1080 + 1080 * (hElapsed % 24);
|
|
859
|
+
const day = 1 + 29 * mElapsed + Math.floor(hElapsed / 24);
|
|
860
|
+
const altDay = day + (parts >= 19440 || 2 === day % 7 && parts >= 9924 && !isLeapYear(year) || 1 === day % 7 && parts >= 16789 && isLeapYear(prevYear));
|
|
861
|
+
return altDay + (altDay % 7 === 0 || altDay % 7 === 3 || altDay % 7 === 5);
|
|
862
|
+
}
|
|
863
|
+
/**
|
|
864
|
+
* Number of days in the hebrew YEAR.
|
|
865
|
+
* A common Hebrew calendar year can have a length of 353, 354 or 355 days
|
|
866
|
+
* A leap Hebrew calendar year can have a length of 383, 384 or 385 days
|
|
867
|
+
* @private
|
|
868
|
+
* @param {number} year Hebrew year
|
|
869
|
+
* @return {number}
|
|
870
|
+
*/
|
|
871
|
+
|
|
872
|
+
|
|
873
|
+
function daysInYear(year) {
|
|
874
|
+
return elapsedDays(year + 1) - elapsedDays(year);
|
|
875
|
+
}
|
|
876
|
+
/**
|
|
877
|
+
* true if Cheshvan is long in Hebrew year
|
|
878
|
+
* @private
|
|
879
|
+
* @param {number} year Hebrew year
|
|
880
|
+
* @return {boolean}
|
|
881
|
+
*/
|
|
882
|
+
|
|
883
|
+
function longCheshvan(year) {
|
|
884
|
+
return daysInYear(year) % 10 === 5;
|
|
885
|
+
}
|
|
886
|
+
/**
|
|
887
|
+
* true if Kislev is short in Hebrew year
|
|
888
|
+
* @private
|
|
889
|
+
* @param {number} year Hebrew year
|
|
890
|
+
* @return {boolean}
|
|
891
|
+
*/
|
|
892
|
+
|
|
893
|
+
function shortKislev(year) {
|
|
894
|
+
return daysInYear(year) % 10 === 3;
|
|
895
|
+
}
|
|
896
|
+
|
|
897
|
+
/*
|
|
898
|
+
Hebcal - A Jewish Calendar Generator
|
|
899
|
+
Copyright (c) 1994-2020 Danny Sadinoff
|
|
900
|
+
Portions copyright Eyal Schachter and Michael J. Radwin
|
|
901
|
+
|
|
902
|
+
https://github.com/hebcal/hebcal-es6
|
|
903
|
+
|
|
904
|
+
This program is free software; you can redistribute it and/or
|
|
905
|
+
modify it under the terms of the GNU General Public License
|
|
906
|
+
as published by the Free Software Foundation; either version 2
|
|
907
|
+
of the License, or (at your option) any later version.
|
|
908
|
+
|
|
909
|
+
This program is distributed in the hope that it will be useful,
|
|
910
|
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
911
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
912
|
+
GNU General Public License for more details.
|
|
913
|
+
|
|
914
|
+
You should have received a copy of the GNU General Public License
|
|
915
|
+
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
916
|
+
*/
|
|
634
917
|
|
|
635
918
|
function throwTypeError$3(msg) {
|
|
636
919
|
throw new TypeError(msg);
|
|
637
920
|
}
|
|
638
921
|
|
|
639
|
-
const edCache = Object.create(null);
|
|
640
|
-
const EPOCH = -1373428; // Avg year length in the cycle (19 solar years with 235 lunar months)
|
|
641
|
-
|
|
642
|
-
const AVG_HEBYEAR_DAYS = 365.24682220597794;
|
|
643
922
|
const UNITS_DAY = 'day';
|
|
644
923
|
const UNITS_WEEK = 'week';
|
|
645
924
|
const UNITS_MONTH = 'month';
|
|
@@ -716,19 +995,22 @@ class HDate {
|
|
|
716
995
|
* @type {number}
|
|
717
996
|
*/
|
|
718
997
|
|
|
719
|
-
|
|
998
|
+
year = parseInt(year, 10);
|
|
720
999
|
|
|
721
|
-
if (isNaN(
|
|
1000
|
+
if (isNaN(year)) {
|
|
722
1001
|
throw new TypeError(`HDate called with bad year argument: ${year}`);
|
|
723
1002
|
}
|
|
724
1003
|
|
|
1004
|
+
this.year = year;
|
|
725
1005
|
this.setMonth(month); // will throw if we can't parse
|
|
726
1006
|
|
|
727
|
-
|
|
1007
|
+
day = parseInt(day, 10);
|
|
728
1008
|
|
|
729
|
-
if (isNaN(
|
|
1009
|
+
if (isNaN(day)) {
|
|
730
1010
|
throw new TypeError(`HDate called with bad day argument: ${day}`);
|
|
731
1011
|
}
|
|
1012
|
+
|
|
1013
|
+
this.setDate(day);
|
|
732
1014
|
} else {
|
|
733
1015
|
// 0 arguments
|
|
734
1016
|
if (typeof day === 'undefined') {
|
|
@@ -736,13 +1018,13 @@ class HDate {
|
|
|
736
1018
|
} // 1 argument
|
|
737
1019
|
|
|
738
1020
|
|
|
739
|
-
const abs0 = typeof day === 'number' && !isNaN(day) ? day :
|
|
1021
|
+
const abs0 = typeof day === 'number' && !isNaN(day) ? day : isDate(day) ? greg2abs(day) : HDate.isHDate(day) ? {
|
|
740
1022
|
dd: day.day,
|
|
741
1023
|
mm: day.month,
|
|
742
1024
|
yy: day.year
|
|
743
1025
|
} : throwTypeError$3(`HDate called with bad argument: ${day}`);
|
|
744
1026
|
const isNumber = typeof abs0 === 'number';
|
|
745
|
-
const d = isNumber ?
|
|
1027
|
+
const d = isNumber ? abs2hebrew(abs0) : abs0;
|
|
746
1028
|
/**
|
|
747
1029
|
* @private
|
|
748
1030
|
* @type {number}
|
|
@@ -787,7 +1069,7 @@ class HDate {
|
|
|
787
1069
|
|
|
788
1070
|
|
|
789
1071
|
isLeapYear() {
|
|
790
|
-
return
|
|
1072
|
+
return isLeapYear(this.year);
|
|
791
1073
|
}
|
|
792
1074
|
/**
|
|
793
1075
|
* Gets the Hebrew month (1=NISAN, 7=TISHREI) of this Hebrew date
|
|
@@ -805,7 +1087,7 @@ class HDate {
|
|
|
805
1087
|
|
|
806
1088
|
|
|
807
1089
|
getTishreiMonth() {
|
|
808
|
-
const nummonths =
|
|
1090
|
+
const nummonths = monthsInYear(this.getFullYear());
|
|
809
1091
|
return (this.getMonth() + nummonths - 6) % nummonths || nummonths;
|
|
810
1092
|
}
|
|
811
1093
|
/**
|
|
@@ -815,7 +1097,7 @@ class HDate {
|
|
|
815
1097
|
|
|
816
1098
|
|
|
817
1099
|
daysInMonth() {
|
|
818
|
-
return
|
|
1100
|
+
return daysInMonth(this.getMonth(), this.getFullYear());
|
|
819
1101
|
}
|
|
820
1102
|
/**
|
|
821
1103
|
* Gets the day within the month (1-30)
|
|
@@ -881,7 +1163,7 @@ class HDate {
|
|
|
881
1163
|
|
|
882
1164
|
|
|
883
1165
|
greg() {
|
|
884
|
-
return
|
|
1166
|
+
return abs2greg(this.abs());
|
|
885
1167
|
}
|
|
886
1168
|
/**
|
|
887
1169
|
* Returns R.D. (Rata Die) fixed days.
|
|
@@ -894,7 +1176,7 @@ class HDate {
|
|
|
894
1176
|
|
|
895
1177
|
abs() {
|
|
896
1178
|
if (typeof this.abs0 !== 'number') {
|
|
897
|
-
this.abs0 =
|
|
1179
|
+
this.abs0 = hebrew2abs(this.year, this.month, this.day);
|
|
898
1180
|
}
|
|
899
1181
|
|
|
900
1182
|
return this.abs0;
|
|
@@ -911,51 +1193,7 @@ class HDate {
|
|
|
911
1193
|
|
|
912
1194
|
|
|
913
1195
|
static hebrew2abs(year, month, day) {
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
if (month < TISHREI$2) {
|
|
917
|
-
for (let m = TISHREI$2; m <= HDate.monthsInYear(year); m++) {
|
|
918
|
-
tempabs += HDate.daysInMonth(m, year);
|
|
919
|
-
}
|
|
920
|
-
|
|
921
|
-
for (let m = NISAN$3; m < month; m++) {
|
|
922
|
-
tempabs += HDate.daysInMonth(m, year);
|
|
923
|
-
}
|
|
924
|
-
} else {
|
|
925
|
-
for (let m = TISHREI$2; m < month; m++) {
|
|
926
|
-
tempabs += HDate.daysInMonth(m, year);
|
|
927
|
-
}
|
|
928
|
-
}
|
|
929
|
-
|
|
930
|
-
return EPOCH + HDate.elapsedDays(year) + tempabs - 1;
|
|
931
|
-
}
|
|
932
|
-
/**
|
|
933
|
-
* @private
|
|
934
|
-
* @param {number} year
|
|
935
|
-
* @return {number}
|
|
936
|
-
*/
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
static newYear(year) {
|
|
940
|
-
return EPOCH + HDate.elapsedDays(year) + HDate.newYearDelay(year);
|
|
941
|
-
}
|
|
942
|
-
/**
|
|
943
|
-
* @private
|
|
944
|
-
* @param {number} year
|
|
945
|
-
* @return {number}
|
|
946
|
-
*/
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
static newYearDelay(year) {
|
|
950
|
-
const ny1 = HDate.elapsedDays(year);
|
|
951
|
-
const ny2 = HDate.elapsedDays(year + 1);
|
|
952
|
-
|
|
953
|
-
if (ny2 - ny1 === 356) {
|
|
954
|
-
return 2;
|
|
955
|
-
} else {
|
|
956
|
-
const ny0 = HDate.elapsedDays(year - 1);
|
|
957
|
-
return ny1 - ny0 === 382 ? 1 : 0;
|
|
958
|
-
}
|
|
1196
|
+
return hebrew2abs(year, month, day);
|
|
959
1197
|
}
|
|
960
1198
|
/**
|
|
961
1199
|
* Converts absolute R.D. days to Hebrew date
|
|
@@ -966,31 +1204,7 @@ class HDate {
|
|
|
966
1204
|
|
|
967
1205
|
|
|
968
1206
|
static abs2hebrew(abs) {
|
|
969
|
-
|
|
970
|
-
throw new TypeError(`invalid parameter to abs2hebrew ${abs}`);
|
|
971
|
-
}
|
|
972
|
-
|
|
973
|
-
abs = Math.trunc(abs); // first, quickly approximate year
|
|
974
|
-
|
|
975
|
-
let year = Math.floor((abs - EPOCH) / AVG_HEBYEAR_DAYS);
|
|
976
|
-
|
|
977
|
-
while (HDate.newYear(year) <= abs) {
|
|
978
|
-
++year;
|
|
979
|
-
}
|
|
980
|
-
|
|
981
|
-
--year;
|
|
982
|
-
let month = abs < HDate.hebrew2abs(year, 1, 1) ? 7 : 1;
|
|
983
|
-
|
|
984
|
-
while (abs > HDate.hebrew2abs(year, month, HDate.daysInMonth(month, year))) {
|
|
985
|
-
++month;
|
|
986
|
-
}
|
|
987
|
-
|
|
988
|
-
const day = 1 + abs - HDate.hebrew2abs(year, month, 1);
|
|
989
|
-
return {
|
|
990
|
-
yy: year,
|
|
991
|
-
mm: month,
|
|
992
|
-
dd: day
|
|
993
|
-
};
|
|
1207
|
+
return abs2hebrew(abs);
|
|
994
1208
|
}
|
|
995
1209
|
/**
|
|
996
1210
|
* Returns a transliterated Hebrew month name, e.g. `'Elul'` or `'Cheshvan'`.
|
|
@@ -999,7 +1213,7 @@ class HDate {
|
|
|
999
1213
|
|
|
1000
1214
|
|
|
1001
1215
|
getMonthName() {
|
|
1002
|
-
return
|
|
1216
|
+
return getMonthName(this.getMonth(), this.getFullYear());
|
|
1003
1217
|
}
|
|
1004
1218
|
/**
|
|
1005
1219
|
* Renders this Hebrew date as a translated or transliterated string,
|
|
@@ -1305,7 +1519,7 @@ class HDate {
|
|
|
1305
1519
|
|
|
1306
1520
|
|
|
1307
1521
|
static isLeapYear(year) {
|
|
1308
|
-
return (
|
|
1522
|
+
return isLeapYear(year);
|
|
1309
1523
|
}
|
|
1310
1524
|
/**
|
|
1311
1525
|
* Number of months in this Hebrew year (either 12 or 13 depending on leap year)
|
|
@@ -1315,7 +1529,7 @@ class HDate {
|
|
|
1315
1529
|
|
|
1316
1530
|
|
|
1317
1531
|
static monthsInYear(year) {
|
|
1318
|
-
return
|
|
1532
|
+
return monthsInYear(year);
|
|
1319
1533
|
}
|
|
1320
1534
|
/**
|
|
1321
1535
|
* Number of days in Hebrew month in a given year (29 or 30)
|
|
@@ -1326,11 +1540,7 @@ class HDate {
|
|
|
1326
1540
|
|
|
1327
1541
|
|
|
1328
1542
|
static daysInMonth(month, year) {
|
|
1329
|
-
|
|
1330
|
-
return 29;
|
|
1331
|
-
} else {
|
|
1332
|
-
return 30;
|
|
1333
|
-
}
|
|
1543
|
+
return daysInMonth(month, year);
|
|
1334
1544
|
}
|
|
1335
1545
|
/**
|
|
1336
1546
|
* Returns a transliterated string name of Hebrew month in year,
|
|
@@ -1342,11 +1552,7 @@ class HDate {
|
|
|
1342
1552
|
|
|
1343
1553
|
|
|
1344
1554
|
static getMonthName(month, year) {
|
|
1345
|
-
|
|
1346
|
-
throw new TypeError(`bad month argument ${month}`);
|
|
1347
|
-
}
|
|
1348
|
-
|
|
1349
|
-
return monthNames[+HDate.isLeapYear(year)][month];
|
|
1555
|
+
return getMonthName(month, year);
|
|
1350
1556
|
}
|
|
1351
1557
|
/**
|
|
1352
1558
|
* Returns the Hebrew month number (NISAN=1, TISHREI=7)
|
|
@@ -1356,43 +1562,17 @@ class HDate {
|
|
|
1356
1562
|
|
|
1357
1563
|
|
|
1358
1564
|
static monthNum(month) {
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
/**
|
|
1364
|
-
* Days from sunday prior to start of Hebrew calendar to mean
|
|
1365
|
-
* conjunction of Tishrei in Hebrew YEAR
|
|
1366
|
-
* @param {number} year Hebrew year
|
|
1367
|
-
* @return {number}
|
|
1368
|
-
*/
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
static elapsedDays(year) {
|
|
1372
|
-
const elapsed = edCache[year] = edCache[year] || HDate.elapsedDays0(year);
|
|
1373
|
-
return elapsed;
|
|
1374
|
-
}
|
|
1375
|
-
/**
|
|
1376
|
-
* Days from sunday prior to start of Hebrew calendar to mean
|
|
1377
|
-
* conjunction of Tishrei in Hebrew YEAR
|
|
1378
|
-
* @private
|
|
1379
|
-
* @param {number} year Hebrew year
|
|
1380
|
-
* @return {number}
|
|
1381
|
-
*/
|
|
1382
|
-
|
|
1565
|
+
if (typeof month === 'number') {
|
|
1566
|
+
if (isNaN(month) || month > 14) {
|
|
1567
|
+
throw new RangeError(`Invalid month number: ${month}`);
|
|
1568
|
+
}
|
|
1383
1569
|
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
const mElapsed = 235 * Math.floor(prevYear / 19) + // Months in complete 19 year lunar (Metonic) cycles so far
|
|
1387
|
-
12 * (prevYear % 19) + // Regular months in this cycle
|
|
1388
|
-
Math.floor((prevYear % 19 * 7 + 1) / 19); // Leap months this cycle
|
|
1570
|
+
return month;
|
|
1571
|
+
}
|
|
1389
1572
|
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
const day = 1 + 29 * mElapsed + Math.floor(hElapsed / 24);
|
|
1394
|
-
const altDay = day + (parts >= 19440 || 2 == day % 7 && parts >= 9924 && !HDate.isLeapYear(year) || 1 == day % 7 && parts >= 16789 && HDate.isLeapYear(prevYear));
|
|
1395
|
-
return altDay + (altDay % 7 === 0 || altDay % 7 == 3 || altDay % 7 == 5);
|
|
1573
|
+
return month.charCodeAt(0) >= 48 && month.charCodeAt(0) <= 57 ?
|
|
1574
|
+
/* number */
|
|
1575
|
+
parseInt(month, 10) : HDate.monthFromName(month);
|
|
1396
1576
|
}
|
|
1397
1577
|
/**
|
|
1398
1578
|
* Number of days in the hebrew YEAR
|
|
@@ -1402,7 +1582,7 @@ class HDate {
|
|
|
1402
1582
|
|
|
1403
1583
|
|
|
1404
1584
|
static daysInYear(year) {
|
|
1405
|
-
return
|
|
1585
|
+
return daysInYear(year);
|
|
1406
1586
|
}
|
|
1407
1587
|
/**
|
|
1408
1588
|
* true if Cheshvan is long in Hebrew year
|
|
@@ -1412,7 +1592,7 @@ class HDate {
|
|
|
1412
1592
|
|
|
1413
1593
|
|
|
1414
1594
|
static longCheshvan(year) {
|
|
1415
|
-
return
|
|
1595
|
+
return longCheshvan(year);
|
|
1416
1596
|
}
|
|
1417
1597
|
/**
|
|
1418
1598
|
* true if Kislev is short in Hebrew year
|
|
@@ -1422,7 +1602,7 @@ class HDate {
|
|
|
1422
1602
|
|
|
1423
1603
|
|
|
1424
1604
|
static shortKislev(year) {
|
|
1425
|
-
return
|
|
1605
|
+
return shortKislev(year);
|
|
1426
1606
|
}
|
|
1427
1607
|
/**
|
|
1428
1608
|
* Converts Hebrew month string name to numeric
|
|
@@ -1432,7 +1612,14 @@ class HDate {
|
|
|
1432
1612
|
|
|
1433
1613
|
|
|
1434
1614
|
static monthFromName(monthName) {
|
|
1435
|
-
if (typeof monthName === 'number')
|
|
1615
|
+
if (typeof monthName === 'number') {
|
|
1616
|
+
if (isNaN(monthName) || monthName < 1 || monthName > 14) {
|
|
1617
|
+
throw new RangeError(`Invalid month name: ${monthName}`);
|
|
1618
|
+
}
|
|
1619
|
+
|
|
1620
|
+
return monthName;
|
|
1621
|
+
}
|
|
1622
|
+
|
|
1436
1623
|
const c = monthName.toLowerCase();
|
|
1437
1624
|
/*
|
|
1438
1625
|
the Hebrew months are unique to their second letter
|
|
@@ -1464,41 +1651,41 @@ class HDate {
|
|
|
1464
1651
|
/* this catches "november" */
|
|
1465
1652
|
}
|
|
1466
1653
|
|
|
1467
|
-
return NISAN
|
|
1654
|
+
return months.NISAN;
|
|
1468
1655
|
|
|
1469
1656
|
case 'i':
|
|
1470
|
-
return IYYAR
|
|
1657
|
+
return months.IYYAR;
|
|
1471
1658
|
|
|
1472
1659
|
case 'e':
|
|
1473
|
-
return ELUL
|
|
1660
|
+
return months.ELUL;
|
|
1474
1661
|
|
|
1475
1662
|
case 'c':
|
|
1476
1663
|
case 'ח':
|
|
1477
|
-
return CHESHVAN
|
|
1664
|
+
return months.CHESHVAN;
|
|
1478
1665
|
|
|
1479
1666
|
case 'k':
|
|
1480
1667
|
case 'כ':
|
|
1481
|
-
return KISLEV
|
|
1668
|
+
return months.KISLEV;
|
|
1482
1669
|
|
|
1483
1670
|
case 's':
|
|
1484
1671
|
switch (c[1]) {
|
|
1485
1672
|
case 'i':
|
|
1486
|
-
return SIVAN
|
|
1673
|
+
return months.SIVAN;
|
|
1487
1674
|
|
|
1488
1675
|
case 'h':
|
|
1489
|
-
return SHVAT
|
|
1676
|
+
return months.SHVAT;
|
|
1490
1677
|
}
|
|
1491
1678
|
|
|
1492
1679
|
case 't':
|
|
1493
1680
|
switch (c[1]) {
|
|
1494
1681
|
case 'a':
|
|
1495
|
-
return TAMUZ
|
|
1682
|
+
return months.TAMUZ;
|
|
1496
1683
|
|
|
1497
1684
|
case 'i':
|
|
1498
|
-
return TISHREI
|
|
1685
|
+
return months.TISHREI;
|
|
1499
1686
|
|
|
1500
1687
|
case 'e':
|
|
1501
|
-
return TEVET
|
|
1688
|
+
return months.TEVET;
|
|
1502
1689
|
}
|
|
1503
1690
|
|
|
1504
1691
|
break;
|
|
@@ -1506,46 +1693,46 @@ class HDate {
|
|
|
1506
1693
|
case 'a':
|
|
1507
1694
|
switch (c[1]) {
|
|
1508
1695
|
case 'v':
|
|
1509
|
-
return AV
|
|
1696
|
+
return months.AV;
|
|
1510
1697
|
|
|
1511
1698
|
case 'd':
|
|
1512
1699
|
if (/(1|[^i]i|a|א)$/i.test(monthName)) {
|
|
1513
|
-
return ADAR_I
|
|
1700
|
+
return months.ADAR_I;
|
|
1514
1701
|
}
|
|
1515
1702
|
|
|
1516
|
-
return ADAR_II
|
|
1703
|
+
return months.ADAR_II;
|
|
1517
1704
|
// else assume sheini
|
|
1518
1705
|
}
|
|
1519
1706
|
|
|
1520
1707
|
break;
|
|
1521
1708
|
|
|
1522
1709
|
case 'ס':
|
|
1523
|
-
return SIVAN
|
|
1710
|
+
return months.SIVAN;
|
|
1524
1711
|
|
|
1525
1712
|
case 'ט':
|
|
1526
|
-
return TEVET
|
|
1713
|
+
return months.TEVET;
|
|
1527
1714
|
|
|
1528
1715
|
case 'ש':
|
|
1529
|
-
return SHVAT
|
|
1716
|
+
return months.SHVAT;
|
|
1530
1717
|
|
|
1531
1718
|
case 'א':
|
|
1532
1719
|
switch (c[1]) {
|
|
1533
1720
|
case 'ב':
|
|
1534
|
-
return AV
|
|
1721
|
+
return months.AV;
|
|
1535
1722
|
|
|
1536
1723
|
case 'ד':
|
|
1537
1724
|
if (/(1|[^i]i|a|א)$/i.test(monthName)) {
|
|
1538
|
-
return ADAR_I
|
|
1725
|
+
return months.ADAR_I;
|
|
1539
1726
|
}
|
|
1540
1727
|
|
|
1541
|
-
return ADAR_II
|
|
1728
|
+
return months.ADAR_II;
|
|
1542
1729
|
// else assume sheini
|
|
1543
1730
|
|
|
1544
1731
|
case 'י':
|
|
1545
|
-
return IYYAR
|
|
1732
|
+
return months.IYYAR;
|
|
1546
1733
|
|
|
1547
1734
|
case 'ל':
|
|
1548
|
-
return ELUL
|
|
1735
|
+
return months.ELUL;
|
|
1549
1736
|
}
|
|
1550
1737
|
|
|
1551
1738
|
break;
|
|
@@ -1553,10 +1740,10 @@ class HDate {
|
|
|
1553
1740
|
case 'ת':
|
|
1554
1741
|
switch (c[1]) {
|
|
1555
1742
|
case 'מ':
|
|
1556
|
-
return TAMUZ
|
|
1743
|
+
return months.TAMUZ;
|
|
1557
1744
|
|
|
1558
1745
|
case 'ש':
|
|
1559
|
-
return TISHREI
|
|
1746
|
+
return months.TISHREI;
|
|
1560
1747
|
}
|
|
1561
1748
|
|
|
1562
1749
|
break;
|
|
@@ -1607,21 +1794,21 @@ function fix(date) {
|
|
|
1607
1794
|
|
|
1608
1795
|
function fixDate(date) {
|
|
1609
1796
|
if (date.day < 1) {
|
|
1610
|
-
if (date.month == TISHREI
|
|
1797
|
+
if (date.month == months.TISHREI) {
|
|
1611
1798
|
date.year -= 1;
|
|
1612
1799
|
}
|
|
1613
1800
|
|
|
1614
|
-
date.day +=
|
|
1801
|
+
date.day += daysInMonth(date.month, date.year);
|
|
1615
1802
|
date.month -= 1;
|
|
1616
1803
|
fix(date);
|
|
1617
1804
|
}
|
|
1618
1805
|
|
|
1619
|
-
if (date.day >
|
|
1620
|
-
if (date.month
|
|
1806
|
+
if (date.day > daysInMonth(date.month, date.year)) {
|
|
1807
|
+
if (date.month === months.ELUL) {
|
|
1621
1808
|
date.year += 1;
|
|
1622
1809
|
}
|
|
1623
1810
|
|
|
1624
|
-
date.day -=
|
|
1811
|
+
date.day -= daysInMonth(date.month, date.year);
|
|
1625
1812
|
date.month += 1;
|
|
1626
1813
|
fix(date);
|
|
1627
1814
|
}
|
|
@@ -1635,16 +1822,16 @@ function fixDate(date) {
|
|
|
1635
1822
|
|
|
1636
1823
|
|
|
1637
1824
|
function fixMonth(date) {
|
|
1638
|
-
if (date.month
|
|
1825
|
+
if (date.month === months.ADAR_II && !date.isLeapYear()) {
|
|
1639
1826
|
date.month -= 1; // to Adar I
|
|
1640
1827
|
|
|
1641
1828
|
fix(date);
|
|
1642
1829
|
} else if (date.month < 1) {
|
|
1643
|
-
date.month +=
|
|
1830
|
+
date.month += monthsInYear(date.year);
|
|
1644
1831
|
date.year -= 1;
|
|
1645
1832
|
fix(date);
|
|
1646
|
-
} else if (date.month >
|
|
1647
|
-
date.month -=
|
|
1833
|
+
} else if (date.month > monthsInYear(date.year)) {
|
|
1834
|
+
date.month -= monthsInYear(date.year);
|
|
1648
1835
|
date.year += 1;
|
|
1649
1836
|
fix(date);
|
|
1650
1837
|
}
|
|
@@ -1664,31 +1851,6 @@ function onOrBefore(day, t, offset) {
|
|
|
1664
1851
|
return new HDate(HDate.dayOnOrBefore(day, t.abs() + offset));
|
|
1665
1852
|
}
|
|
1666
1853
|
|
|
1667
|
-
const CHAG$1 = 0x000001;
|
|
1668
|
-
const LIGHT_CANDLES$2 = 0x000002;
|
|
1669
|
-
const YOM_TOV_ENDS$2 = 0x000004;
|
|
1670
|
-
const CHUL_ONLY$2 = 0x000008; // chutz l'aretz (Diaspora)
|
|
1671
|
-
|
|
1672
|
-
const IL_ONLY$2 = 0x000010; // b'aretz (Israel)
|
|
1673
|
-
|
|
1674
|
-
const LIGHT_CANDLES_TZEIS$2 = 0x000020;
|
|
1675
|
-
const CHANUKAH_CANDLES$2 = 0x000040;
|
|
1676
|
-
const ROSH_CHODESH$1 = 0x000080;
|
|
1677
|
-
const MINOR_FAST$2 = 0x000100;
|
|
1678
|
-
const SPECIAL_SHABBAT$2 = 0x000200;
|
|
1679
|
-
const PARSHA_HASHAVUA$1 = 0x000400;
|
|
1680
|
-
const DAF_YOMI$1 = 0x000800;
|
|
1681
|
-
const OMER_COUNT$1 = 0x001000;
|
|
1682
|
-
const MODERN_HOLIDAY$2 = 0x002000;
|
|
1683
|
-
const MAJOR_FAST$2 = 0x004000;
|
|
1684
|
-
const SHABBAT_MEVARCHIM$1 = 0x008000;
|
|
1685
|
-
const MOLAD = 0x010000;
|
|
1686
|
-
const USER_EVENT = 0x020000;
|
|
1687
|
-
const HEBREW_DATE = 0x040000;
|
|
1688
|
-
const MINOR_HOLIDAY$2 = 0x080000;
|
|
1689
|
-
const EREV$2 = 0x100000;
|
|
1690
|
-
const CHOL_HAMOED$2 = 0x200000;
|
|
1691
|
-
const MISHNA_YOMI = 0x400000;
|
|
1692
1854
|
/**
|
|
1693
1855
|
* Holiday flags for Event
|
|
1694
1856
|
* @readonly
|
|
@@ -1697,73 +1859,73 @@ const MISHNA_YOMI = 0x400000;
|
|
|
1697
1859
|
|
|
1698
1860
|
const flags = {
|
|
1699
1861
|
/** Chag, yontiff, yom tov */
|
|
1700
|
-
CHAG:
|
|
1862
|
+
CHAG: 0x000001,
|
|
1701
1863
|
|
|
1702
1864
|
/** Light candles 18 minutes before sundown */
|
|
1703
|
-
LIGHT_CANDLES:
|
|
1865
|
+
LIGHT_CANDLES: 0x000002,
|
|
1704
1866
|
|
|
1705
1867
|
/** End of holiday (end of Yom Tov) */
|
|
1706
|
-
YOM_TOV_ENDS:
|
|
1868
|
+
YOM_TOV_ENDS: 0x000004,
|
|
1707
1869
|
|
|
1708
1870
|
/** Observed only in the Diaspora (chutz l'aretz) */
|
|
1709
|
-
CHUL_ONLY:
|
|
1871
|
+
CHUL_ONLY: 0x000008,
|
|
1710
1872
|
|
|
1711
1873
|
/** Observed only in Israel */
|
|
1712
|
-
IL_ONLY:
|
|
1874
|
+
IL_ONLY: 0x000010,
|
|
1713
1875
|
|
|
1714
1876
|
/** Light candles in the evening at Tzeit time (3 small stars) */
|
|
1715
|
-
LIGHT_CANDLES_TZEIS:
|
|
1877
|
+
LIGHT_CANDLES_TZEIS: 0x000020,
|
|
1716
1878
|
|
|
1717
1879
|
/** Candle-lighting for Chanukah */
|
|
1718
|
-
CHANUKAH_CANDLES:
|
|
1880
|
+
CHANUKAH_CANDLES: 0x000040,
|
|
1719
1881
|
|
|
1720
1882
|
/** Rosh Chodesh, beginning of a new Hebrew month */
|
|
1721
|
-
ROSH_CHODESH:
|
|
1883
|
+
ROSH_CHODESH: 0x000080,
|
|
1722
1884
|
|
|
1723
1885
|
/** Minor fasts like Tzom Tammuz, Ta'anit Esther, ... */
|
|
1724
|
-
MINOR_FAST:
|
|
1886
|
+
MINOR_FAST: 0x000100,
|
|
1725
1887
|
|
|
1726
1888
|
/** Shabbat Shekalim, Zachor, ... */
|
|
1727
|
-
SPECIAL_SHABBAT:
|
|
1889
|
+
SPECIAL_SHABBAT: 0x000200,
|
|
1728
1890
|
|
|
1729
1891
|
/** Weekly sedrot on Saturdays */
|
|
1730
|
-
PARSHA_HASHAVUA:
|
|
1892
|
+
PARSHA_HASHAVUA: 0x000400,
|
|
1731
1893
|
|
|
1732
1894
|
/** Daily page of Talmud */
|
|
1733
|
-
DAF_YOMI:
|
|
1895
|
+
DAF_YOMI: 0x000800,
|
|
1734
1896
|
|
|
1735
1897
|
/** Days of the Omer */
|
|
1736
|
-
OMER_COUNT:
|
|
1898
|
+
OMER_COUNT: 0x000800,
|
|
1737
1899
|
|
|
1738
1900
|
/** Yom HaShoah, Yom HaAtzma'ut, ... */
|
|
1739
|
-
MODERN_HOLIDAY:
|
|
1901
|
+
MODERN_HOLIDAY: 0x002000,
|
|
1740
1902
|
|
|
1741
1903
|
/** Yom Kippur and Tish'a B'Av */
|
|
1742
|
-
MAJOR_FAST:
|
|
1904
|
+
MAJOR_FAST: 0x004000,
|
|
1743
1905
|
|
|
1744
1906
|
/** On the Saturday before Rosh Chodesh */
|
|
1745
|
-
SHABBAT_MEVARCHIM:
|
|
1907
|
+
SHABBAT_MEVARCHIM: 0x008000,
|
|
1746
1908
|
|
|
1747
1909
|
/** Molad */
|
|
1748
|
-
MOLAD,
|
|
1910
|
+
MOLAD: 0x010000,
|
|
1749
1911
|
|
|
1750
1912
|
/** Yahrzeit or Hebrew Anniversary */
|
|
1751
|
-
USER_EVENT,
|
|
1913
|
+
USER_EVENT: 0x020000,
|
|
1752
1914
|
|
|
1753
1915
|
/** Daily Hebrew date ("11th of Sivan, 5780") */
|
|
1754
|
-
HEBREW_DATE,
|
|
1916
|
+
HEBREW_DATE: 0x040000,
|
|
1755
1917
|
|
|
1756
1918
|
/** A holiday that's not major, modern, rosh chodesh, or a fast day */
|
|
1757
|
-
MINOR_HOLIDAY:
|
|
1919
|
+
MINOR_HOLIDAY: 0x080000,
|
|
1758
1920
|
|
|
1759
1921
|
/** Evening before a major or minor holiday */
|
|
1760
|
-
EREV:
|
|
1922
|
+
EREV: 0x080000,
|
|
1761
1923
|
|
|
1762
1924
|
/** Chol haMoed, intermediate days of Pesach or Sukkot */
|
|
1763
|
-
CHOL_HAMOED:
|
|
1925
|
+
CHOL_HAMOED: 0x200000,
|
|
1764
1926
|
|
|
1765
1927
|
/** Mishna Yomi */
|
|
1766
|
-
MISHNA_YOMI
|
|
1928
|
+
MISHNA_YOMI: 0x400000
|
|
1767
1929
|
};
|
|
1768
1930
|
/** Represents an Event with a title, date, and flags */
|
|
1769
1931
|
|
|
@@ -1881,7 +2043,7 @@ class Event {
|
|
|
1881
2043
|
|
|
1882
2044
|
|
|
1883
2045
|
observedInIsrael() {
|
|
1884
|
-
return !(this.mask & CHUL_ONLY
|
|
2046
|
+
return !(this.mask & flags.CHUL_ONLY);
|
|
1885
2047
|
}
|
|
1886
2048
|
/**
|
|
1887
2049
|
* Is this event observed in the Diaspora?
|
|
@@ -1895,7 +2057,7 @@ class Event {
|
|
|
1895
2057
|
|
|
1896
2058
|
|
|
1897
2059
|
observedInDiaspora() {
|
|
1898
|
-
return !(this.mask & IL_ONLY
|
|
2060
|
+
return !(this.mask & flags.IL_ONLY);
|
|
1899
2061
|
}
|
|
1900
2062
|
/**
|
|
1901
2063
|
* @deprecated
|
|
@@ -2446,7 +2608,7 @@ class Zmanim {
|
|
|
2446
2608
|
throw new RangeError(`Longitude ${longitude} out of range [-180,180]`);
|
|
2447
2609
|
}
|
|
2448
2610
|
|
|
2449
|
-
const dt =
|
|
2611
|
+
const dt = isDate(date) ? date : HDate.isHDate(date) ? date.greg() : throwTypeError$2(`invalid date: ${date}`);
|
|
2450
2612
|
this.date = dt;
|
|
2451
2613
|
this.solarCalc = new SolarCalc(this.date, latitude, longitude);
|
|
2452
2614
|
this.sun = this.solarCalc.sun;
|
|
@@ -3610,7 +3772,6 @@ class OmerEvent extends Event {
|
|
|
3610
3772
|
|
|
3611
3773
|
this.weekNumber = Math.floor((omerDay - 1) / 7) + 1;
|
|
3612
3774
|
this.daysWithinWeeks = omerDay % 7 || 7;
|
|
3613
|
-
this.memo = [this.sefira('en'), this.sefira('he'), this.sefira('translit')].join('\n');
|
|
3614
3775
|
}
|
|
3615
3776
|
/**
|
|
3616
3777
|
* @param {string} lang
|
|
@@ -3812,8 +3973,8 @@ function getTodayIsHe(omer) {
|
|
|
3812
3973
|
|
|
3813
3974
|
/* eslint-disable no-multi-spaces */
|
|
3814
3975
|
const osdate = new Date(1923, 8, 11);
|
|
3815
|
-
const osday =
|
|
3816
|
-
const nsday =
|
|
3976
|
+
const osday = greg2abs(osdate);
|
|
3977
|
+
const nsday = greg2abs(new Date(1975, 5, 24));
|
|
3817
3978
|
const shas = [['Berachot', 64], ['Shabbat', 157], ['Eruvin', 105], ['Pesachim', 121], ['Shekalim', 22], ['Yoma', 88], ['Sukkah', 56], ['Beitzah', 40], ['Rosh Hashana', 35], ['Taanit', 31], ['Megillah', 32], ['Moed Katan', 29], ['Chagigah', 27], ['Yevamot', 122], ['Ketubot', 112], ['Nedarim', 91], ['Nazir', 66], ['Sotah', 49], ['Gitin', 90], ['Kiddushin', 82], ['Baba Kamma', 119], ['Baba Metzia', 119], ['Baba Batra', 176], ['Sanhedrin', 113], ['Makkot', 24], ['Shevuot', 49], ['Avodah Zarah', 76], ['Horayot', 14], ['Zevachim', 120], ['Menachot', 110], ['Chullin', 142], ['Bechorot', 61], ['Arachin', 34], ['Temurah', 34], ['Keritot', 28], ['Meilah', 22], ['Kinnim', 4], ['Tamid', 9], ['Midot', 5], ['Niddah', 73]].map(m => {
|
|
3818
3979
|
return {
|
|
3819
3980
|
name: m[0],
|
|
@@ -3835,7 +3996,7 @@ class DafYomi {
|
|
|
3835
3996
|
* @param {Date|HDate|number} gregdate Gregorian date
|
|
3836
3997
|
*/
|
|
3837
3998
|
constructor(gregdate) {
|
|
3838
|
-
const cday = typeof gregdate === 'number' && !isNaN(gregdate) ? gregdate :
|
|
3999
|
+
const cday = typeof gregdate === 'number' && !isNaN(gregdate) ? gregdate : isDate(gregdate) ? greg2abs(gregdate) : HDate.isHDate(gregdate) ? gregdate.abs() : throwTypeError$1(`non-date given to dafyomi: ${gregdate}`);
|
|
3839
4000
|
|
|
3840
4001
|
if (cday < osday) {
|
|
3841
4002
|
throw new RangeError(`Date ${gregdate} too early; Daf Yomi cycle began on ${osdate}`);
|
|
@@ -5090,7 +5251,7 @@ function getHolidaysForYear_(year) {
|
|
|
5090
5251
|
var mishnayot = [{k:"Berakhot",v:[5,8,6,7,5,8,5,8,5]},{k:"Peah",v:[6,8,8,11,8,11,8,9]},{k:"Demai",v:[4,5,6,7,11,12,8]},{k:"Kilayim",v:[9,11,7,9,8,9,8,6,10]},{k:"Sheviit",v:[8,10,10,10,9,6,7,11,9,9]},{k:"Terumot",v:[10,6,9,13,9,6,7,12,7,12,10]},{k:"Maasrot",v:[8,8,10,6,8]},{k:"Maaser Sheni",v:[7,10,13,12,15]},{k:"Challah",v:[9,8,10,11]},{k:"Orlah",v:[9,17,9]},{k:"Bikkurim",v:[11,11,12,5]},{k:"Shabbat",v:[11,7,6,2,4,10,4,7,7,6,6,6,7,4,3,8,8,3,6,5,3,6,5,5]},{k:"Eruvin",v:[10,6,9,11,9,10,11,11,4,15]},{k:"Pesachim",v:[7,8,8,9,10,6,13,8,11,9]},{k:"Shekalim",v:[7,5,4,9,6,6,7,8]},{k:"Yoma",v:[8,7,11,6,7,8,5,9]},{k:"Sukkah",v:[11,9,15,10,8]},{k:"Beitzah",v:[10,10,8,7,7]},{k:"Rosh Hashanah",v:[9,9,8,9]},{k:"Taanit",v:[7,10,9,8]},{k:"Megillah",v:[11,6,6,10]},{k:"Moed Katan",v:[10,5,9]},{k:"Chagigah",v:[8,7,8]},{k:"Yevamot",v:[4,10,10,13,6,6,6,6,6,9,7,6,13,9,10,7]},{k:"Ketubot",v:[10,10,9,12,9,7,10,8,9,6,6,4,11]},{k:"Nedarim",v:[4,5,11,8,6,10,9,7,10,8,12]},{k:"Nazir",v:[7,10,7,7,7,11,4,2,5]},{k:"Sotah",v:[9,6,8,5,5,4,8,7,15]},{k:"Gittin",v:[6,7,8,9,9,7,9,10,10]},{k:"Kiddushin",v:[10,10,13,14]},{k:"Bava Kamma",v:[4,6,11,9,7,6,7,7,12,10]},{k:"Bava Metzia",v:[8,11,12,12,11,8,11,9,13,6]},{k:"Bava Batra",v:[6,14,8,9,11,8,4,8,10,8]},{k:"Sanhedrin",v:[6,5,8,5,5,6,11,7,6,6,6]},{k:"Makkot",v:[10,8,16]},{k:"Shevuot",v:[7,5,11,13,5,7,8,6]},{k:"Eduyot",v:[14,10,12,12,7,3,9,7]},{k:"Avodah Zarah",v:[9,7,10,12,12]},{k:"Avot",v:[18,16,18,22,23,11]},{k:"Horayot",v:[5,7,8]},{k:"Zevachim",v:[4,5,6,6,8,7,6,12,7,8,8,6,8,10]},{k:"Menachot",v:[4,5,7,5,9,7,6,7,9,9,9,5,11]},{k:"Chullin",v:[7,10,7,7,5,7,6,6,8,4,2,5]},{k:"Bekhorot",v:[7,9,4,10,6,12,7,10,8]},{k:"Arakhin",v:[4,6,5,4,6,5,5,7,8]},{k:"Temurah",v:[6,3,5,4,6,5,6]},{k:"Keritot",v:[7,6,10,3,8,9]},{k:"Meilah",v:[4,9,8,6,5,6]},{k:"Tamid",v:[4,5,9,3,6,3,4]},{k:"Middot",v:[9,6,8,7,4]},{k:"Kinnim",v:[4,5,6]},{k:"Kelim",v:[9,8,8,4,11,4,6,11,8,8,9,8,8,8,6,8,17,9,10,7,3,10,5,17,9,9,12,10,8,4]},{k:"Oholot",v:[8,7,7,3,7,7,6,6,16,7,9,8,6,7,10,5,5,10]},{k:"Negaim",v:[6,5,8,11,5,8,5,10,3,10,12,7,12,13]},{k:"Parah",v:[4,5,11,4,9,5,12,11,9,6,9,11]},{k:"Tahorot",v:[9,8,8,13,9,10,9,9,9,8]},{k:"Mikvaot",v:[8,10,4,5,6,11,7,5,7,8]},{k:"Niddah",v:[7,7,7,7,9,14,5,4,11,8]},{k:"Makhshirin",v:[6,11,8,10,11,8]},{k:"Zavim",v:[6,4,3,7,12]},{k:"Tevul Yom",v:[5,8,6,7]},{k:"Yadayim",v:[5,4,5,8]},{k:"Oktzin",v:[6,10,12]}];
|
|
5091
5252
|
|
|
5092
5253
|
const cycleStartDate = new Date(1947, 4, 20);
|
|
5093
|
-
const mishnaYomiStart =
|
|
5254
|
+
const mishnaYomiStart = greg2abs(cycleStartDate);
|
|
5094
5255
|
const numMishnayot = 4192;
|
|
5095
5256
|
const numDays = numMishnayot / 2;
|
|
5096
5257
|
/**
|
|
@@ -5152,7 +5313,7 @@ class MishnaYomiIndex {
|
|
|
5152
5313
|
|
|
5153
5314
|
|
|
5154
5315
|
lookup(date) {
|
|
5155
|
-
const abs = typeof date === 'number' && !isNaN(date) ? date :
|
|
5316
|
+
const abs = typeof date === 'number' && !isNaN(date) ? date : isDate(date) ? greg2abs(date) : HDate.isHDate(date) ? date.abs() : throwTypeError(`Invalid date: ${date}`);
|
|
5156
5317
|
|
|
5157
5318
|
if (abs < mishnaYomiStart) {
|
|
5158
5319
|
const s = date.toISOString().substring(0, 10);
|
|
@@ -5273,18 +5434,18 @@ function getYahrzeit_(hyear, gdate) {
|
|
|
5273
5434
|
return undefined;
|
|
5274
5435
|
}
|
|
5275
5436
|
|
|
5276
|
-
if (hDeath.mm == CHESHVAN && hDeath.dd == 30 && !
|
|
5437
|
+
if (hDeath.mm == CHESHVAN && hDeath.dd == 30 && !longCheshvan(hDeath.yy + 1)) {
|
|
5277
5438
|
// If it's Heshvan 30 it depends on the first anniversary;
|
|
5278
5439
|
// if that was not Heshvan 30, use the day before Kislev 1.
|
|
5279
|
-
hDeath =
|
|
5280
|
-
} else if (hDeath.mm == KISLEV && hDeath.dd == 30 &&
|
|
5440
|
+
hDeath = abs2hebrew(hebrew2abs(hyear, KISLEV, 1) - 1);
|
|
5441
|
+
} else if (hDeath.mm == KISLEV && hDeath.dd == 30 && shortKislev(hDeath.yy + 1)) {
|
|
5281
5442
|
// If it's Kislev 30 it depends on the first anniversary;
|
|
5282
5443
|
// if that was not Kislev 30, use the day before Teveth 1.
|
|
5283
|
-
hDeath =
|
|
5444
|
+
hDeath = abs2hebrew(hebrew2abs(hyear, TEVET, 1) - 1);
|
|
5284
5445
|
} else if (hDeath.mm == ADAR_II) {
|
|
5285
5446
|
// If it's Adar II, use the same day in last month of year (Adar or Adar II).
|
|
5286
|
-
hDeath.mm =
|
|
5287
|
-
} else if (hDeath.mm == ADAR_I && hDeath.dd == 30 && !
|
|
5447
|
+
hDeath.mm = monthsInYear(hyear);
|
|
5448
|
+
} else if (hDeath.mm == ADAR_I && hDeath.dd == 30 && !isLeapYear(hyear)) {
|
|
5288
5449
|
// If it's the 30th in Adar I and year is not a leap year
|
|
5289
5450
|
// (so Adar has only 29 days), use the last day in Shevat.
|
|
5290
5451
|
hDeath.dd = 30;
|
|
@@ -5293,10 +5454,10 @@ function getYahrzeit_(hyear, gdate) {
|
|
|
5293
5454
|
// advance day to rosh chodesh if needed
|
|
5294
5455
|
|
|
5295
5456
|
|
|
5296
|
-
if (hDeath.mm == CHESHVAN && hDeath.dd == 30 && !
|
|
5457
|
+
if (hDeath.mm == CHESHVAN && hDeath.dd == 30 && !longCheshvan(hyear)) {
|
|
5297
5458
|
hDeath.mm = KISLEV;
|
|
5298
5459
|
hDeath.dd = 1;
|
|
5299
|
-
} else if (hDeath.mm == KISLEV && hDeath.dd == 30 &&
|
|
5460
|
+
} else if (hDeath.mm == KISLEV && hDeath.dd == 30 && shortKislev(hyear)) {
|
|
5300
5461
|
hDeath.mm = TEVET;
|
|
5301
5462
|
hDeath.dd = 1;
|
|
5302
5463
|
}
|
|
@@ -5319,19 +5480,19 @@ function getBirthdayOrAnniversary_(hyear, gdate) {
|
|
|
5319
5480
|
return undefined;
|
|
5320
5481
|
}
|
|
5321
5482
|
|
|
5322
|
-
const isOrigLeap =
|
|
5483
|
+
const isOrigLeap = isLeapYear(origYear);
|
|
5323
5484
|
let month = orig.getMonth();
|
|
5324
5485
|
let day = orig.getDate();
|
|
5325
5486
|
|
|
5326
5487
|
if (month == ADAR_I && !isOrigLeap || month == ADAR_II && isOrigLeap) {
|
|
5327
|
-
month =
|
|
5328
|
-
} else if (month == CHESHVAN && day == 30 && !
|
|
5488
|
+
month = monthsInYear(hyear);
|
|
5489
|
+
} else if (month == CHESHVAN && day == 30 && !longCheshvan(hyear)) {
|
|
5329
5490
|
month = KISLEV;
|
|
5330
5491
|
day = 1;
|
|
5331
|
-
} else if (month == KISLEV && day == 30 &&
|
|
5492
|
+
} else if (month == KISLEV && day == 30 && shortKislev(hyear)) {
|
|
5332
5493
|
month = TEVET;
|
|
5333
5494
|
day = 1;
|
|
5334
|
-
} else if (month == ADAR_I && day == 30 && isOrigLeap && !
|
|
5495
|
+
} else if (month == ADAR_I && day == 30 && isOrigLeap && !isLeapYear(hyear)) {
|
|
5335
5496
|
month = NISAN$1;
|
|
5336
5497
|
day = 1;
|
|
5337
5498
|
}
|
|
@@ -5339,7 +5500,7 @@ function getBirthdayOrAnniversary_(hyear, gdate) {
|
|
|
5339
5500
|
return new HDate(day, month, hyear);
|
|
5340
5501
|
}
|
|
5341
5502
|
|
|
5342
|
-
const version="3.
|
|
5503
|
+
const version="3.38.0";
|
|
5343
5504
|
|
|
5344
5505
|
const headers$1={"plural-forms":"nplurals=2; plural=(n > 1);",language:"en_CA@ashkenazi"};const 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};
|
|
5345
5506
|
|
|
@@ -5560,7 +5721,7 @@ function checkCandleOptions(options) {
|
|
|
5560
5721
|
|
|
5561
5722
|
function getAbs(d) {
|
|
5562
5723
|
if (typeof d == 'number') return d;
|
|
5563
|
-
if (
|
|
5724
|
+
if (isDate(d)) return greg2abs(d);
|
|
5564
5725
|
if (HDate.isHDate(d)) return d.abs();
|
|
5565
5726
|
throw new TypeError(`Invalid date type: ${d}`);
|
|
5566
5727
|
}
|
|
@@ -5622,11 +5783,11 @@ function getStartAndEnd(options) {
|
|
|
5622
5783
|
startGreg.setFullYear(theYear);
|
|
5623
5784
|
}
|
|
5624
5785
|
|
|
5625
|
-
const startAbs =
|
|
5786
|
+
const startAbs = greg2abs(startGreg);
|
|
5626
5787
|
let endAbs;
|
|
5627
5788
|
|
|
5628
5789
|
if (options.month) {
|
|
5629
|
-
endAbs = startAbs +
|
|
5790
|
+
endAbs = startAbs + daysInMonth$1(theMonth, theYear) - 1;
|
|
5630
5791
|
} else {
|
|
5631
5792
|
const endYear = theYear + numYears;
|
|
5632
5793
|
const endGreg = new Date(endYear, 0, 1);
|
|
@@ -5635,7 +5796,7 @@ function getStartAndEnd(options) {
|
|
|
5635
5796
|
endGreg.setFullYear(endYear);
|
|
5636
5797
|
}
|
|
5637
5798
|
|
|
5638
|
-
endAbs =
|
|
5799
|
+
endAbs = greg2abs(endGreg) - 1;
|
|
5639
5800
|
}
|
|
5640
5801
|
|
|
5641
5802
|
return [startAbs, endAbs];
|
|
@@ -5900,7 +6061,7 @@ class HebrewCalendar {
|
|
|
5900
6061
|
warnUnrecognizedOptions(options);
|
|
5901
6062
|
const startAbs = startAndEnd[0];
|
|
5902
6063
|
const endAbs = startAndEnd[1];
|
|
5903
|
-
const startGreg =
|
|
6064
|
+
const startGreg = abs2greg(startAbs);
|
|
5904
6065
|
|
|
5905
6066
|
if (startGreg.getFullYear() < 100) {
|
|
5906
6067
|
options.candlelighting = false;
|