@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/index.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 });
|
|
@@ -18,27 +18,12 @@ function _defineProperty(obj, key, value) {
|
|
|
18
18
|
return obj;
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
Copyright (c) 1994-2020 Danny Sadinoff
|
|
24
|
-
Portions copyright Eyal Schachter and Michael J. Radwin
|
|
25
|
-
|
|
26
|
-
https://github.com/hebcal/hebcal-es6
|
|
27
|
-
|
|
28
|
-
This program is free software; you can redistribute it and/or
|
|
29
|
-
modify it under the terms of the GNU General Public License
|
|
30
|
-
as published by the Free Software Foundation; either version 2
|
|
31
|
-
of the License, or (at your option) any later version.
|
|
32
|
-
|
|
33
|
-
This program is distributed in the hope that it will be useful,
|
|
34
|
-
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
35
|
-
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
36
|
-
GNU General Public License for more details.
|
|
37
|
-
|
|
38
|
-
You should have received a copy of the GNU General Public License
|
|
39
|
-
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
21
|
+
/**
|
|
22
|
+
* More minimal greg routines
|
|
40
23
|
*/
|
|
41
|
-
const
|
|
24
|
+
const lengths = [0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
|
|
25
|
+
const monthLengths = [lengths, lengths.slice()];
|
|
26
|
+
monthLengths[1][2] = 29;
|
|
42
27
|
/**
|
|
43
28
|
* @private
|
|
44
29
|
* @param {number} x
|
|
@@ -60,9 +45,148 @@ function quotient(x, y) {
|
|
|
60
45
|
return Math.floor(x / y);
|
|
61
46
|
}
|
|
62
47
|
/**
|
|
63
|
-
* Gregorian
|
|
48
|
+
* Returns true if the Gregorian year is a leap year
|
|
49
|
+
* @private
|
|
50
|
+
* @param {number} year Gregorian year
|
|
51
|
+
* @return {boolean}
|
|
52
|
+
*/
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
function isLeapYear$1(year) {
|
|
56
|
+
return !(year % 4) && (!!(year % 100) || !(year % 400));
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Number of days in the Gregorian month for given year
|
|
60
|
+
* @private
|
|
61
|
+
* @param {number} month Gregorian month (1=January, 12=December)
|
|
62
|
+
* @param {number} year Gregorian year
|
|
63
|
+
* @return {number}
|
|
64
|
+
*/
|
|
65
|
+
|
|
66
|
+
function daysInMonth$1(month, year) {
|
|
67
|
+
// 1 based months
|
|
68
|
+
return monthLengths[+isLeapYear$1(year)][month];
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Returns true if the object is a Javascript Date
|
|
72
|
+
* @private
|
|
73
|
+
* @param {Object} obj
|
|
74
|
+
* @return {boolean}
|
|
75
|
+
*/
|
|
76
|
+
|
|
77
|
+
function isDate(obj) {
|
|
78
|
+
return typeof obj === 'object' && Date.prototype === obj.__proto__;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Returns number of days since January 1 of that year
|
|
82
|
+
* @private
|
|
83
|
+
* @param {Date} date Gregorian date
|
|
84
|
+
* @return {number}
|
|
85
|
+
*/
|
|
86
|
+
|
|
87
|
+
function dayOfYear(date) {
|
|
88
|
+
if (!isDate(date)) {
|
|
89
|
+
throw new TypeError('Argument to greg.dayOfYear not a Date');
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
let doy = date.getDate() + 31 * date.getMonth();
|
|
93
|
+
|
|
94
|
+
if (date.getMonth() > 1) {
|
|
95
|
+
// FEB
|
|
96
|
+
doy -= Math.floor((4 * (date.getMonth() + 1) + 23) / 10);
|
|
97
|
+
|
|
98
|
+
if (isLeapYear$1(date.getFullYear())) {
|
|
99
|
+
doy++;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
return doy;
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Converts Gregorian date to absolute R.D. (Rata Die) days
|
|
107
|
+
* @private
|
|
108
|
+
* @param {Date} date Gregorian date
|
|
109
|
+
* @return {number}
|
|
64
110
|
*/
|
|
65
111
|
|
|
112
|
+
function greg2abs(date) {
|
|
113
|
+
if (!isDate(date)) {
|
|
114
|
+
throw new TypeError('Argument to greg.greg2abs not a Date');
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
const year = date.getFullYear() - 1;
|
|
118
|
+
return dayOfYear(date) + // days this year
|
|
119
|
+
365 * year + ( // + days in prior years
|
|
120
|
+
Math.floor(year / 4) - // + Julian Leap years
|
|
121
|
+
Math.floor(year / 100) + // - century years
|
|
122
|
+
Math.floor(year / 400)); // + Gregorian leap years
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* @private
|
|
126
|
+
* @param {number} abs - R.D. number of days
|
|
127
|
+
* @return {number}
|
|
128
|
+
*/
|
|
129
|
+
|
|
130
|
+
function yearFromFixed(abs) {
|
|
131
|
+
const l0 = abs - 1;
|
|
132
|
+
const n400 = quotient(l0, 146097);
|
|
133
|
+
const d1 = mod(l0, 146097);
|
|
134
|
+
const n100 = quotient(d1, 36524);
|
|
135
|
+
const d2 = mod(d1, 36524);
|
|
136
|
+
const n4 = quotient(d2, 1461);
|
|
137
|
+
const d3 = mod(d2, 1461);
|
|
138
|
+
const n1 = quotient(d3, 365);
|
|
139
|
+
const year = 400 * n400 + 100 * n100 + 4 * n4 + n1;
|
|
140
|
+
return n100 != 4 && n1 != 4 ? year + 1 : year;
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* @private
|
|
144
|
+
* @param {number} year
|
|
145
|
+
* @param {number} month
|
|
146
|
+
* @param {number} day
|
|
147
|
+
* @return {number}
|
|
148
|
+
*/
|
|
149
|
+
|
|
150
|
+
|
|
151
|
+
function toFixed(year, month, day) {
|
|
152
|
+
const py = year - 1;
|
|
153
|
+
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;
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
* Converts from Rata Die (R.D. number) to Gregorian date.
|
|
157
|
+
* See the footnote on page 384 of ``Calendrical Calculations, Part II:
|
|
158
|
+
* Three Historical Calendars'' by E. M. Reingold, N. Dershowitz, and S. M.
|
|
159
|
+
* Clamen, Software--Practice and Experience, Volume 23, Number 4
|
|
160
|
+
* (April, 1993), pages 383-404 for an explanation.
|
|
161
|
+
* @private
|
|
162
|
+
* @param {number} abs - R.D. number of days
|
|
163
|
+
* @return {Date}
|
|
164
|
+
*/
|
|
165
|
+
|
|
166
|
+
|
|
167
|
+
function abs2greg(abs) {
|
|
168
|
+
if (typeof abs !== 'number') {
|
|
169
|
+
throw new TypeError('Argument to greg.abs2greg not a Number');
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
abs = Math.trunc(abs);
|
|
173
|
+
const year = yearFromFixed(abs);
|
|
174
|
+
const priorDays = abs - toFixed(year, 1, 1);
|
|
175
|
+
const correction = abs < toFixed(year, 3, 1) ? 0 : isLeapYear$1(year) ? 1 : 2;
|
|
176
|
+
const month = quotient(12 * (priorDays + correction) + 373, 367);
|
|
177
|
+
const day = abs - toFixed(year, month, 1) + 1;
|
|
178
|
+
const dt = new Date(year, month - 1, day);
|
|
179
|
+
|
|
180
|
+
if (year < 100 && year >= 0) {
|
|
181
|
+
dt.setFullYear(year);
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
return dt;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
/**
|
|
188
|
+
* Gregorian date helper functions.
|
|
189
|
+
*/
|
|
66
190
|
|
|
67
191
|
class greg {
|
|
68
192
|
/**
|
|
@@ -77,7 +201,7 @@ class greg {
|
|
|
77
201
|
* @return {boolean}
|
|
78
202
|
*/
|
|
79
203
|
static isLeapYear(year) {
|
|
80
|
-
return
|
|
204
|
+
return isLeapYear$1(year);
|
|
81
205
|
}
|
|
82
206
|
/**
|
|
83
207
|
* Number of days in the Gregorian month for given year
|
|
@@ -88,8 +212,7 @@ class greg {
|
|
|
88
212
|
|
|
89
213
|
|
|
90
214
|
static daysInMonth(month, year) {
|
|
91
|
-
|
|
92
|
-
return monthLengths[+this.isLeapYear(year)][month];
|
|
215
|
+
return daysInMonth$1(month, year);
|
|
93
216
|
}
|
|
94
217
|
/**
|
|
95
218
|
* Returns true if the object is a Javascript Date
|
|
@@ -99,7 +222,7 @@ class greg {
|
|
|
99
222
|
|
|
100
223
|
|
|
101
224
|
static isDate(obj) {
|
|
102
|
-
return
|
|
225
|
+
return isDate(obj);
|
|
103
226
|
}
|
|
104
227
|
/**
|
|
105
228
|
* Returns number of days since January 1 of that year
|
|
@@ -109,22 +232,7 @@ class greg {
|
|
|
109
232
|
|
|
110
233
|
|
|
111
234
|
static dayOfYear(date) {
|
|
112
|
-
|
|
113
|
-
throw new TypeError('Argument to greg.dayOfYear not a Date');
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
let doy = date.getDate() + 31 * date.getMonth();
|
|
117
|
-
|
|
118
|
-
if (date.getMonth() > 1) {
|
|
119
|
-
// FEB
|
|
120
|
-
doy -= Math.floor((4 * (date.getMonth() + 1) + 23) / 10);
|
|
121
|
-
|
|
122
|
-
if (this.isLeapYear(date.getFullYear())) {
|
|
123
|
-
doy++;
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
return doy;
|
|
235
|
+
return dayOfYear(date);
|
|
128
236
|
}
|
|
129
237
|
/**
|
|
130
238
|
* Converts Gregorian date to absolute R.D. (Rata Die) days
|
|
@@ -134,48 +242,7 @@ class greg {
|
|
|
134
242
|
|
|
135
243
|
|
|
136
244
|
static greg2abs(date) {
|
|
137
|
-
|
|
138
|
-
throw new TypeError('Argument to greg.greg2abs not a Date');
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
const year = date.getFullYear() - 1;
|
|
142
|
-
return this.dayOfYear(date) + // days this year
|
|
143
|
-
365 * year + ( // + days in prior years
|
|
144
|
-
Math.floor(year / 4) - // + Julian Leap years
|
|
145
|
-
Math.floor(year / 100) + // - century years
|
|
146
|
-
Math.floor(year / 400)); // + Gregorian leap years
|
|
147
|
-
}
|
|
148
|
-
/**
|
|
149
|
-
* @private
|
|
150
|
-
* @param {number} theDate - R.D. number of days
|
|
151
|
-
* @return {number}
|
|
152
|
-
*/
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
static yearFromFixed(theDate) {
|
|
156
|
-
const l0 = theDate - 1;
|
|
157
|
-
const n400 = quotient(l0, 146097);
|
|
158
|
-
const d1 = mod(l0, 146097);
|
|
159
|
-
const n100 = quotient(d1, 36524);
|
|
160
|
-
const d2 = mod(d1, 36524);
|
|
161
|
-
const n4 = quotient(d2, 1461);
|
|
162
|
-
const d3 = mod(d2, 1461);
|
|
163
|
-
const n1 = quotient(d3, 365);
|
|
164
|
-
const year = 400 * n400 + 100 * n100 + 4 * n4 + n1;
|
|
165
|
-
return n100 != 4 && n1 != 4 ? year + 1 : year;
|
|
166
|
-
}
|
|
167
|
-
/**
|
|
168
|
-
* @private
|
|
169
|
-
* @param {number} year
|
|
170
|
-
* @param {number} month
|
|
171
|
-
* @param {number} day
|
|
172
|
-
* @return {number}
|
|
173
|
-
*/
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
static toFixed(year, month, day) {
|
|
177
|
-
const py = year - 1;
|
|
178
|
-
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;
|
|
245
|
+
return greg2abs(date);
|
|
179
246
|
}
|
|
180
247
|
/**
|
|
181
248
|
* Converts from Rata Die (R.D. number) to Gregorian date.
|
|
@@ -189,23 +256,7 @@ class greg {
|
|
|
189
256
|
|
|
190
257
|
|
|
191
258
|
static abs2greg(theDate) {
|
|
192
|
-
|
|
193
|
-
throw new TypeError('Argument to greg.abs2greg not a Number');
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
theDate = Math.trunc(theDate);
|
|
197
|
-
const year = this.yearFromFixed(theDate);
|
|
198
|
-
const priorDays = theDate - this.toFixed(year, 1, 1);
|
|
199
|
-
const correction = theDate < this.toFixed(year, 3, 1) ? 0 : this.isLeapYear(year) ? 1 : 2;
|
|
200
|
-
const month = quotient(12 * (priorDays + correction) + 373, 367);
|
|
201
|
-
const day = theDate - this.toFixed(year, month, 1) + 1;
|
|
202
|
-
const dt = new Date(year, month - 1, day);
|
|
203
|
-
|
|
204
|
-
if (year < 100 && year >= 0) {
|
|
205
|
-
dt.setFullYear(year);
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
return dt;
|
|
259
|
+
return abs2greg(theDate);
|
|
209
260
|
}
|
|
210
261
|
|
|
211
262
|
}
|
|
@@ -568,37 +619,20 @@ Locale.addLocale('s', noopLocale);
|
|
|
568
619
|
Locale.addLocale('', noopLocale);
|
|
569
620
|
Locale.useLocale('en');
|
|
570
621
|
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
Copyright (c) 1994-2020 Danny Sadinoff
|
|
574
|
-
Portions copyright Eyal Schachter and Michael J. Radwin
|
|
575
|
-
|
|
576
|
-
https://github.com/hebcal/hebcal-es6
|
|
577
|
-
|
|
578
|
-
This program is free software; you can redistribute it and/or
|
|
579
|
-
modify it under the terms of the GNU General Public License
|
|
580
|
-
as published by the Free Software Foundation; either version 2
|
|
581
|
-
of the License, or (at your option) any later version.
|
|
582
|
-
|
|
583
|
-
This program is distributed in the hope that it will be useful,
|
|
584
|
-
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
585
|
-
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
586
|
-
GNU General Public License for more details.
|
|
587
|
-
|
|
588
|
-
You should have received a copy of the GNU General Public License
|
|
589
|
-
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
622
|
+
/**
|
|
623
|
+
* More minimal HDate
|
|
590
624
|
*/
|
|
591
625
|
const NISAN$3 = 1;
|
|
592
|
-
const IYYAR$1 = 2;
|
|
593
|
-
|
|
594
|
-
const TAMUZ$1 = 4;
|
|
595
|
-
|
|
626
|
+
const IYYAR$1 = 2; // const SIVAN = 3;
|
|
627
|
+
|
|
628
|
+
const TAMUZ$1 = 4; // const AV = 5;
|
|
629
|
+
|
|
596
630
|
const ELUL$2 = 6;
|
|
597
631
|
const TISHREI$2 = 7;
|
|
598
632
|
const CHESHVAN$2 = 8;
|
|
599
633
|
const KISLEV$2 = 9;
|
|
600
|
-
const TEVET$2 = 10;
|
|
601
|
-
|
|
634
|
+
const TEVET$2 = 10; // const SHVAT = 11;
|
|
635
|
+
|
|
602
636
|
const ADAR_I$2 = 12;
|
|
603
637
|
const ADAR_II$2 = 13;
|
|
604
638
|
/**
|
|
@@ -654,16 +688,244 @@ const monthNames0 = ['', 'Nisan', 'Iyyar', 'Sivan', 'Tamuz', 'Av', 'Elul', 'Tish
|
|
|
654
688
|
* @private
|
|
655
689
|
*/
|
|
656
690
|
|
|
657
|
-
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$2) {
|
|
710
|
+
for (let m = TISHREI$2; m <= monthsInYear(year); m++) {
|
|
711
|
+
tempabs += daysInMonth(m, year);
|
|
712
|
+
}
|
|
713
|
+
|
|
714
|
+
for (let m = NISAN$3; m < month; m++) {
|
|
715
|
+
tempabs += daysInMonth(m, year);
|
|
716
|
+
}
|
|
717
|
+
} else {
|
|
718
|
+
for (let m = TISHREI$2; 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$1:
|
|
815
|
+
case TAMUZ$1:
|
|
816
|
+
case ELUL$2:
|
|
817
|
+
case TEVET$2:
|
|
818
|
+
case ADAR_II$2:
|
|
819
|
+
return 29;
|
|
820
|
+
}
|
|
821
|
+
|
|
822
|
+
if (month === ADAR_I$2 && !isLeapYear(year) || month === CHESHVAN$2 && !longCheshvan(year) || month === KISLEV$2 && 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
|
+
*/
|
|
658
924
|
|
|
659
925
|
function throwTypeError$3(msg) {
|
|
660
926
|
throw new TypeError(msg);
|
|
661
927
|
}
|
|
662
928
|
|
|
663
|
-
const edCache = Object.create(null);
|
|
664
|
-
const EPOCH = -1373428; // Avg year length in the cycle (19 solar years with 235 lunar months)
|
|
665
|
-
|
|
666
|
-
const AVG_HEBYEAR_DAYS = 365.24682220597794;
|
|
667
929
|
const UNITS_DAY = 'day';
|
|
668
930
|
const UNITS_WEEK = 'week';
|
|
669
931
|
const UNITS_MONTH = 'month';
|
|
@@ -766,7 +1028,7 @@ class HDate {
|
|
|
766
1028
|
yy: day.year
|
|
767
1029
|
} : throwTypeError$3(`HDate called with bad argument: ${day}`);
|
|
768
1030
|
const isNumber = typeof abs0 === 'number';
|
|
769
|
-
const d = isNumber ?
|
|
1031
|
+
const d = isNumber ? abs2hebrew(abs0) : abs0;
|
|
770
1032
|
/**
|
|
771
1033
|
* @private
|
|
772
1034
|
* @type {number}
|
|
@@ -811,7 +1073,7 @@ class HDate {
|
|
|
811
1073
|
|
|
812
1074
|
|
|
813
1075
|
isLeapYear() {
|
|
814
|
-
return
|
|
1076
|
+
return isLeapYear(this.year);
|
|
815
1077
|
}
|
|
816
1078
|
/**
|
|
817
1079
|
* Gets the Hebrew month (1=NISAN, 7=TISHREI) of this Hebrew date
|
|
@@ -829,7 +1091,7 @@ class HDate {
|
|
|
829
1091
|
|
|
830
1092
|
|
|
831
1093
|
getTishreiMonth() {
|
|
832
|
-
const nummonths =
|
|
1094
|
+
const nummonths = monthsInYear(this.getFullYear());
|
|
833
1095
|
return (this.getMonth() + nummonths - 6) % nummonths || nummonths;
|
|
834
1096
|
}
|
|
835
1097
|
/**
|
|
@@ -839,7 +1101,7 @@ class HDate {
|
|
|
839
1101
|
|
|
840
1102
|
|
|
841
1103
|
daysInMonth() {
|
|
842
|
-
return
|
|
1104
|
+
return daysInMonth(this.getMonth(), this.getFullYear());
|
|
843
1105
|
}
|
|
844
1106
|
/**
|
|
845
1107
|
* Gets the day within the month (1-30)
|
|
@@ -918,7 +1180,7 @@ class HDate {
|
|
|
918
1180
|
|
|
919
1181
|
abs() {
|
|
920
1182
|
if (typeof this.abs0 !== 'number') {
|
|
921
|
-
this.abs0 =
|
|
1183
|
+
this.abs0 = hebrew2abs(this.year, this.month, this.day);
|
|
922
1184
|
}
|
|
923
1185
|
|
|
924
1186
|
return this.abs0;
|
|
@@ -935,51 +1197,7 @@ class HDate {
|
|
|
935
1197
|
|
|
936
1198
|
|
|
937
1199
|
static hebrew2abs(year, month, day) {
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
if (month < TISHREI$2) {
|
|
941
|
-
for (let m = TISHREI$2; m <= HDate.monthsInYear(year); m++) {
|
|
942
|
-
tempabs += HDate.daysInMonth(m, year);
|
|
943
|
-
}
|
|
944
|
-
|
|
945
|
-
for (let m = NISAN$3; m < month; m++) {
|
|
946
|
-
tempabs += HDate.daysInMonth(m, year);
|
|
947
|
-
}
|
|
948
|
-
} else {
|
|
949
|
-
for (let m = TISHREI$2; m < month; m++) {
|
|
950
|
-
tempabs += HDate.daysInMonth(m, year);
|
|
951
|
-
}
|
|
952
|
-
}
|
|
953
|
-
|
|
954
|
-
return EPOCH + HDate.elapsedDays(year) + tempabs - 1;
|
|
955
|
-
}
|
|
956
|
-
/**
|
|
957
|
-
* @private
|
|
958
|
-
* @param {number} year
|
|
959
|
-
* @return {number}
|
|
960
|
-
*/
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
static newYear(year) {
|
|
964
|
-
return EPOCH + HDate.elapsedDays(year) + HDate.newYearDelay(year);
|
|
965
|
-
}
|
|
966
|
-
/**
|
|
967
|
-
* @private
|
|
968
|
-
* @param {number} year
|
|
969
|
-
* @return {number}
|
|
970
|
-
*/
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
static newYearDelay(year) {
|
|
974
|
-
const ny1 = HDate.elapsedDays(year);
|
|
975
|
-
const ny2 = HDate.elapsedDays(year + 1);
|
|
976
|
-
|
|
977
|
-
if (ny2 - ny1 === 356) {
|
|
978
|
-
return 2;
|
|
979
|
-
} else {
|
|
980
|
-
const ny0 = HDate.elapsedDays(year - 1);
|
|
981
|
-
return ny1 - ny0 === 382 ? 1 : 0;
|
|
982
|
-
}
|
|
1200
|
+
return hebrew2abs(year, month, day);
|
|
983
1201
|
}
|
|
984
1202
|
/**
|
|
985
1203
|
* Converts absolute R.D. days to Hebrew date
|
|
@@ -990,31 +1208,7 @@ class HDate {
|
|
|
990
1208
|
|
|
991
1209
|
|
|
992
1210
|
static abs2hebrew(abs) {
|
|
993
|
-
|
|
994
|
-
throw new TypeError(`invalid parameter to abs2hebrew ${abs}`);
|
|
995
|
-
}
|
|
996
|
-
|
|
997
|
-
abs = Math.trunc(abs); // first, quickly approximate year
|
|
998
|
-
|
|
999
|
-
let year = Math.floor((abs - EPOCH) / AVG_HEBYEAR_DAYS);
|
|
1000
|
-
|
|
1001
|
-
while (HDate.newYear(year) <= abs) {
|
|
1002
|
-
++year;
|
|
1003
|
-
}
|
|
1004
|
-
|
|
1005
|
-
--year;
|
|
1006
|
-
let month = abs < HDate.hebrew2abs(year, 1, 1) ? 7 : 1;
|
|
1007
|
-
|
|
1008
|
-
while (abs > HDate.hebrew2abs(year, month, HDate.daysInMonth(month, year))) {
|
|
1009
|
-
++month;
|
|
1010
|
-
}
|
|
1011
|
-
|
|
1012
|
-
const day = 1 + abs - HDate.hebrew2abs(year, month, 1);
|
|
1013
|
-
return {
|
|
1014
|
-
yy: year,
|
|
1015
|
-
mm: month,
|
|
1016
|
-
dd: day
|
|
1017
|
-
};
|
|
1211
|
+
return abs2hebrew(abs);
|
|
1018
1212
|
}
|
|
1019
1213
|
/**
|
|
1020
1214
|
* Returns a transliterated Hebrew month name, e.g. `'Elul'` or `'Cheshvan'`.
|
|
@@ -1023,7 +1217,7 @@ class HDate {
|
|
|
1023
1217
|
|
|
1024
1218
|
|
|
1025
1219
|
getMonthName() {
|
|
1026
|
-
return
|
|
1220
|
+
return getMonthName(this.getMonth(), this.getFullYear());
|
|
1027
1221
|
}
|
|
1028
1222
|
/**
|
|
1029
1223
|
* Renders this Hebrew date as a translated or transliterated string,
|
|
@@ -1329,7 +1523,7 @@ class HDate {
|
|
|
1329
1523
|
|
|
1330
1524
|
|
|
1331
1525
|
static isLeapYear(year) {
|
|
1332
|
-
return (
|
|
1526
|
+
return isLeapYear(year);
|
|
1333
1527
|
}
|
|
1334
1528
|
/**
|
|
1335
1529
|
* Number of months in this Hebrew year (either 12 or 13 depending on leap year)
|
|
@@ -1339,7 +1533,7 @@ class HDate {
|
|
|
1339
1533
|
|
|
1340
1534
|
|
|
1341
1535
|
static monthsInYear(year) {
|
|
1342
|
-
return
|
|
1536
|
+
return monthsInYear(year);
|
|
1343
1537
|
}
|
|
1344
1538
|
/**
|
|
1345
1539
|
* Number of days in Hebrew month in a given year (29 or 30)
|
|
@@ -1350,11 +1544,7 @@ class HDate {
|
|
|
1350
1544
|
|
|
1351
1545
|
|
|
1352
1546
|
static daysInMonth(month, year) {
|
|
1353
|
-
|
|
1354
|
-
return 29;
|
|
1355
|
-
} else {
|
|
1356
|
-
return 30;
|
|
1357
|
-
}
|
|
1547
|
+
return daysInMonth(month, year);
|
|
1358
1548
|
}
|
|
1359
1549
|
/**
|
|
1360
1550
|
* Returns a transliterated string name of Hebrew month in year,
|
|
@@ -1366,11 +1556,7 @@ class HDate {
|
|
|
1366
1556
|
|
|
1367
1557
|
|
|
1368
1558
|
static getMonthName(month, year) {
|
|
1369
|
-
|
|
1370
|
-
throw new TypeError(`bad month argument ${month}`);
|
|
1371
|
-
}
|
|
1372
|
-
|
|
1373
|
-
return monthNames[+HDate.isLeapYear(year)][month];
|
|
1559
|
+
return getMonthName(month, year);
|
|
1374
1560
|
}
|
|
1375
1561
|
/**
|
|
1376
1562
|
* Returns the Hebrew month number (NISAN=1, TISHREI=7)
|
|
@@ -1384,40 +1570,6 @@ class HDate {
|
|
|
1384
1570
|
/* number */
|
|
1385
1571
|
parseInt(month, 10) : HDate.monthFromName(month);
|
|
1386
1572
|
}
|
|
1387
|
-
/**
|
|
1388
|
-
* Days from sunday prior to start of Hebrew calendar to mean
|
|
1389
|
-
* conjunction of Tishrei in Hebrew YEAR
|
|
1390
|
-
* @param {number} year Hebrew year
|
|
1391
|
-
* @return {number}
|
|
1392
|
-
*/
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
static elapsedDays(year) {
|
|
1396
|
-
const elapsed = edCache[year] = edCache[year] || HDate.elapsedDays0(year);
|
|
1397
|
-
return elapsed;
|
|
1398
|
-
}
|
|
1399
|
-
/**
|
|
1400
|
-
* Days from sunday prior to start of Hebrew calendar to mean
|
|
1401
|
-
* conjunction of Tishrei in Hebrew YEAR
|
|
1402
|
-
* @private
|
|
1403
|
-
* @param {number} year Hebrew year
|
|
1404
|
-
* @return {number}
|
|
1405
|
-
*/
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
static elapsedDays0(year) {
|
|
1409
|
-
const prevYear = year - 1;
|
|
1410
|
-
const mElapsed = 235 * Math.floor(prevYear / 19) + // Months in complete 19 year lunar (Metonic) cycles so far
|
|
1411
|
-
12 * (prevYear % 19) + // Regular months in this cycle
|
|
1412
|
-
Math.floor((prevYear % 19 * 7 + 1) / 19); // Leap months this cycle
|
|
1413
|
-
|
|
1414
|
-
const pElapsed = 204 + 793 * (mElapsed % 1080);
|
|
1415
|
-
const hElapsed = 5 + 12 * mElapsed + 793 * Math.floor(mElapsed / 1080) + Math.floor(pElapsed / 1080);
|
|
1416
|
-
const parts = pElapsed % 1080 + 1080 * (hElapsed % 24);
|
|
1417
|
-
const day = 1 + 29 * mElapsed + Math.floor(hElapsed / 24);
|
|
1418
|
-
const altDay = day + (parts >= 19440 || 2 == day % 7 && parts >= 9924 && !HDate.isLeapYear(year) || 1 == day % 7 && parts >= 16789 && HDate.isLeapYear(prevYear));
|
|
1419
|
-
return altDay + (altDay % 7 === 0 || altDay % 7 == 3 || altDay % 7 == 5);
|
|
1420
|
-
}
|
|
1421
1573
|
/**
|
|
1422
1574
|
* Number of days in the hebrew YEAR
|
|
1423
1575
|
* @param {number} year Hebrew year
|
|
@@ -1426,7 +1578,7 @@ class HDate {
|
|
|
1426
1578
|
|
|
1427
1579
|
|
|
1428
1580
|
static daysInYear(year) {
|
|
1429
|
-
return
|
|
1581
|
+
return daysInYear(year);
|
|
1430
1582
|
}
|
|
1431
1583
|
/**
|
|
1432
1584
|
* true if Cheshvan is long in Hebrew year
|
|
@@ -1436,7 +1588,7 @@ class HDate {
|
|
|
1436
1588
|
|
|
1437
1589
|
|
|
1438
1590
|
static longCheshvan(year) {
|
|
1439
|
-
return
|
|
1591
|
+
return longCheshvan(year);
|
|
1440
1592
|
}
|
|
1441
1593
|
/**
|
|
1442
1594
|
* true if Kislev is short in Hebrew year
|
|
@@ -1446,7 +1598,7 @@ class HDate {
|
|
|
1446
1598
|
|
|
1447
1599
|
|
|
1448
1600
|
static shortKislev(year) {
|
|
1449
|
-
return
|
|
1601
|
+
return shortKislev(year);
|
|
1450
1602
|
}
|
|
1451
1603
|
/**
|
|
1452
1604
|
* Converts Hebrew month string name to numeric
|
|
@@ -1488,41 +1640,41 @@ class HDate {
|
|
|
1488
1640
|
/* this catches "november" */
|
|
1489
1641
|
}
|
|
1490
1642
|
|
|
1491
|
-
return NISAN
|
|
1643
|
+
return months.NISAN;
|
|
1492
1644
|
|
|
1493
1645
|
case 'i':
|
|
1494
|
-
return IYYAR
|
|
1646
|
+
return months.IYYAR;
|
|
1495
1647
|
|
|
1496
1648
|
case 'e':
|
|
1497
|
-
return ELUL
|
|
1649
|
+
return months.ELUL;
|
|
1498
1650
|
|
|
1499
1651
|
case 'c':
|
|
1500
1652
|
case 'ח':
|
|
1501
|
-
return CHESHVAN
|
|
1653
|
+
return months.CHESHVAN;
|
|
1502
1654
|
|
|
1503
1655
|
case 'k':
|
|
1504
1656
|
case 'כ':
|
|
1505
|
-
return KISLEV
|
|
1657
|
+
return months.KISLEV;
|
|
1506
1658
|
|
|
1507
1659
|
case 's':
|
|
1508
1660
|
switch (c[1]) {
|
|
1509
1661
|
case 'i':
|
|
1510
|
-
return SIVAN
|
|
1662
|
+
return months.SIVAN;
|
|
1511
1663
|
|
|
1512
1664
|
case 'h':
|
|
1513
|
-
return SHVAT
|
|
1665
|
+
return months.SHVAT;
|
|
1514
1666
|
}
|
|
1515
1667
|
|
|
1516
1668
|
case 't':
|
|
1517
1669
|
switch (c[1]) {
|
|
1518
1670
|
case 'a':
|
|
1519
|
-
return TAMUZ
|
|
1671
|
+
return months.TAMUZ;
|
|
1520
1672
|
|
|
1521
1673
|
case 'i':
|
|
1522
|
-
return TISHREI
|
|
1674
|
+
return months.TISHREI;
|
|
1523
1675
|
|
|
1524
1676
|
case 'e':
|
|
1525
|
-
return TEVET
|
|
1677
|
+
return months.TEVET;
|
|
1526
1678
|
}
|
|
1527
1679
|
|
|
1528
1680
|
break;
|
|
@@ -1530,46 +1682,46 @@ class HDate {
|
|
|
1530
1682
|
case 'a':
|
|
1531
1683
|
switch (c[1]) {
|
|
1532
1684
|
case 'v':
|
|
1533
|
-
return AV
|
|
1685
|
+
return months.AV;
|
|
1534
1686
|
|
|
1535
1687
|
case 'd':
|
|
1536
1688
|
if (/(1|[^i]i|a|א)$/i.test(monthName)) {
|
|
1537
|
-
return ADAR_I
|
|
1689
|
+
return months.ADAR_I;
|
|
1538
1690
|
}
|
|
1539
1691
|
|
|
1540
|
-
return ADAR_II
|
|
1692
|
+
return months.ADAR_II;
|
|
1541
1693
|
// else assume sheini
|
|
1542
1694
|
}
|
|
1543
1695
|
|
|
1544
1696
|
break;
|
|
1545
1697
|
|
|
1546
1698
|
case 'ס':
|
|
1547
|
-
return SIVAN
|
|
1699
|
+
return months.SIVAN;
|
|
1548
1700
|
|
|
1549
1701
|
case 'ט':
|
|
1550
|
-
return TEVET
|
|
1702
|
+
return months.TEVET;
|
|
1551
1703
|
|
|
1552
1704
|
case 'ש':
|
|
1553
|
-
return SHVAT
|
|
1705
|
+
return months.SHVAT;
|
|
1554
1706
|
|
|
1555
1707
|
case 'א':
|
|
1556
1708
|
switch (c[1]) {
|
|
1557
1709
|
case 'ב':
|
|
1558
|
-
return AV
|
|
1710
|
+
return months.AV;
|
|
1559
1711
|
|
|
1560
1712
|
case 'ד':
|
|
1561
1713
|
if (/(1|[^i]i|a|א)$/i.test(monthName)) {
|
|
1562
|
-
return ADAR_I
|
|
1714
|
+
return months.ADAR_I;
|
|
1563
1715
|
}
|
|
1564
1716
|
|
|
1565
|
-
return ADAR_II
|
|
1717
|
+
return months.ADAR_II;
|
|
1566
1718
|
// else assume sheini
|
|
1567
1719
|
|
|
1568
1720
|
case 'י':
|
|
1569
|
-
return IYYAR
|
|
1721
|
+
return months.IYYAR;
|
|
1570
1722
|
|
|
1571
1723
|
case 'ל':
|
|
1572
|
-
return ELUL
|
|
1724
|
+
return months.ELUL;
|
|
1573
1725
|
}
|
|
1574
1726
|
|
|
1575
1727
|
break;
|
|
@@ -1577,10 +1729,10 @@ class HDate {
|
|
|
1577
1729
|
case 'ת':
|
|
1578
1730
|
switch (c[1]) {
|
|
1579
1731
|
case 'מ':
|
|
1580
|
-
return TAMUZ
|
|
1732
|
+
return months.TAMUZ;
|
|
1581
1733
|
|
|
1582
1734
|
case 'ש':
|
|
1583
|
-
return TISHREI
|
|
1735
|
+
return months.TISHREI;
|
|
1584
1736
|
}
|
|
1585
1737
|
|
|
1586
1738
|
break;
|
|
@@ -1631,21 +1783,21 @@ function fix(date) {
|
|
|
1631
1783
|
|
|
1632
1784
|
function fixDate(date) {
|
|
1633
1785
|
if (date.day < 1) {
|
|
1634
|
-
if (date.month == TISHREI
|
|
1786
|
+
if (date.month == months.TISHREI) {
|
|
1635
1787
|
date.year -= 1;
|
|
1636
1788
|
}
|
|
1637
1789
|
|
|
1638
|
-
date.day +=
|
|
1790
|
+
date.day += daysInMonth(date.month, date.year);
|
|
1639
1791
|
date.month -= 1;
|
|
1640
1792
|
fix(date);
|
|
1641
1793
|
}
|
|
1642
1794
|
|
|
1643
|
-
if (date.day >
|
|
1644
|
-
if (date.month
|
|
1795
|
+
if (date.day > daysInMonth(date.month, date.year)) {
|
|
1796
|
+
if (date.month === months.ELUL) {
|
|
1645
1797
|
date.year += 1;
|
|
1646
1798
|
}
|
|
1647
1799
|
|
|
1648
|
-
date.day -=
|
|
1800
|
+
date.day -= daysInMonth(date.month, date.year);
|
|
1649
1801
|
date.month += 1;
|
|
1650
1802
|
fix(date);
|
|
1651
1803
|
}
|
|
@@ -1659,16 +1811,16 @@ function fixDate(date) {
|
|
|
1659
1811
|
|
|
1660
1812
|
|
|
1661
1813
|
function fixMonth(date) {
|
|
1662
|
-
if (date.month
|
|
1814
|
+
if (date.month === months.ADAR_II && !date.isLeapYear()) {
|
|
1663
1815
|
date.month -= 1; // to Adar I
|
|
1664
1816
|
|
|
1665
1817
|
fix(date);
|
|
1666
1818
|
} else if (date.month < 1) {
|
|
1667
|
-
date.month +=
|
|
1819
|
+
date.month += monthsInYear(date.year);
|
|
1668
1820
|
date.year -= 1;
|
|
1669
1821
|
fix(date);
|
|
1670
|
-
} else if (date.month >
|
|
1671
|
-
date.month -=
|
|
1822
|
+
} else if (date.month > monthsInYear(date.year)) {
|
|
1823
|
+
date.month -= monthsInYear(date.year);
|
|
1672
1824
|
date.year += 1;
|
|
1673
1825
|
fix(date);
|
|
1674
1826
|
}
|
|
@@ -3634,7 +3786,6 @@ class OmerEvent extends Event {
|
|
|
3634
3786
|
|
|
3635
3787
|
this.weekNumber = Math.floor((omerDay - 1) / 7) + 1;
|
|
3636
3788
|
this.daysWithinWeeks = omerDay % 7 || 7;
|
|
3637
|
-
this.memo = [this.sefira('en'), this.sefira('he'), this.sefira('translit')].join('\n');
|
|
3638
3789
|
}
|
|
3639
3790
|
/**
|
|
3640
3791
|
* @param {string} lang
|
|
@@ -3650,7 +3801,7 @@ class OmerEvent extends Event {
|
|
|
3650
3801
|
case 'he':
|
|
3651
3802
|
const heWeek = Locale.gettext(week, 'he');
|
|
3652
3803
|
const heDayWithinWeek = Locale.gettext(dayWithinWeek, 'he');
|
|
3653
|
-
const hePrefix = this.weekNumber === 2 || this.weekNumber === 6 ? '
|
|
3804
|
+
const hePrefix = this.weekNumber === 2 || this.weekNumber === 6 ? 'שֶׁבִּ' : 'שֶׁבְּ';
|
|
3654
3805
|
return `${heDayWithinWeek} ${hePrefix}${heWeek}`.normalize();
|
|
3655
3806
|
|
|
3656
3807
|
case 'translit':
|
|
@@ -3755,7 +3906,7 @@ class OmerEvent extends Event {
|
|
|
3755
3906
|
// https://github.com/py-libhdate/py-libhdate/blob/master/hdate/date.py
|
|
3756
3907
|
|
|
3757
3908
|
const tens = ['', 'עֲשָׂרָה', 'עֶשְׂרִים', 'שְׁלוֹשִׁים', 'אַרְבָּעִים'];
|
|
3758
|
-
const ones = ['', 'אֶחָד', '
|
|
3909
|
+
const ones = ['', 'אֶחָד', 'שְׁנַיִם', 'שְׁלוֹשָׁה', 'אַרְבָּעָה', 'חֲמִשָׁה', 'שִׁשָׁה', 'שִׁבְעָה', 'שְׁמוֹנָה', 'תִּשְׁעָה'];
|
|
3759
3910
|
const shnei = 'שְׁנֵי';
|
|
3760
3911
|
const yamim = 'יָמִים';
|
|
3761
3912
|
const shneiYamim = shnei + ' ' + yamim;
|
|
@@ -3803,7 +3954,7 @@ function getTodayIsHe(omer) {
|
|
|
3803
3954
|
if (omer > 6) {
|
|
3804
3955
|
str = str.trim(); // remove trailing space before comma
|
|
3805
3956
|
|
|
3806
|
-
str += ',
|
|
3957
|
+
str += ', שְׁהֵם ';
|
|
3807
3958
|
const weeks = Math.floor(omer / 7);
|
|
3808
3959
|
const days = omer % 7;
|
|
3809
3960
|
|
|
@@ -3831,7 +3982,7 @@ function getTodayIsHe(omer) {
|
|
|
3831
3982
|
}
|
|
3832
3983
|
|
|
3833
3984
|
str += 'לָעוֹמֶר';
|
|
3834
|
-
return str;
|
|
3985
|
+
return str.normalize();
|
|
3835
3986
|
}
|
|
3836
3987
|
|
|
3837
3988
|
/* eslint-disable no-multi-spaces */
|
|
@@ -5297,18 +5448,18 @@ function getYahrzeit_(hyear, gdate) {
|
|
|
5297
5448
|
return undefined;
|
|
5298
5449
|
}
|
|
5299
5450
|
|
|
5300
|
-
if (hDeath.mm == CHESHVAN && hDeath.dd == 30 && !
|
|
5451
|
+
if (hDeath.mm == CHESHVAN && hDeath.dd == 30 && !longCheshvan(hDeath.yy + 1)) {
|
|
5301
5452
|
// If it's Heshvan 30 it depends on the first anniversary;
|
|
5302
5453
|
// if that was not Heshvan 30, use the day before Kislev 1.
|
|
5303
|
-
hDeath =
|
|
5304
|
-
} else if (hDeath.mm == KISLEV && hDeath.dd == 30 &&
|
|
5454
|
+
hDeath = abs2hebrew(hebrew2abs(hyear, KISLEV, 1) - 1);
|
|
5455
|
+
} else if (hDeath.mm == KISLEV && hDeath.dd == 30 && shortKislev(hDeath.yy + 1)) {
|
|
5305
5456
|
// If it's Kislev 30 it depends on the first anniversary;
|
|
5306
5457
|
// if that was not Kislev 30, use the day before Teveth 1.
|
|
5307
|
-
hDeath =
|
|
5458
|
+
hDeath = abs2hebrew(hebrew2abs(hyear, TEVET, 1) - 1);
|
|
5308
5459
|
} else if (hDeath.mm == ADAR_II) {
|
|
5309
5460
|
// If it's Adar II, use the same day in last month of year (Adar or Adar II).
|
|
5310
|
-
hDeath.mm =
|
|
5311
|
-
} else if (hDeath.mm == ADAR_I && hDeath.dd == 30 && !
|
|
5461
|
+
hDeath.mm = monthsInYear(hyear);
|
|
5462
|
+
} else if (hDeath.mm == ADAR_I && hDeath.dd == 30 && !isLeapYear(hyear)) {
|
|
5312
5463
|
// If it's the 30th in Adar I and year is not a leap year
|
|
5313
5464
|
// (so Adar has only 29 days), use the last day in Shevat.
|
|
5314
5465
|
hDeath.dd = 30;
|
|
@@ -5317,10 +5468,10 @@ function getYahrzeit_(hyear, gdate) {
|
|
|
5317
5468
|
// advance day to rosh chodesh if needed
|
|
5318
5469
|
|
|
5319
5470
|
|
|
5320
|
-
if (hDeath.mm == CHESHVAN && hDeath.dd == 30 && !
|
|
5471
|
+
if (hDeath.mm == CHESHVAN && hDeath.dd == 30 && !longCheshvan(hyear)) {
|
|
5321
5472
|
hDeath.mm = KISLEV;
|
|
5322
5473
|
hDeath.dd = 1;
|
|
5323
|
-
} else if (hDeath.mm == KISLEV && hDeath.dd == 30 &&
|
|
5474
|
+
} else if (hDeath.mm == KISLEV && hDeath.dd == 30 && shortKislev(hyear)) {
|
|
5324
5475
|
hDeath.mm = TEVET;
|
|
5325
5476
|
hDeath.dd = 1;
|
|
5326
5477
|
}
|
|
@@ -5343,19 +5494,19 @@ function getBirthdayOrAnniversary_(hyear, gdate) {
|
|
|
5343
5494
|
return undefined;
|
|
5344
5495
|
}
|
|
5345
5496
|
|
|
5346
|
-
const isOrigLeap =
|
|
5497
|
+
const isOrigLeap = isLeapYear(origYear);
|
|
5347
5498
|
let month = orig.getMonth();
|
|
5348
5499
|
let day = orig.getDate();
|
|
5349
5500
|
|
|
5350
5501
|
if (month == ADAR_I && !isOrigLeap || month == ADAR_II && isOrigLeap) {
|
|
5351
|
-
month =
|
|
5352
|
-
} else if (month == CHESHVAN && day == 30 && !
|
|
5502
|
+
month = monthsInYear(hyear);
|
|
5503
|
+
} else if (month == CHESHVAN && day == 30 && !longCheshvan(hyear)) {
|
|
5353
5504
|
month = KISLEV;
|
|
5354
5505
|
day = 1;
|
|
5355
|
-
} else if (month == KISLEV && day == 30 &&
|
|
5506
|
+
} else if (month == KISLEV && day == 30 && shortKislev(hyear)) {
|
|
5356
5507
|
month = TEVET;
|
|
5357
5508
|
day = 1;
|
|
5358
|
-
} else if (month == ADAR_I && day == 30 && isOrigLeap && !
|
|
5509
|
+
} else if (month == ADAR_I && day == 30 && isOrigLeap && !isLeapYear(hyear)) {
|
|
5359
5510
|
month = NISAN$1;
|
|
5360
5511
|
day = 1;
|
|
5361
5512
|
}
|
|
@@ -5363,7 +5514,7 @@ function getBirthdayOrAnniversary_(hyear, gdate) {
|
|
|
5363
5514
|
return new HDate(day, month, hyear);
|
|
5364
5515
|
}
|
|
5365
5516
|
|
|
5366
|
-
var version="3.
|
|
5517
|
+
var version="3.38.0";
|
|
5367
5518
|
|
|
5368
5519
|
var headers$1={"plural-forms":"nplurals=2; plural=(n > 1);",language:"en_CA@ashkenazi"};var contexts$1={"":{Berachot:["Berachos"],Shabbat:["Shabbos"],Taanit:["Taanis"],Yevamot:["Yevamos"],Ketubot:["Kesubos"],"Baba Batra":["Baba Basra"],Makkot:["Makkos"],Shevuot:["Shevuos"],Horayot:["Horayos"],Menachot:["Menachos"],Bechorot:["Bechoros"],Keritot:["Kerisos"],Midot:["Midos"],"Achrei Mot":["Achrei Mos"],Bechukotai:["Bechukosai"],"Beha'alotcha":["Beha'aloscha"],Bereshit:["Bereshis"],Chukat:["Chukas"],"Erev Shavuot":["Erev Shavuos"],"Erev Sukkot":["Erev Sukkos"],"Ki Tavo":["Ki Savo"],"Ki Teitzei":["Ki Seitzei"],"Ki Tisa":["Ki Sisa"],Matot:["Matos"],"Purim Katan":["Purim Koton"],Tazria:["Sazria"],"Shabbat Chazon":["Shabbos Chazon"],"Shabbat HaChodesh":["Shabbos HaChodesh"],"Shabbat HaGadol":["Shabbos HaGadol"],"Shabbat Nachamu":["Shabbos Nachamu"],"Shabbat Parah":["Shabbos Parah"],"Shabbat Shekalim":["Shabbos Shekalim"],"Shabbat Shuva":["Shabbos Shuvah"],"Shabbat Zachor":["Shabbos Zachor"],Shavuot:["Shavuos"],"Shavuot I":["Shavuos I"],"Shavuot II":["Shavuos II"],Shemot:["Shemos"],"Shmini Atzeret":["Shmini Atzeres"],"Simchat Torah":["Simchas Torah"],Sukkot:["Sukkos"],"Sukkot I":["Sukkos I"],"Sukkot II":["Sukkos II"],"Sukkot II (CH''M)":["Sukkos II (CH''M)"],"Sukkot III (CH''M)":["Sukkos III (CH''M)"],"Sukkot IV (CH''M)":["Sukkos IV (CH''M)"],"Sukkot V (CH''M)":["Sukkos V (CH''M)"],"Sukkot VI (CH''M)":["Sukkos VI (CH''M)"],"Sukkot VII (Hoshana Raba)":["Sukkos VII (Hoshana Raba)"],"Ta'anit Bechorot":["Ta'anis Bechoros"],"Ta'anit Esther":["Ta'anis Esther"],Toldot:["Toldos"],Vaetchanan:["Vaeschanan"],Yitro:["Yisro"],"Vezot Haberakhah":["Vezos Haberakhah"],Parashat:["Parshas"],"Leil Selichot":["Leil Selichos"],"Shabbat Mevarchim Chodesh":["Shabbos Mevorchim Chodesh"],"Shabbat Shirah":["Shabbos Shirah"],Tevet:["Teves"],"Asara B'Tevet":["Asara B'Teves"],Berakhot:["Berakhos"],Sheviit:["Sheviis"],Terumot:["Terumos"],Maasrot:["Maasros"],Eduyot:["Eduyos"],Avot:["Avos"],Bekhorot:["Bekhoros"],Middot:["Middos"],Oholot:["Oholos"],Tahorot:["Tahoros"],Mikvaot:["Mikvaos"]}};var poAshkenazi = {headers:headers$1,contexts:contexts$1};
|
|
5369
5520
|
|