@hebcal/core 3.37.2 → 3.38.2
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 -1148
- 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 -368
- package/dist/index.mjs +530 -368
- package/package.json +9 -9
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! @hebcal/core v3.
|
|
1
|
+
/*! @hebcal/core v3.38.2 */
|
|
2
2
|
'use strict';
|
|
3
3
|
|
|
4
4
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
@@ -19,26 +19,15 @@ function _defineProperty(obj, key, value) {
|
|
|
19
19
|
}
|
|
20
20
|
|
|
21
21
|
/*
|
|
22
|
-
|
|
23
|
-
|
|
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.
|
|
22
|
+
* More minimal greg routines
|
|
23
|
+
*/
|
|
32
24
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
GNU General Public License for more details.
|
|
25
|
+
/** @private */
|
|
26
|
+
const lengths = [0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
|
|
27
|
+
/** @private */
|
|
37
28
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
*/
|
|
41
|
-
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]];
|
|
29
|
+
const monthLengths = [lengths, lengths.slice()];
|
|
30
|
+
monthLengths[1][2] = 29;
|
|
42
31
|
/**
|
|
43
32
|
* @private
|
|
44
33
|
* @param {number} x
|
|
@@ -60,9 +49,148 @@ function quotient(x, y) {
|
|
|
60
49
|
return Math.floor(x / y);
|
|
61
50
|
}
|
|
62
51
|
/**
|
|
63
|
-
* Gregorian
|
|
52
|
+
* Returns true if the Gregorian year is a leap year
|
|
53
|
+
* @private
|
|
54
|
+
* @param {number} year Gregorian year
|
|
55
|
+
* @return {boolean}
|
|
56
|
+
*/
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
function isLeapYear$1(year) {
|
|
60
|
+
return !(year % 4) && (!!(year % 100) || !(year % 400));
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Number of days in the Gregorian month for given year
|
|
64
|
+
* @private
|
|
65
|
+
* @param {number} month Gregorian month (1=January, 12=December)
|
|
66
|
+
* @param {number} year Gregorian year
|
|
67
|
+
* @return {number}
|
|
68
|
+
*/
|
|
69
|
+
|
|
70
|
+
function daysInMonth$1(month, year) {
|
|
71
|
+
// 1 based months
|
|
72
|
+
return monthLengths[+isLeapYear$1(year)][month];
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Returns true if the object is a Javascript Date
|
|
76
|
+
* @private
|
|
77
|
+
* @param {Object} obj
|
|
78
|
+
* @return {boolean}
|
|
64
79
|
*/
|
|
65
80
|
|
|
81
|
+
function isDate(obj) {
|
|
82
|
+
return typeof obj === 'object' && Date.prototype === obj.__proto__;
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Returns number of days since January 1 of that year
|
|
86
|
+
* @private
|
|
87
|
+
* @param {Date} date Gregorian date
|
|
88
|
+
* @return {number}
|
|
89
|
+
*/
|
|
90
|
+
|
|
91
|
+
function dayOfYear(date) {
|
|
92
|
+
if (!isDate(date)) {
|
|
93
|
+
throw new TypeError(`Argument not a Date: ${date}`);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
let doy = date.getDate() + 31 * date.getMonth();
|
|
97
|
+
|
|
98
|
+
if (date.getMonth() > 1) {
|
|
99
|
+
// FEB
|
|
100
|
+
doy -= Math.floor((4 * (date.getMonth() + 1) + 23) / 10);
|
|
101
|
+
|
|
102
|
+
if (isLeapYear$1(date.getFullYear())) {
|
|
103
|
+
doy++;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
return doy;
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Converts Gregorian date to absolute R.D. (Rata Die) days
|
|
111
|
+
* @private
|
|
112
|
+
* @param {Date} date Gregorian date
|
|
113
|
+
* @return {number}
|
|
114
|
+
*/
|
|
115
|
+
|
|
116
|
+
function greg2abs(date) {
|
|
117
|
+
if (!isDate(date)) {
|
|
118
|
+
throw new TypeError(`Argument not a Date: ${date}`);
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
const year = date.getFullYear() - 1;
|
|
122
|
+
return dayOfYear(date) + // days this year
|
|
123
|
+
365 * year + ( // + days in prior years
|
|
124
|
+
Math.floor(year / 4) - // + Julian Leap years
|
|
125
|
+
Math.floor(year / 100) + // - century years
|
|
126
|
+
Math.floor(year / 400)); // + Gregorian leap years
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* @private
|
|
130
|
+
* @param {number} abs - R.D. number of days
|
|
131
|
+
* @return {number}
|
|
132
|
+
*/
|
|
133
|
+
|
|
134
|
+
function yearFromFixed(abs) {
|
|
135
|
+
const l0 = abs - 1;
|
|
136
|
+
const n400 = quotient(l0, 146097);
|
|
137
|
+
const d1 = mod(l0, 146097);
|
|
138
|
+
const n100 = quotient(d1, 36524);
|
|
139
|
+
const d2 = mod(d1, 36524);
|
|
140
|
+
const n4 = quotient(d2, 1461);
|
|
141
|
+
const d3 = mod(d2, 1461);
|
|
142
|
+
const n1 = quotient(d3, 365);
|
|
143
|
+
const year = 400 * n400 + 100 * n100 + 4 * n4 + n1;
|
|
144
|
+
return n100 != 4 && n1 != 4 ? year + 1 : year;
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* @private
|
|
148
|
+
* @param {number} year
|
|
149
|
+
* @param {number} month
|
|
150
|
+
* @param {number} day
|
|
151
|
+
* @return {number}
|
|
152
|
+
*/
|
|
153
|
+
|
|
154
|
+
|
|
155
|
+
function toFixed(year, month, day) {
|
|
156
|
+
const py = year - 1;
|
|
157
|
+
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;
|
|
158
|
+
}
|
|
159
|
+
/**
|
|
160
|
+
* Converts from Rata Die (R.D. number) to Gregorian date.
|
|
161
|
+
* See the footnote on page 384 of ``Calendrical Calculations, Part II:
|
|
162
|
+
* Three Historical Calendars'' by E. M. Reingold, N. Dershowitz, and S. M.
|
|
163
|
+
* Clamen, Software--Practice and Experience, Volume 23, Number 4
|
|
164
|
+
* (April, 1993), pages 383-404 for an explanation.
|
|
165
|
+
* @private
|
|
166
|
+
* @param {number} abs - R.D. number of days
|
|
167
|
+
* @return {Date}
|
|
168
|
+
*/
|
|
169
|
+
|
|
170
|
+
|
|
171
|
+
function abs2greg(abs) {
|
|
172
|
+
if (typeof abs !== 'number') {
|
|
173
|
+
throw new TypeError(`Argument not a Number: ${abs}`);
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
abs = Math.trunc(abs);
|
|
177
|
+
const year = yearFromFixed(abs);
|
|
178
|
+
const priorDays = abs - toFixed(year, 1, 1);
|
|
179
|
+
const correction = abs < toFixed(year, 3, 1) ? 0 : isLeapYear$1(year) ? 1 : 2;
|
|
180
|
+
const month = quotient(12 * (priorDays + correction) + 373, 367);
|
|
181
|
+
const day = abs - toFixed(year, month, 1) + 1;
|
|
182
|
+
const dt = new Date(year, month - 1, day);
|
|
183
|
+
|
|
184
|
+
if (year < 100 && year >= 0) {
|
|
185
|
+
dt.setFullYear(year);
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
return dt;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
/**
|
|
192
|
+
* Gregorian date helper functions.
|
|
193
|
+
*/
|
|
66
194
|
|
|
67
195
|
class greg {
|
|
68
196
|
/**
|
|
@@ -77,7 +205,7 @@ class greg {
|
|
|
77
205
|
* @return {boolean}
|
|
78
206
|
*/
|
|
79
207
|
static isLeapYear(year) {
|
|
80
|
-
return
|
|
208
|
+
return isLeapYear$1(year);
|
|
81
209
|
}
|
|
82
210
|
/**
|
|
83
211
|
* Number of days in the Gregorian month for given year
|
|
@@ -88,8 +216,7 @@ class greg {
|
|
|
88
216
|
|
|
89
217
|
|
|
90
218
|
static daysInMonth(month, year) {
|
|
91
|
-
|
|
92
|
-
return monthLengths[+this.isLeapYear(year)][month];
|
|
219
|
+
return daysInMonth$1(month, year);
|
|
93
220
|
}
|
|
94
221
|
/**
|
|
95
222
|
* Returns true if the object is a Javascript Date
|
|
@@ -99,7 +226,7 @@ class greg {
|
|
|
99
226
|
|
|
100
227
|
|
|
101
228
|
static isDate(obj) {
|
|
102
|
-
return
|
|
229
|
+
return isDate(obj);
|
|
103
230
|
}
|
|
104
231
|
/**
|
|
105
232
|
* Returns number of days since January 1 of that year
|
|
@@ -109,22 +236,7 @@ class greg {
|
|
|
109
236
|
|
|
110
237
|
|
|
111
238
|
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;
|
|
239
|
+
return dayOfYear(date);
|
|
128
240
|
}
|
|
129
241
|
/**
|
|
130
242
|
* Converts Gregorian date to absolute R.D. (Rata Die) days
|
|
@@ -134,48 +246,7 @@ class greg {
|
|
|
134
246
|
|
|
135
247
|
|
|
136
248
|
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;
|
|
249
|
+
return greg2abs(date);
|
|
179
250
|
}
|
|
180
251
|
/**
|
|
181
252
|
* Converts from Rata Die (R.D. number) to Gregorian date.
|
|
@@ -189,23 +260,7 @@ class greg {
|
|
|
189
260
|
|
|
190
261
|
|
|
191
262
|
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;
|
|
263
|
+
return abs2greg(theDate);
|
|
209
264
|
}
|
|
210
265
|
|
|
211
266
|
}
|
|
@@ -569,36 +624,19 @@ Locale.addLocale('', noopLocale);
|
|
|
569
624
|
Locale.useLocale('en');
|
|
570
625
|
|
|
571
626
|
/*
|
|
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/>.
|
|
627
|
+
* More minimal HDate
|
|
590
628
|
*/
|
|
591
629
|
const NISAN$3 = 1;
|
|
592
|
-
const IYYAR$1 = 2;
|
|
593
|
-
|
|
594
|
-
const TAMUZ$1 = 4;
|
|
595
|
-
|
|
630
|
+
const IYYAR$1 = 2; // const SIVAN = 3;
|
|
631
|
+
|
|
632
|
+
const TAMUZ$1 = 4; // const AV = 5;
|
|
633
|
+
|
|
596
634
|
const ELUL$2 = 6;
|
|
597
635
|
const TISHREI$2 = 7;
|
|
598
636
|
const CHESHVAN$2 = 8;
|
|
599
637
|
const KISLEV$2 = 9;
|
|
600
|
-
const TEVET$2 = 10;
|
|
601
|
-
|
|
638
|
+
const TEVET$2 = 10; // const SHVAT = 11;
|
|
639
|
+
|
|
602
640
|
const ADAR_I$2 = 12;
|
|
603
641
|
const ADAR_II$2 = 13;
|
|
604
642
|
/**
|
|
@@ -654,16 +692,237 @@ const monthNames0 = ['', 'Nisan', 'Iyyar', 'Sivan', 'Tamuz', 'Av', 'Elul', 'Tish
|
|
|
654
692
|
* @private
|
|
655
693
|
*/
|
|
656
694
|
|
|
657
|
-
const monthNames = [monthNames0.concat(['Adar', 'Nisan']), monthNames0.concat(['Adar I', 'Adar II', 'Nisan'])];
|
|
695
|
+
const monthNames = [monthNames0.concat(['Adar', 'Nisan']), monthNames0.concat(['Adar I', 'Adar II', 'Nisan'])];
|
|
696
|
+
const edCache = Object.create(null);
|
|
697
|
+
const EPOCH = -1373428; // Avg year length in the cycle (19 solar years with 235 lunar months)
|
|
698
|
+
|
|
699
|
+
const AVG_HEBYEAR_DAYS = 365.24682220597794;
|
|
700
|
+
/**
|
|
701
|
+
* Converts Hebrew date to R.D. (Rata Die) fixed days.
|
|
702
|
+
* R.D. 1 is the imaginary date Monday, January 1, 1 on the Gregorian
|
|
703
|
+
* Calendar.
|
|
704
|
+
* @private
|
|
705
|
+
* @param {number} year Hebrew year
|
|
706
|
+
* @param {number} month Hebrew month
|
|
707
|
+
* @param {number} day Hebrew date (1-30)
|
|
708
|
+
* @return {number}
|
|
709
|
+
*/
|
|
710
|
+
|
|
711
|
+
function hebrew2abs(year, month, day) {
|
|
712
|
+
let tempabs = day;
|
|
713
|
+
|
|
714
|
+
if (month < TISHREI$2) {
|
|
715
|
+
for (let m = TISHREI$2; m <= monthsInYear(year); m++) {
|
|
716
|
+
tempabs += daysInMonth(m, year);
|
|
717
|
+
}
|
|
718
|
+
|
|
719
|
+
for (let m = NISAN$3; m < month; m++) {
|
|
720
|
+
tempabs += daysInMonth(m, year);
|
|
721
|
+
}
|
|
722
|
+
} else {
|
|
723
|
+
for (let m = TISHREI$2; m < month; m++) {
|
|
724
|
+
tempabs += daysInMonth(m, year);
|
|
725
|
+
}
|
|
726
|
+
}
|
|
727
|
+
|
|
728
|
+
return EPOCH + elapsedDays(year) + tempabs - 1;
|
|
729
|
+
}
|
|
730
|
+
/**
|
|
731
|
+
* @private
|
|
732
|
+
* @param {number} year
|
|
733
|
+
* @return {number}
|
|
734
|
+
*/
|
|
735
|
+
|
|
736
|
+
function newYear(year) {
|
|
737
|
+
return EPOCH + elapsedDays(year);
|
|
738
|
+
}
|
|
739
|
+
/**
|
|
740
|
+
* Converts absolute R.D. days to Hebrew date
|
|
741
|
+
* @private
|
|
742
|
+
* @param {number} abs absolute R.D. days
|
|
743
|
+
* @return {SimpleHebrewDate}
|
|
744
|
+
*/
|
|
745
|
+
|
|
746
|
+
|
|
747
|
+
function abs2hebrew(abs) {
|
|
748
|
+
if (typeof abs !== 'number' || isNaN(abs)) {
|
|
749
|
+
throw new TypeError(`invalid parameter to abs2hebrew ${abs}`);
|
|
750
|
+
}
|
|
751
|
+
|
|
752
|
+
abs = Math.trunc(abs); // first, quickly approximate year
|
|
753
|
+
|
|
754
|
+
let year = Math.floor((abs - EPOCH) / AVG_HEBYEAR_DAYS);
|
|
755
|
+
|
|
756
|
+
while (newYear(year) <= abs) {
|
|
757
|
+
++year;
|
|
758
|
+
}
|
|
759
|
+
|
|
760
|
+
--year;
|
|
761
|
+
let month = abs < hebrew2abs(year, 1, 1) ? 7 : 1;
|
|
762
|
+
|
|
763
|
+
while (abs > hebrew2abs(year, month, daysInMonth(month, year))) {
|
|
764
|
+
++month;
|
|
765
|
+
}
|
|
766
|
+
|
|
767
|
+
const day = 1 + abs - hebrew2abs(year, month, 1);
|
|
768
|
+
return {
|
|
769
|
+
yy: year,
|
|
770
|
+
mm: month,
|
|
771
|
+
dd: day
|
|
772
|
+
};
|
|
773
|
+
}
|
|
774
|
+
/**
|
|
775
|
+
* Returns true if Hebrew year is a leap year
|
|
776
|
+
* @private
|
|
777
|
+
* @param {number} year Hebrew year
|
|
778
|
+
* @return {boolean}
|
|
779
|
+
*/
|
|
780
|
+
|
|
781
|
+
function isLeapYear(year) {
|
|
782
|
+
return (1 + year * 7) % 19 < 7;
|
|
783
|
+
}
|
|
784
|
+
/**
|
|
785
|
+
* Number of months in this Hebrew year (either 12 or 13 depending on leap year)
|
|
786
|
+
* @private
|
|
787
|
+
* @param {number} year Hebrew year
|
|
788
|
+
* @return {number}
|
|
789
|
+
*/
|
|
790
|
+
|
|
791
|
+
function monthsInYear(year) {
|
|
792
|
+
return 12 + isLeapYear(year); // boolean is cast to 1 or 0
|
|
793
|
+
}
|
|
794
|
+
/**
|
|
795
|
+
* Number of days in Hebrew month in a given year (29 or 30)
|
|
796
|
+
* @private
|
|
797
|
+
* @param {number} month Hebrew month (e.g. months.TISHREI)
|
|
798
|
+
* @param {number} year Hebrew year
|
|
799
|
+
* @return {number}
|
|
800
|
+
*/
|
|
801
|
+
|
|
802
|
+
function daysInMonth(month, year) {
|
|
803
|
+
switch (month) {
|
|
804
|
+
case IYYAR$1:
|
|
805
|
+
case TAMUZ$1:
|
|
806
|
+
case ELUL$2:
|
|
807
|
+
case TEVET$2:
|
|
808
|
+
case ADAR_II$2:
|
|
809
|
+
return 29;
|
|
810
|
+
}
|
|
811
|
+
|
|
812
|
+
if (month === ADAR_I$2 && !isLeapYear(year) || month === CHESHVAN$2 && !longCheshvan(year) || month === KISLEV$2 && shortKislev(year)) {
|
|
813
|
+
return 29;
|
|
814
|
+
} else {
|
|
815
|
+
return 30;
|
|
816
|
+
}
|
|
817
|
+
}
|
|
818
|
+
/**
|
|
819
|
+
* Returns a transliterated string name of Hebrew month in year,
|
|
820
|
+
* for example 'Elul' or 'Cheshvan'.
|
|
821
|
+
* @private
|
|
822
|
+
* @param {number} month Hebrew month (e.g. months.TISHREI)
|
|
823
|
+
* @param {number} year Hebrew year
|
|
824
|
+
* @return {string}
|
|
825
|
+
*/
|
|
826
|
+
|
|
827
|
+
function getMonthName(month, year) {
|
|
828
|
+
if (typeof month !== 'number' || isNaN(month) || month < 1 || month > 14) {
|
|
829
|
+
throw new TypeError(`bad month argument ${month}`);
|
|
830
|
+
}
|
|
831
|
+
|
|
832
|
+
return monthNames[+isLeapYear(year)][month];
|
|
833
|
+
}
|
|
834
|
+
/**
|
|
835
|
+
* Days from sunday prior to start of Hebrew calendar to mean
|
|
836
|
+
* conjunction of Tishrei in Hebrew YEAR
|
|
837
|
+
* @private
|
|
838
|
+
* @param {number} year Hebrew year
|
|
839
|
+
* @return {number}
|
|
840
|
+
*/
|
|
841
|
+
|
|
842
|
+
function elapsedDays(year) {
|
|
843
|
+
const elapsed = edCache[year] = edCache[year] || elapsedDays0(year);
|
|
844
|
+
return elapsed;
|
|
845
|
+
}
|
|
846
|
+
/**
|
|
847
|
+
* Days from sunday prior to start of Hebrew calendar to mean
|
|
848
|
+
* conjunction of Tishrei in Hebrew YEAR
|
|
849
|
+
* @private
|
|
850
|
+
* @param {number} year Hebrew year
|
|
851
|
+
* @return {number}
|
|
852
|
+
*/
|
|
853
|
+
|
|
854
|
+
function elapsedDays0(year) {
|
|
855
|
+
const prevYear = year - 1;
|
|
856
|
+
const mElapsed = 235 * Math.floor(prevYear / 19) + // Months in complete 19 year lunar (Metonic) cycles so far
|
|
857
|
+
12 * (prevYear % 19) + // Regular months in this cycle
|
|
858
|
+
Math.floor((prevYear % 19 * 7 + 1) / 19); // Leap months this cycle
|
|
859
|
+
|
|
860
|
+
const pElapsed = 204 + 793 * (mElapsed % 1080);
|
|
861
|
+
const hElapsed = 5 + 12 * mElapsed + 793 * Math.floor(mElapsed / 1080) + Math.floor(pElapsed / 1080);
|
|
862
|
+
const parts = pElapsed % 1080 + 1080 * (hElapsed % 24);
|
|
863
|
+
const day = 1 + 29 * mElapsed + Math.floor(hElapsed / 24);
|
|
864
|
+
const altDay = day + (parts >= 19440 || 2 === day % 7 && parts >= 9924 && !isLeapYear(year) || 1 === day % 7 && parts >= 16789 && isLeapYear(prevYear));
|
|
865
|
+
return altDay + (altDay % 7 === 0 || altDay % 7 === 3 || altDay % 7 === 5);
|
|
866
|
+
}
|
|
867
|
+
/**
|
|
868
|
+
* Number of days in the hebrew YEAR.
|
|
869
|
+
* A common Hebrew calendar year can have a length of 353, 354 or 355 days
|
|
870
|
+
* A leap Hebrew calendar year can have a length of 383, 384 or 385 days
|
|
871
|
+
* @private
|
|
872
|
+
* @param {number} year Hebrew year
|
|
873
|
+
* @return {number}
|
|
874
|
+
*/
|
|
875
|
+
|
|
876
|
+
|
|
877
|
+
function daysInYear(year) {
|
|
878
|
+
return elapsedDays(year + 1) - elapsedDays(year);
|
|
879
|
+
}
|
|
880
|
+
/**
|
|
881
|
+
* true if Cheshvan is long in Hebrew year
|
|
882
|
+
* @private
|
|
883
|
+
* @param {number} year Hebrew year
|
|
884
|
+
* @return {boolean}
|
|
885
|
+
*/
|
|
886
|
+
|
|
887
|
+
function longCheshvan(year) {
|
|
888
|
+
return daysInYear(year) % 10 === 5;
|
|
889
|
+
}
|
|
890
|
+
/**
|
|
891
|
+
* true if Kislev is short in Hebrew year
|
|
892
|
+
* @private
|
|
893
|
+
* @param {number} year Hebrew year
|
|
894
|
+
* @return {boolean}
|
|
895
|
+
*/
|
|
896
|
+
|
|
897
|
+
function shortKislev(year) {
|
|
898
|
+
return daysInYear(year) % 10 === 3;
|
|
899
|
+
}
|
|
900
|
+
|
|
901
|
+
/*
|
|
902
|
+
Hebcal - A Jewish Calendar Generator
|
|
903
|
+
Copyright (c) 1994-2020 Danny Sadinoff
|
|
904
|
+
Portions copyright Eyal Schachter and Michael J. Radwin
|
|
905
|
+
|
|
906
|
+
https://github.com/hebcal/hebcal-es6
|
|
907
|
+
|
|
908
|
+
This program is free software; you can redistribute it and/or
|
|
909
|
+
modify it under the terms of the GNU General Public License
|
|
910
|
+
as published by the Free Software Foundation; either version 2
|
|
911
|
+
of the License, or (at your option) any later version.
|
|
912
|
+
|
|
913
|
+
This program is distributed in the hope that it will be useful,
|
|
914
|
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
915
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
916
|
+
GNU General Public License for more details.
|
|
917
|
+
|
|
918
|
+
You should have received a copy of the GNU General Public License
|
|
919
|
+
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
920
|
+
*/
|
|
658
921
|
|
|
659
922
|
function throwTypeError$3(msg) {
|
|
660
923
|
throw new TypeError(msg);
|
|
661
924
|
}
|
|
662
925
|
|
|
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
926
|
const UNITS_DAY = 'day';
|
|
668
927
|
const UNITS_WEEK = 'week';
|
|
669
928
|
const UNITS_MONTH = 'month';
|
|
@@ -740,19 +999,22 @@ class HDate {
|
|
|
740
999
|
* @type {number}
|
|
741
1000
|
*/
|
|
742
1001
|
|
|
743
|
-
|
|
1002
|
+
year = parseInt(year, 10);
|
|
744
1003
|
|
|
745
|
-
if (isNaN(
|
|
1004
|
+
if (isNaN(year)) {
|
|
746
1005
|
throw new TypeError(`HDate called with bad year argument: ${year}`);
|
|
747
1006
|
}
|
|
748
1007
|
|
|
1008
|
+
this.year = year;
|
|
749
1009
|
this.setMonth(month); // will throw if we can't parse
|
|
750
1010
|
|
|
751
|
-
|
|
1011
|
+
day = parseInt(day, 10);
|
|
752
1012
|
|
|
753
|
-
if (isNaN(
|
|
1013
|
+
if (isNaN(day)) {
|
|
754
1014
|
throw new TypeError(`HDate called with bad day argument: ${day}`);
|
|
755
1015
|
}
|
|
1016
|
+
|
|
1017
|
+
this.setDate(day);
|
|
756
1018
|
} else {
|
|
757
1019
|
// 0 arguments
|
|
758
1020
|
if (typeof day === 'undefined') {
|
|
@@ -760,13 +1022,13 @@ class HDate {
|
|
|
760
1022
|
} // 1 argument
|
|
761
1023
|
|
|
762
1024
|
|
|
763
|
-
const abs0 = typeof day === 'number' && !isNaN(day) ? day :
|
|
1025
|
+
const abs0 = typeof day === 'number' && !isNaN(day) ? day : isDate(day) ? greg2abs(day) : HDate.isHDate(day) ? {
|
|
764
1026
|
dd: day.day,
|
|
765
1027
|
mm: day.month,
|
|
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)
|
|
@@ -905,7 +1167,7 @@ class HDate {
|
|
|
905
1167
|
|
|
906
1168
|
|
|
907
1169
|
greg() {
|
|
908
|
-
return
|
|
1170
|
+
return abs2greg(this.abs());
|
|
909
1171
|
}
|
|
910
1172
|
/**
|
|
911
1173
|
* Returns R.D. (Rata Die) fixed days.
|
|
@@ -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)
|
|
@@ -1380,43 +1566,17 @@ class HDate {
|
|
|
1380
1566
|
|
|
1381
1567
|
|
|
1382
1568
|
static monthNum(month) {
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
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
|
-
|
|
1569
|
+
if (typeof month === 'number') {
|
|
1570
|
+
if (isNaN(month) || month > 14) {
|
|
1571
|
+
throw new RangeError(`Invalid month number: ${month}`);
|
|
1572
|
+
}
|
|
1407
1573
|
|
|
1408
|
-
|
|
1409
|
-
|
|
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
|
|
1574
|
+
return month;
|
|
1575
|
+
}
|
|
1413
1576
|
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
|
|
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);
|
|
1577
|
+
return month.charCodeAt(0) >= 48 && month.charCodeAt(0) <= 57 ?
|
|
1578
|
+
/* number */
|
|
1579
|
+
parseInt(month, 10) : HDate.monthFromName(month);
|
|
1420
1580
|
}
|
|
1421
1581
|
/**
|
|
1422
1582
|
* Number of days in the hebrew YEAR
|
|
@@ -1426,7 +1586,7 @@ class HDate {
|
|
|
1426
1586
|
|
|
1427
1587
|
|
|
1428
1588
|
static daysInYear(year) {
|
|
1429
|
-
return
|
|
1589
|
+
return daysInYear(year);
|
|
1430
1590
|
}
|
|
1431
1591
|
/**
|
|
1432
1592
|
* true if Cheshvan is long in Hebrew year
|
|
@@ -1436,7 +1596,7 @@ class HDate {
|
|
|
1436
1596
|
|
|
1437
1597
|
|
|
1438
1598
|
static longCheshvan(year) {
|
|
1439
|
-
return
|
|
1599
|
+
return longCheshvan(year);
|
|
1440
1600
|
}
|
|
1441
1601
|
/**
|
|
1442
1602
|
* true if Kislev is short in Hebrew year
|
|
@@ -1446,7 +1606,7 @@ class HDate {
|
|
|
1446
1606
|
|
|
1447
1607
|
|
|
1448
1608
|
static shortKislev(year) {
|
|
1449
|
-
return
|
|
1609
|
+
return shortKislev(year);
|
|
1450
1610
|
}
|
|
1451
1611
|
/**
|
|
1452
1612
|
* Converts Hebrew month string name to numeric
|
|
@@ -1456,7 +1616,14 @@ class HDate {
|
|
|
1456
1616
|
|
|
1457
1617
|
|
|
1458
1618
|
static monthFromName(monthName) {
|
|
1459
|
-
if (typeof monthName === 'number')
|
|
1619
|
+
if (typeof monthName === 'number') {
|
|
1620
|
+
if (isNaN(monthName) || monthName < 1 || monthName > 14) {
|
|
1621
|
+
throw new RangeError(`Invalid month name: ${monthName}`);
|
|
1622
|
+
}
|
|
1623
|
+
|
|
1624
|
+
return monthName;
|
|
1625
|
+
}
|
|
1626
|
+
|
|
1460
1627
|
const c = monthName.toLowerCase();
|
|
1461
1628
|
/*
|
|
1462
1629
|
the Hebrew months are unique to their second letter
|
|
@@ -1488,41 +1655,41 @@ class HDate {
|
|
|
1488
1655
|
/* this catches "november" */
|
|
1489
1656
|
}
|
|
1490
1657
|
|
|
1491
|
-
return NISAN
|
|
1658
|
+
return months.NISAN;
|
|
1492
1659
|
|
|
1493
1660
|
case 'i':
|
|
1494
|
-
return IYYAR
|
|
1661
|
+
return months.IYYAR;
|
|
1495
1662
|
|
|
1496
1663
|
case 'e':
|
|
1497
|
-
return ELUL
|
|
1664
|
+
return months.ELUL;
|
|
1498
1665
|
|
|
1499
1666
|
case 'c':
|
|
1500
1667
|
case 'ח':
|
|
1501
|
-
return CHESHVAN
|
|
1668
|
+
return months.CHESHVAN;
|
|
1502
1669
|
|
|
1503
1670
|
case 'k':
|
|
1504
1671
|
case 'כ':
|
|
1505
|
-
return KISLEV
|
|
1672
|
+
return months.KISLEV;
|
|
1506
1673
|
|
|
1507
1674
|
case 's':
|
|
1508
1675
|
switch (c[1]) {
|
|
1509
1676
|
case 'i':
|
|
1510
|
-
return SIVAN
|
|
1677
|
+
return months.SIVAN;
|
|
1511
1678
|
|
|
1512
1679
|
case 'h':
|
|
1513
|
-
return SHVAT
|
|
1680
|
+
return months.SHVAT;
|
|
1514
1681
|
}
|
|
1515
1682
|
|
|
1516
1683
|
case 't':
|
|
1517
1684
|
switch (c[1]) {
|
|
1518
1685
|
case 'a':
|
|
1519
|
-
return TAMUZ
|
|
1686
|
+
return months.TAMUZ;
|
|
1520
1687
|
|
|
1521
1688
|
case 'i':
|
|
1522
|
-
return TISHREI
|
|
1689
|
+
return months.TISHREI;
|
|
1523
1690
|
|
|
1524
1691
|
case 'e':
|
|
1525
|
-
return TEVET
|
|
1692
|
+
return months.TEVET;
|
|
1526
1693
|
}
|
|
1527
1694
|
|
|
1528
1695
|
break;
|
|
@@ -1530,46 +1697,46 @@ class HDate {
|
|
|
1530
1697
|
case 'a':
|
|
1531
1698
|
switch (c[1]) {
|
|
1532
1699
|
case 'v':
|
|
1533
|
-
return AV
|
|
1700
|
+
return months.AV;
|
|
1534
1701
|
|
|
1535
1702
|
case 'd':
|
|
1536
1703
|
if (/(1|[^i]i|a|א)$/i.test(monthName)) {
|
|
1537
|
-
return ADAR_I
|
|
1704
|
+
return months.ADAR_I;
|
|
1538
1705
|
}
|
|
1539
1706
|
|
|
1540
|
-
return ADAR_II
|
|
1707
|
+
return months.ADAR_II;
|
|
1541
1708
|
// else assume sheini
|
|
1542
1709
|
}
|
|
1543
1710
|
|
|
1544
1711
|
break;
|
|
1545
1712
|
|
|
1546
1713
|
case 'ס':
|
|
1547
|
-
return SIVAN
|
|
1714
|
+
return months.SIVAN;
|
|
1548
1715
|
|
|
1549
1716
|
case 'ט':
|
|
1550
|
-
return TEVET
|
|
1717
|
+
return months.TEVET;
|
|
1551
1718
|
|
|
1552
1719
|
case 'ש':
|
|
1553
|
-
return SHVAT
|
|
1720
|
+
return months.SHVAT;
|
|
1554
1721
|
|
|
1555
1722
|
case 'א':
|
|
1556
1723
|
switch (c[1]) {
|
|
1557
1724
|
case 'ב':
|
|
1558
|
-
return AV
|
|
1725
|
+
return months.AV;
|
|
1559
1726
|
|
|
1560
1727
|
case 'ד':
|
|
1561
1728
|
if (/(1|[^i]i|a|א)$/i.test(monthName)) {
|
|
1562
|
-
return ADAR_I
|
|
1729
|
+
return months.ADAR_I;
|
|
1563
1730
|
}
|
|
1564
1731
|
|
|
1565
|
-
return ADAR_II
|
|
1732
|
+
return months.ADAR_II;
|
|
1566
1733
|
// else assume sheini
|
|
1567
1734
|
|
|
1568
1735
|
case 'י':
|
|
1569
|
-
return IYYAR
|
|
1736
|
+
return months.IYYAR;
|
|
1570
1737
|
|
|
1571
1738
|
case 'ל':
|
|
1572
|
-
return ELUL
|
|
1739
|
+
return months.ELUL;
|
|
1573
1740
|
}
|
|
1574
1741
|
|
|
1575
1742
|
break;
|
|
@@ -1577,10 +1744,10 @@ class HDate {
|
|
|
1577
1744
|
case 'ת':
|
|
1578
1745
|
switch (c[1]) {
|
|
1579
1746
|
case 'מ':
|
|
1580
|
-
return TAMUZ
|
|
1747
|
+
return months.TAMUZ;
|
|
1581
1748
|
|
|
1582
1749
|
case 'ש':
|
|
1583
|
-
return TISHREI
|
|
1750
|
+
return months.TISHREI;
|
|
1584
1751
|
}
|
|
1585
1752
|
|
|
1586
1753
|
break;
|
|
@@ -1631,21 +1798,21 @@ function fix(date) {
|
|
|
1631
1798
|
|
|
1632
1799
|
function fixDate(date) {
|
|
1633
1800
|
if (date.day < 1) {
|
|
1634
|
-
if (date.month == TISHREI
|
|
1801
|
+
if (date.month == months.TISHREI) {
|
|
1635
1802
|
date.year -= 1;
|
|
1636
1803
|
}
|
|
1637
1804
|
|
|
1638
|
-
date.day +=
|
|
1805
|
+
date.day += daysInMonth(date.month, date.year);
|
|
1639
1806
|
date.month -= 1;
|
|
1640
1807
|
fix(date);
|
|
1641
1808
|
}
|
|
1642
1809
|
|
|
1643
|
-
if (date.day >
|
|
1644
|
-
if (date.month
|
|
1810
|
+
if (date.day > daysInMonth(date.month, date.year)) {
|
|
1811
|
+
if (date.month === months.ELUL) {
|
|
1645
1812
|
date.year += 1;
|
|
1646
1813
|
}
|
|
1647
1814
|
|
|
1648
|
-
date.day -=
|
|
1815
|
+
date.day -= daysInMonth(date.month, date.year);
|
|
1649
1816
|
date.month += 1;
|
|
1650
1817
|
fix(date);
|
|
1651
1818
|
}
|
|
@@ -1659,16 +1826,16 @@ function fixDate(date) {
|
|
|
1659
1826
|
|
|
1660
1827
|
|
|
1661
1828
|
function fixMonth(date) {
|
|
1662
|
-
if (date.month
|
|
1829
|
+
if (date.month === months.ADAR_II && !date.isLeapYear()) {
|
|
1663
1830
|
date.month -= 1; // to Adar I
|
|
1664
1831
|
|
|
1665
1832
|
fix(date);
|
|
1666
1833
|
} else if (date.month < 1) {
|
|
1667
|
-
date.month +=
|
|
1834
|
+
date.month += monthsInYear(date.year);
|
|
1668
1835
|
date.year -= 1;
|
|
1669
1836
|
fix(date);
|
|
1670
|
-
} else if (date.month >
|
|
1671
|
-
date.month -=
|
|
1837
|
+
} else if (date.month > monthsInYear(date.year)) {
|
|
1838
|
+
date.month -= monthsInYear(date.year);
|
|
1672
1839
|
date.year += 1;
|
|
1673
1840
|
fix(date);
|
|
1674
1841
|
}
|
|
@@ -1688,31 +1855,6 @@ function onOrBefore(day, t, offset) {
|
|
|
1688
1855
|
return new HDate(HDate.dayOnOrBefore(day, t.abs() + offset));
|
|
1689
1856
|
}
|
|
1690
1857
|
|
|
1691
|
-
const CHAG$1 = 0x000001;
|
|
1692
|
-
const LIGHT_CANDLES$2 = 0x000002;
|
|
1693
|
-
const YOM_TOV_ENDS$2 = 0x000004;
|
|
1694
|
-
const CHUL_ONLY$2 = 0x000008; // chutz l'aretz (Diaspora)
|
|
1695
|
-
|
|
1696
|
-
const IL_ONLY$2 = 0x000010; // b'aretz (Israel)
|
|
1697
|
-
|
|
1698
|
-
const LIGHT_CANDLES_TZEIS$2 = 0x000020;
|
|
1699
|
-
const CHANUKAH_CANDLES$2 = 0x000040;
|
|
1700
|
-
const ROSH_CHODESH$1 = 0x000080;
|
|
1701
|
-
const MINOR_FAST$2 = 0x000100;
|
|
1702
|
-
const SPECIAL_SHABBAT$2 = 0x000200;
|
|
1703
|
-
const PARSHA_HASHAVUA$1 = 0x000400;
|
|
1704
|
-
const DAF_YOMI$1 = 0x000800;
|
|
1705
|
-
const OMER_COUNT$1 = 0x001000;
|
|
1706
|
-
const MODERN_HOLIDAY$2 = 0x002000;
|
|
1707
|
-
const MAJOR_FAST$2 = 0x004000;
|
|
1708
|
-
const SHABBAT_MEVARCHIM$1 = 0x008000;
|
|
1709
|
-
const MOLAD = 0x010000;
|
|
1710
|
-
const USER_EVENT = 0x020000;
|
|
1711
|
-
const HEBREW_DATE = 0x040000;
|
|
1712
|
-
const MINOR_HOLIDAY$2 = 0x080000;
|
|
1713
|
-
const EREV$2 = 0x100000;
|
|
1714
|
-
const CHOL_HAMOED$2 = 0x200000;
|
|
1715
|
-
const MISHNA_YOMI = 0x400000;
|
|
1716
1858
|
/**
|
|
1717
1859
|
* Holiday flags for Event
|
|
1718
1860
|
* @readonly
|
|
@@ -1721,73 +1863,73 @@ const MISHNA_YOMI = 0x400000;
|
|
|
1721
1863
|
|
|
1722
1864
|
const flags = {
|
|
1723
1865
|
/** Chag, yontiff, yom tov */
|
|
1724
|
-
CHAG:
|
|
1866
|
+
CHAG: 0x000001,
|
|
1725
1867
|
|
|
1726
1868
|
/** Light candles 18 minutes before sundown */
|
|
1727
|
-
LIGHT_CANDLES:
|
|
1869
|
+
LIGHT_CANDLES: 0x000002,
|
|
1728
1870
|
|
|
1729
1871
|
/** End of holiday (end of Yom Tov) */
|
|
1730
|
-
YOM_TOV_ENDS:
|
|
1872
|
+
YOM_TOV_ENDS: 0x000004,
|
|
1731
1873
|
|
|
1732
1874
|
/** Observed only in the Diaspora (chutz l'aretz) */
|
|
1733
|
-
CHUL_ONLY:
|
|
1875
|
+
CHUL_ONLY: 0x000008,
|
|
1734
1876
|
|
|
1735
1877
|
/** Observed only in Israel */
|
|
1736
|
-
IL_ONLY:
|
|
1878
|
+
IL_ONLY: 0x000010,
|
|
1737
1879
|
|
|
1738
1880
|
/** Light candles in the evening at Tzeit time (3 small stars) */
|
|
1739
|
-
LIGHT_CANDLES_TZEIS:
|
|
1881
|
+
LIGHT_CANDLES_TZEIS: 0x000020,
|
|
1740
1882
|
|
|
1741
1883
|
/** Candle-lighting for Chanukah */
|
|
1742
|
-
CHANUKAH_CANDLES:
|
|
1884
|
+
CHANUKAH_CANDLES: 0x000040,
|
|
1743
1885
|
|
|
1744
1886
|
/** Rosh Chodesh, beginning of a new Hebrew month */
|
|
1745
|
-
ROSH_CHODESH:
|
|
1887
|
+
ROSH_CHODESH: 0x000080,
|
|
1746
1888
|
|
|
1747
1889
|
/** Minor fasts like Tzom Tammuz, Ta'anit Esther, ... */
|
|
1748
|
-
MINOR_FAST:
|
|
1890
|
+
MINOR_FAST: 0x000100,
|
|
1749
1891
|
|
|
1750
1892
|
/** Shabbat Shekalim, Zachor, ... */
|
|
1751
|
-
SPECIAL_SHABBAT:
|
|
1893
|
+
SPECIAL_SHABBAT: 0x000200,
|
|
1752
1894
|
|
|
1753
1895
|
/** Weekly sedrot on Saturdays */
|
|
1754
|
-
PARSHA_HASHAVUA:
|
|
1896
|
+
PARSHA_HASHAVUA: 0x000400,
|
|
1755
1897
|
|
|
1756
1898
|
/** Daily page of Talmud */
|
|
1757
|
-
DAF_YOMI:
|
|
1899
|
+
DAF_YOMI: 0x000800,
|
|
1758
1900
|
|
|
1759
1901
|
/** Days of the Omer */
|
|
1760
|
-
OMER_COUNT:
|
|
1902
|
+
OMER_COUNT: 0x001000,
|
|
1761
1903
|
|
|
1762
1904
|
/** Yom HaShoah, Yom HaAtzma'ut, ... */
|
|
1763
|
-
MODERN_HOLIDAY:
|
|
1905
|
+
MODERN_HOLIDAY: 0x002000,
|
|
1764
1906
|
|
|
1765
1907
|
/** Yom Kippur and Tish'a B'Av */
|
|
1766
|
-
MAJOR_FAST:
|
|
1908
|
+
MAJOR_FAST: 0x004000,
|
|
1767
1909
|
|
|
1768
1910
|
/** On the Saturday before Rosh Chodesh */
|
|
1769
|
-
SHABBAT_MEVARCHIM:
|
|
1911
|
+
SHABBAT_MEVARCHIM: 0x008000,
|
|
1770
1912
|
|
|
1771
1913
|
/** Molad */
|
|
1772
|
-
MOLAD,
|
|
1914
|
+
MOLAD: 0x010000,
|
|
1773
1915
|
|
|
1774
1916
|
/** Yahrzeit or Hebrew Anniversary */
|
|
1775
|
-
USER_EVENT,
|
|
1917
|
+
USER_EVENT: 0x020000,
|
|
1776
1918
|
|
|
1777
1919
|
/** Daily Hebrew date ("11th of Sivan, 5780") */
|
|
1778
|
-
HEBREW_DATE,
|
|
1920
|
+
HEBREW_DATE: 0x040000,
|
|
1779
1921
|
|
|
1780
1922
|
/** A holiday that's not major, modern, rosh chodesh, or a fast day */
|
|
1781
|
-
MINOR_HOLIDAY:
|
|
1923
|
+
MINOR_HOLIDAY: 0x080000,
|
|
1782
1924
|
|
|
1783
1925
|
/** Evening before a major or minor holiday */
|
|
1784
|
-
EREV:
|
|
1926
|
+
EREV: 0x100000,
|
|
1785
1927
|
|
|
1786
1928
|
/** Chol haMoed, intermediate days of Pesach or Sukkot */
|
|
1787
|
-
CHOL_HAMOED:
|
|
1929
|
+
CHOL_HAMOED: 0x200000,
|
|
1788
1930
|
|
|
1789
1931
|
/** Mishna Yomi */
|
|
1790
|
-
MISHNA_YOMI
|
|
1932
|
+
MISHNA_YOMI: 0x400000
|
|
1791
1933
|
};
|
|
1792
1934
|
/** Represents an Event with a title, date, and flags */
|
|
1793
1935
|
|
|
@@ -1905,7 +2047,7 @@ class Event {
|
|
|
1905
2047
|
|
|
1906
2048
|
|
|
1907
2049
|
observedInIsrael() {
|
|
1908
|
-
return !(this.mask & CHUL_ONLY
|
|
2050
|
+
return !(this.mask & flags.CHUL_ONLY);
|
|
1909
2051
|
}
|
|
1910
2052
|
/**
|
|
1911
2053
|
* Is this event observed in the Diaspora?
|
|
@@ -1919,7 +2061,7 @@ class Event {
|
|
|
1919
2061
|
|
|
1920
2062
|
|
|
1921
2063
|
observedInDiaspora() {
|
|
1922
|
-
return !(this.mask & IL_ONLY
|
|
2064
|
+
return !(this.mask & flags.IL_ONLY);
|
|
1923
2065
|
}
|
|
1924
2066
|
/**
|
|
1925
2067
|
* @deprecated
|
|
@@ -2470,7 +2612,7 @@ class Zmanim {
|
|
|
2470
2612
|
throw new RangeError(`Longitude ${longitude} out of range [-180,180]`);
|
|
2471
2613
|
}
|
|
2472
2614
|
|
|
2473
|
-
const dt =
|
|
2615
|
+
const dt = isDate(date) ? date : HDate.isHDate(date) ? date.greg() : throwTypeError$2(`invalid date: ${date}`);
|
|
2474
2616
|
this.date = dt;
|
|
2475
2617
|
this.solarCalc = new SolarCalc(this.date, latitude, longitude);
|
|
2476
2618
|
this.sun = this.solarCalc.sun;
|
|
@@ -3835,8 +3977,8 @@ function getTodayIsHe(omer) {
|
|
|
3835
3977
|
|
|
3836
3978
|
/* eslint-disable no-multi-spaces */
|
|
3837
3979
|
const osdate = new Date(1923, 8, 11);
|
|
3838
|
-
const osday =
|
|
3839
|
-
const nsday =
|
|
3980
|
+
const osday = greg2abs(osdate);
|
|
3981
|
+
const nsday = greg2abs(new Date(1975, 5, 24));
|
|
3840
3982
|
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 => {
|
|
3841
3983
|
return {
|
|
3842
3984
|
name: m[0],
|
|
@@ -3858,7 +4000,7 @@ class DafYomi {
|
|
|
3858
4000
|
* @param {Date|HDate|number} gregdate Gregorian date
|
|
3859
4001
|
*/
|
|
3860
4002
|
constructor(gregdate) {
|
|
3861
|
-
const cday = typeof gregdate === 'number' && !isNaN(gregdate) ? gregdate :
|
|
4003
|
+
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}`);
|
|
3862
4004
|
|
|
3863
4005
|
if (cday < osday) {
|
|
3864
4006
|
throw new RangeError(`Date ${gregdate} too early; Daf Yomi cycle began on ${osdate}`);
|
|
@@ -5113,7 +5255,7 @@ function getHolidaysForYear_(year) {
|
|
|
5113
5255
|
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]}];
|
|
5114
5256
|
|
|
5115
5257
|
const cycleStartDate = new Date(1947, 4, 20);
|
|
5116
|
-
const mishnaYomiStart =
|
|
5258
|
+
const mishnaYomiStart = greg2abs(cycleStartDate);
|
|
5117
5259
|
const numMishnayot = 4192;
|
|
5118
5260
|
const numDays = numMishnayot / 2;
|
|
5119
5261
|
/**
|
|
@@ -5175,7 +5317,7 @@ class MishnaYomiIndex {
|
|
|
5175
5317
|
|
|
5176
5318
|
|
|
5177
5319
|
lookup(date) {
|
|
5178
|
-
const abs = typeof date === 'number' && !isNaN(date) ? date :
|
|
5320
|
+
const abs = typeof date === 'number' && !isNaN(date) ? date : isDate(date) ? greg2abs(date) : HDate.isHDate(date) ? date.abs() : throwTypeError(`Invalid date: ${date}`);
|
|
5179
5321
|
|
|
5180
5322
|
if (abs < mishnaYomiStart) {
|
|
5181
5323
|
const s = date.toISOString().substring(0, 10);
|
|
@@ -5296,18 +5438,18 @@ function getYahrzeit_(hyear, gdate) {
|
|
|
5296
5438
|
return undefined;
|
|
5297
5439
|
}
|
|
5298
5440
|
|
|
5299
|
-
if (hDeath.mm == CHESHVAN && hDeath.dd == 30 && !
|
|
5441
|
+
if (hDeath.mm == CHESHVAN && hDeath.dd == 30 && !longCheshvan(hDeath.yy + 1)) {
|
|
5300
5442
|
// If it's Heshvan 30 it depends on the first anniversary;
|
|
5301
5443
|
// if that was not Heshvan 30, use the day before Kislev 1.
|
|
5302
|
-
hDeath =
|
|
5303
|
-
} else if (hDeath.mm == KISLEV && hDeath.dd == 30 &&
|
|
5444
|
+
hDeath = abs2hebrew(hebrew2abs(hyear, KISLEV, 1) - 1);
|
|
5445
|
+
} else if (hDeath.mm == KISLEV && hDeath.dd == 30 && shortKislev(hDeath.yy + 1)) {
|
|
5304
5446
|
// If it's Kislev 30 it depends on the first anniversary;
|
|
5305
5447
|
// if that was not Kislev 30, use the day before Teveth 1.
|
|
5306
|
-
hDeath =
|
|
5448
|
+
hDeath = abs2hebrew(hebrew2abs(hyear, TEVET, 1) - 1);
|
|
5307
5449
|
} else if (hDeath.mm == ADAR_II) {
|
|
5308
5450
|
// If it's Adar II, use the same day in last month of year (Adar or Adar II).
|
|
5309
|
-
hDeath.mm =
|
|
5310
|
-
} else if (hDeath.mm == ADAR_I && hDeath.dd == 30 && !
|
|
5451
|
+
hDeath.mm = monthsInYear(hyear);
|
|
5452
|
+
} else if (hDeath.mm == ADAR_I && hDeath.dd == 30 && !isLeapYear(hyear)) {
|
|
5311
5453
|
// If it's the 30th in Adar I and year is not a leap year
|
|
5312
5454
|
// (so Adar has only 29 days), use the last day in Shevat.
|
|
5313
5455
|
hDeath.dd = 30;
|
|
@@ -5316,10 +5458,10 @@ function getYahrzeit_(hyear, gdate) {
|
|
|
5316
5458
|
// advance day to rosh chodesh if needed
|
|
5317
5459
|
|
|
5318
5460
|
|
|
5319
|
-
if (hDeath.mm == CHESHVAN && hDeath.dd == 30 && !
|
|
5461
|
+
if (hDeath.mm == CHESHVAN && hDeath.dd == 30 && !longCheshvan(hyear)) {
|
|
5320
5462
|
hDeath.mm = KISLEV;
|
|
5321
5463
|
hDeath.dd = 1;
|
|
5322
|
-
} else if (hDeath.mm == KISLEV && hDeath.dd == 30 &&
|
|
5464
|
+
} else if (hDeath.mm == KISLEV && hDeath.dd == 30 && shortKislev(hyear)) {
|
|
5323
5465
|
hDeath.mm = TEVET;
|
|
5324
5466
|
hDeath.dd = 1;
|
|
5325
5467
|
}
|
|
@@ -5342,19 +5484,19 @@ function getBirthdayOrAnniversary_(hyear, gdate) {
|
|
|
5342
5484
|
return undefined;
|
|
5343
5485
|
}
|
|
5344
5486
|
|
|
5345
|
-
const isOrigLeap =
|
|
5487
|
+
const isOrigLeap = isLeapYear(origYear);
|
|
5346
5488
|
let month = orig.getMonth();
|
|
5347
5489
|
let day = orig.getDate();
|
|
5348
5490
|
|
|
5349
5491
|
if (month == ADAR_I && !isOrigLeap || month == ADAR_II && isOrigLeap) {
|
|
5350
|
-
month =
|
|
5351
|
-
} else if (month == CHESHVAN && day == 30 && !
|
|
5492
|
+
month = monthsInYear(hyear);
|
|
5493
|
+
} else if (month == CHESHVAN && day == 30 && !longCheshvan(hyear)) {
|
|
5352
5494
|
month = KISLEV;
|
|
5353
5495
|
day = 1;
|
|
5354
|
-
} else if (month == KISLEV && day == 30 &&
|
|
5496
|
+
} else if (month == KISLEV && day == 30 && shortKislev(hyear)) {
|
|
5355
5497
|
month = TEVET;
|
|
5356
5498
|
day = 1;
|
|
5357
|
-
} else if (month == ADAR_I && day == 30 && isOrigLeap && !
|
|
5499
|
+
} else if (month == ADAR_I && day == 30 && isOrigLeap && !isLeapYear(hyear)) {
|
|
5358
5500
|
month = NISAN$1;
|
|
5359
5501
|
day = 1;
|
|
5360
5502
|
}
|
|
@@ -5362,7 +5504,7 @@ function getBirthdayOrAnniversary_(hyear, gdate) {
|
|
|
5362
5504
|
return new HDate(day, month, hyear);
|
|
5363
5505
|
}
|
|
5364
5506
|
|
|
5365
|
-
var version="3.
|
|
5507
|
+
var version="3.38.2";
|
|
5366
5508
|
|
|
5367
5509
|
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};
|
|
5368
5510
|
|
|
@@ -5583,7 +5725,7 @@ function checkCandleOptions(options) {
|
|
|
5583
5725
|
|
|
5584
5726
|
function getAbs(d) {
|
|
5585
5727
|
if (typeof d == 'number') return d;
|
|
5586
|
-
if (
|
|
5728
|
+
if (isDate(d)) return greg2abs(d);
|
|
5587
5729
|
if (HDate.isHDate(d)) return d.abs();
|
|
5588
5730
|
throw new TypeError(`Invalid date type: ${d}`);
|
|
5589
5731
|
}
|
|
@@ -5645,11 +5787,11 @@ function getStartAndEnd(options) {
|
|
|
5645
5787
|
startGreg.setFullYear(theYear);
|
|
5646
5788
|
}
|
|
5647
5789
|
|
|
5648
|
-
const startAbs =
|
|
5790
|
+
const startAbs = greg2abs(startGreg);
|
|
5649
5791
|
let endAbs;
|
|
5650
5792
|
|
|
5651
5793
|
if (options.month) {
|
|
5652
|
-
endAbs = startAbs +
|
|
5794
|
+
endAbs = startAbs + daysInMonth$1(theMonth, theYear) - 1;
|
|
5653
5795
|
} else {
|
|
5654
5796
|
const endYear = theYear + numYears;
|
|
5655
5797
|
const endGreg = new Date(endYear, 0, 1);
|
|
@@ -5658,7 +5800,7 @@ function getStartAndEnd(options) {
|
|
|
5658
5800
|
endGreg.setFullYear(endYear);
|
|
5659
5801
|
}
|
|
5660
5802
|
|
|
5661
|
-
endAbs =
|
|
5803
|
+
endAbs = greg2abs(endGreg) - 1;
|
|
5662
5804
|
}
|
|
5663
5805
|
|
|
5664
5806
|
return [startAbs, endAbs];
|
|
@@ -5923,7 +6065,7 @@ class HebrewCalendar {
|
|
|
5923
6065
|
warnUnrecognizedOptions(options);
|
|
5924
6066
|
const startAbs = startAndEnd[0];
|
|
5925
6067
|
const endAbs = startAndEnd[1];
|
|
5926
|
-
const startGreg =
|
|
6068
|
+
const startGreg = abs2greg(startAbs);
|
|
5927
6069
|
|
|
5928
6070
|
if (startGreg.getFullYear() < 100) {
|
|
5929
6071
|
options.candlelighting = false;
|