@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.
@@ -0,0 +1,469 @@
1
+ /*! @hebcal/core v3.38.2 */
2
+ var hebcal = (function (exports) {
3
+ 'use strict';
4
+
5
+ function _typeof(obj) {
6
+ "@babel/helpers - typeof";
7
+
8
+ return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) {
9
+ return typeof obj;
10
+ } : function (obj) {
11
+ return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
12
+ }, _typeof(obj);
13
+ }
14
+
15
+ /*
16
+ * More minimal greg routines
17
+ */
18
+
19
+ /** @private */
20
+ var lengths = [0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
21
+ /** @private */
22
+
23
+ var monthLengths = [lengths, lengths.slice()];
24
+ monthLengths[1][2] = 29;
25
+ /**
26
+ * @private
27
+ * @param {number} x
28
+ * @param {number} y
29
+ * @return {number}
30
+ */
31
+
32
+ function mod(x, y) {
33
+ return x - y * Math.floor(x / y);
34
+ }
35
+ /**
36
+ * @private
37
+ * @param {number} x
38
+ * @param {number} y
39
+ * @return {number}
40
+ */
41
+
42
+ function quotient(x, y) {
43
+ return Math.floor(x / y);
44
+ }
45
+ /**
46
+ * Returns true if the Gregorian year is a leap year
47
+ * @private
48
+ * @param {number} year Gregorian year
49
+ * @return {boolean}
50
+ */
51
+
52
+
53
+ function isLeapYear$1(year) {
54
+ return !(year % 4) && (!!(year % 100) || !(year % 400));
55
+ }
56
+ /**
57
+ * Returns true if the object is a Javascript Date
58
+ * @private
59
+ * @param {Object} obj
60
+ * @return {boolean}
61
+ */
62
+
63
+ function isDate(obj) {
64
+ return _typeof(obj) === 'object' && Date.prototype === obj.__proto__;
65
+ }
66
+ /**
67
+ * Returns number of days since January 1 of that year
68
+ * @private
69
+ * @param {Date} date Gregorian date
70
+ * @return {number}
71
+ */
72
+
73
+ function dayOfYear(date) {
74
+ if (!isDate(date)) {
75
+ throw new TypeError("Argument not a Date: ".concat(date));
76
+ }
77
+
78
+ var doy = date.getDate() + 31 * date.getMonth();
79
+
80
+ if (date.getMonth() > 1) {
81
+ // FEB
82
+ doy -= Math.floor((4 * (date.getMonth() + 1) + 23) / 10);
83
+
84
+ if (isLeapYear$1(date.getFullYear())) {
85
+ doy++;
86
+ }
87
+ }
88
+
89
+ return doy;
90
+ }
91
+ /**
92
+ * Converts Gregorian date to absolute R.D. (Rata Die) days
93
+ * @private
94
+ * @param {Date} date Gregorian date
95
+ * @return {number}
96
+ */
97
+
98
+ function greg2abs(date) {
99
+ if (!isDate(date)) {
100
+ throw new TypeError("Argument not a Date: ".concat(date));
101
+ }
102
+
103
+ var year = date.getFullYear() - 1;
104
+ return dayOfYear(date) + // days this year
105
+ 365 * year + ( // + days in prior years
106
+ Math.floor(year / 4) - // + Julian Leap years
107
+ Math.floor(year / 100) + // - century years
108
+ Math.floor(year / 400)); // + Gregorian leap years
109
+ }
110
+ /**
111
+ * @private
112
+ * @param {number} abs - R.D. number of days
113
+ * @return {number}
114
+ */
115
+
116
+ function yearFromFixed(abs) {
117
+ var l0 = abs - 1;
118
+ var n400 = quotient(l0, 146097);
119
+ var d1 = mod(l0, 146097);
120
+ var n100 = quotient(d1, 36524);
121
+ var d2 = mod(d1, 36524);
122
+ var n4 = quotient(d2, 1461);
123
+ var d3 = mod(d2, 1461);
124
+ var n1 = quotient(d3, 365);
125
+ var year = 400 * n400 + 100 * n100 + 4 * n4 + n1;
126
+ return n100 != 4 && n1 != 4 ? year + 1 : year;
127
+ }
128
+ /**
129
+ * @private
130
+ * @param {number} year
131
+ * @param {number} month
132
+ * @param {number} day
133
+ * @return {number}
134
+ */
135
+
136
+
137
+ function toFixed(year, month, day) {
138
+ var py = year - 1;
139
+ 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;
140
+ }
141
+ /**
142
+ * Converts from Rata Die (R.D. number) to Gregorian date.
143
+ * See the footnote on page 384 of ``Calendrical Calculations, Part II:
144
+ * Three Historical Calendars'' by E. M. Reingold, N. Dershowitz, and S. M.
145
+ * Clamen, Software--Practice and Experience, Volume 23, Number 4
146
+ * (April, 1993), pages 383-404 for an explanation.
147
+ * @private
148
+ * @param {number} abs - R.D. number of days
149
+ * @return {Date}
150
+ */
151
+
152
+
153
+ function abs2greg(abs) {
154
+ if (typeof abs !== 'number') {
155
+ throw new TypeError("Argument not a Number: ".concat(abs));
156
+ }
157
+
158
+ abs = Math.trunc(abs);
159
+ var year = yearFromFixed(abs);
160
+ var priorDays = abs - toFixed(year, 1, 1);
161
+ var correction = abs < toFixed(year, 3, 1) ? 0 : isLeapYear$1(year) ? 1 : 2;
162
+ var month = quotient(12 * (priorDays + correction) + 373, 367);
163
+ var day = abs - toFixed(year, month, 1) + 1;
164
+ var dt = new Date(year, month - 1, day);
165
+
166
+ if (year < 100 && year >= 0) {
167
+ dt.setFullYear(year);
168
+ }
169
+
170
+ return dt;
171
+ }
172
+
173
+ /*
174
+ * More minimal HDate
175
+ */
176
+ var NISAN = 1;
177
+ var IYYAR = 2; // const SIVAN = 3;
178
+
179
+ var TAMUZ = 4; // const AV = 5;
180
+
181
+ var ELUL = 6;
182
+ var TISHREI = 7;
183
+ var CHESHVAN = 8;
184
+ var KISLEV = 9;
185
+ var TEVET = 10; // const SHVAT = 11;
186
+
187
+ var ADAR_I = 12;
188
+ var ADAR_II = 13;
189
+ /**
190
+ * Hebrew months of the year (NISAN=1, TISHREI=7)
191
+ * @readonly
192
+ * @enum {number}
193
+ */
194
+
195
+ var months = {
196
+ /** Nissan / ניסן */
197
+ NISAN: 1,
198
+
199
+ /** Iyyar / אייר */
200
+ IYYAR: 2,
201
+
202
+ /** Sivan / סיון */
203
+ SIVAN: 3,
204
+
205
+ /** Tamuz (sometimes Tammuz) / תמוז */
206
+ TAMUZ: 4,
207
+
208
+ /** Av / אב */
209
+ AV: 5,
210
+
211
+ /** Elul / אלול */
212
+ ELUL: 6,
213
+
214
+ /** Tishrei / תִשְׁרֵי */
215
+ TISHREI: 7,
216
+
217
+ /** Cheshvan / חשון */
218
+ CHESHVAN: 8,
219
+
220
+ /** Kislev / כסלו */
221
+ KISLEV: 9,
222
+
223
+ /** Tevet / טבת */
224
+ TEVET: 10,
225
+
226
+ /** Sh'vat / שבט */
227
+ SHVAT: 11,
228
+
229
+ /** Adar or Adar Rishon / אדר */
230
+ ADAR_I: 12,
231
+
232
+ /** Adar Sheini (only on leap years) / אדר ב׳ */
233
+ ADAR_II: 13
234
+ };
235
+ var monthNames0 = ['', 'Nisan', 'Iyyar', 'Sivan', 'Tamuz', 'Av', 'Elul', 'Tishrei', 'Cheshvan', 'Kislev', 'Tevet', 'Sh\'vat'];
236
+ /**
237
+ * Transliterations of Hebrew month names.
238
+ * Regular years are index 0 and leap years are index 1.
239
+ * @private
240
+ */
241
+
242
+ var monthNames = [monthNames0.concat(['Adar', 'Nisan']), monthNames0.concat(['Adar I', 'Adar II', 'Nisan'])];
243
+ var edCache = Object.create(null);
244
+ var EPOCH = -1373428; // Avg year length in the cycle (19 solar years with 235 lunar months)
245
+
246
+ var AVG_HEBYEAR_DAYS = 365.24682220597794;
247
+ /**
248
+ * Converts Hebrew date to R.D. (Rata Die) fixed days.
249
+ * R.D. 1 is the imaginary date Monday, January 1, 1 on the Gregorian
250
+ * Calendar.
251
+ * @private
252
+ * @param {number} year Hebrew year
253
+ * @param {number} month Hebrew month
254
+ * @param {number} day Hebrew date (1-30)
255
+ * @return {number}
256
+ */
257
+
258
+ function hebrew2abs(year, month, day) {
259
+ var tempabs = day;
260
+
261
+ if (month < TISHREI) {
262
+ for (var m = TISHREI; m <= monthsInYear(year); m++) {
263
+ tempabs += daysInMonth(m, year);
264
+ }
265
+
266
+ for (var _m = NISAN; _m < month; _m++) {
267
+ tempabs += daysInMonth(_m, year);
268
+ }
269
+ } else {
270
+ for (var _m2 = TISHREI; _m2 < month; _m2++) {
271
+ tempabs += daysInMonth(_m2, year);
272
+ }
273
+ }
274
+
275
+ return EPOCH + elapsedDays(year) + tempabs - 1;
276
+ }
277
+ /**
278
+ * @private
279
+ * @param {number} year
280
+ * @return {number}
281
+ */
282
+
283
+ function newYear(year) {
284
+ return EPOCH + elapsedDays(year);
285
+ }
286
+ /**
287
+ * Converts absolute R.D. days to Hebrew date
288
+ * @private
289
+ * @param {number} abs absolute R.D. days
290
+ * @return {SimpleHebrewDate}
291
+ */
292
+
293
+
294
+ function abs2hebrew(abs) {
295
+ if (typeof abs !== 'number' || isNaN(abs)) {
296
+ throw new TypeError("invalid parameter to abs2hebrew ".concat(abs));
297
+ }
298
+
299
+ abs = Math.trunc(abs); // first, quickly approximate year
300
+
301
+ var year = Math.floor((abs - EPOCH) / AVG_HEBYEAR_DAYS);
302
+
303
+ while (newYear(year) <= abs) {
304
+ ++year;
305
+ }
306
+
307
+ --year;
308
+ var month = abs < hebrew2abs(year, 1, 1) ? 7 : 1;
309
+
310
+ while (abs > hebrew2abs(year, month, daysInMonth(month, year))) {
311
+ ++month;
312
+ }
313
+
314
+ var day = 1 + abs - hebrew2abs(year, month, 1);
315
+ return {
316
+ yy: year,
317
+ mm: month,
318
+ dd: day
319
+ };
320
+ }
321
+ /**
322
+ * Returns true if Hebrew year is a leap year
323
+ * @private
324
+ * @param {number} year Hebrew year
325
+ * @return {boolean}
326
+ */
327
+
328
+ function isLeapYear(year) {
329
+ return (1 + year * 7) % 19 < 7;
330
+ }
331
+ /**
332
+ * Number of months in this Hebrew year (either 12 or 13 depending on leap year)
333
+ * @private
334
+ * @param {number} year Hebrew year
335
+ * @return {number}
336
+ */
337
+
338
+ function monthsInYear(year) {
339
+ return 12 + isLeapYear(year); // boolean is cast to 1 or 0
340
+ }
341
+ /**
342
+ * Number of days in Hebrew month in a given year (29 or 30)
343
+ * @private
344
+ * @param {number} month Hebrew month (e.g. months.TISHREI)
345
+ * @param {number} year Hebrew year
346
+ * @return {number}
347
+ */
348
+
349
+ function daysInMonth(month, year) {
350
+ switch (month) {
351
+ case IYYAR:
352
+ case TAMUZ:
353
+ case ELUL:
354
+ case TEVET:
355
+ case ADAR_II:
356
+ return 29;
357
+ }
358
+
359
+ if (month === ADAR_I && !isLeapYear(year) || month === CHESHVAN && !longCheshvan(year) || month === KISLEV && shortKislev(year)) {
360
+ return 29;
361
+ } else {
362
+ return 30;
363
+ }
364
+ }
365
+ /**
366
+ * Returns a transliterated string name of Hebrew month in year,
367
+ * for example 'Elul' or 'Cheshvan'.
368
+ * @private
369
+ * @param {number} month Hebrew month (e.g. months.TISHREI)
370
+ * @param {number} year Hebrew year
371
+ * @return {string}
372
+ */
373
+
374
+ function getMonthName(month, year) {
375
+ if (typeof month !== 'number' || isNaN(month) || month < 1 || month > 14) {
376
+ throw new TypeError("bad month argument ".concat(month));
377
+ }
378
+
379
+ return monthNames[+isLeapYear(year)][month];
380
+ }
381
+ /**
382
+ * Days from sunday prior to start of Hebrew calendar to mean
383
+ * conjunction of Tishrei in Hebrew YEAR
384
+ * @private
385
+ * @param {number} year Hebrew year
386
+ * @return {number}
387
+ */
388
+
389
+ function elapsedDays(year) {
390
+ var elapsed = edCache[year] = edCache[year] || elapsedDays0(year);
391
+ return elapsed;
392
+ }
393
+ /**
394
+ * Days from sunday prior to start of Hebrew calendar to mean
395
+ * conjunction of Tishrei in Hebrew YEAR
396
+ * @private
397
+ * @param {number} year Hebrew year
398
+ * @return {number}
399
+ */
400
+
401
+ function elapsedDays0(year) {
402
+ var prevYear = year - 1;
403
+ var mElapsed = 235 * Math.floor(prevYear / 19) + // Months in complete 19 year lunar (Metonic) cycles so far
404
+ 12 * (prevYear % 19) + // Regular months in this cycle
405
+ Math.floor((prevYear % 19 * 7 + 1) / 19); // Leap months this cycle
406
+
407
+ var pElapsed = 204 + 793 * (mElapsed % 1080);
408
+ var hElapsed = 5 + 12 * mElapsed + 793 * Math.floor(mElapsed / 1080) + Math.floor(pElapsed / 1080);
409
+ var parts = pElapsed % 1080 + 1080 * (hElapsed % 24);
410
+ var day = 1 + 29 * mElapsed + Math.floor(hElapsed / 24);
411
+ var altDay = day + (parts >= 19440 || 2 === day % 7 && parts >= 9924 && !isLeapYear(year) || 1 === day % 7 && parts >= 16789 && isLeapYear(prevYear));
412
+ return altDay + (altDay % 7 === 0 || altDay % 7 === 3 || altDay % 7 === 5);
413
+ }
414
+ /**
415
+ * Number of days in the hebrew YEAR.
416
+ * A common Hebrew calendar year can have a length of 353, 354 or 355 days
417
+ * A leap Hebrew calendar year can have a length of 383, 384 or 385 days
418
+ * @private
419
+ * @param {number} year Hebrew year
420
+ * @return {number}
421
+ */
422
+
423
+
424
+ function daysInYear(year) {
425
+ return elapsedDays(year + 1) - elapsedDays(year);
426
+ }
427
+ /**
428
+ * true if Cheshvan is long in Hebrew year
429
+ * @private
430
+ * @param {number} year Hebrew year
431
+ * @return {boolean}
432
+ */
433
+
434
+ function longCheshvan(year) {
435
+ return daysInYear(year) % 10 === 5;
436
+ }
437
+ /**
438
+ * true if Kislev is short in Hebrew year
439
+ * @private
440
+ * @param {number} year Hebrew year
441
+ * @return {boolean}
442
+ */
443
+
444
+ function shortKislev(year) {
445
+ return daysInYear(year) % 10 === 3;
446
+ }
447
+
448
+ var hdate = {
449
+ abs2hebrew: abs2hebrew,
450
+ daysInMonth: daysInMonth,
451
+ daysInYear: daysInYear,
452
+ getMonthName: getMonthName,
453
+ hebrew2abs: hebrew2abs,
454
+ isLeapYear: isLeapYear,
455
+ longCheshvan: longCheshvan,
456
+ months: months,
457
+ monthsInYear: monthsInYear,
458
+ shortKislev: shortKislev
459
+ };
460
+
461
+ exports.abs2greg = abs2greg;
462
+ exports.greg2abs = greg2abs;
463
+ exports.hdate = hdate;
464
+
465
+ Object.defineProperty(exports, '__esModule', { value: true });
466
+
467
+ return exports;
468
+
469
+ })({});
@@ -0,0 +1,2 @@
1
+ /*! @hebcal/core v3.38.2 */
2
+ var hebcal=function(r){"use strict";function t(r){return t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(r){return typeof r}:function(r){return r&&"function"==typeof Symbol&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r},t(r)}var n=[0,31,28,31,30,31,30,31,31,30,31,30,31];function e(r,t){return r-t*Math.floor(r/t)}function o(r,t){return Math.floor(r/t)}function a(r){return!(r%4||!(r%100)&&r%400)}function u(r){return"object"===t(r)&&Date.prototype===r.__proto__}function f(r,t,n){var e=r-1;return 0+365*e+o(e,4)-o(e,100)+o(e,400)+o(367*t-362,12)+Math.floor(t<=2?0:a(r)?-1:-2)+n}[n,n.slice()][1][2]=29;var c=["","Nisan","Iyyar","Sivan","Tamuz","Av","Elul","Tishrei","Cheshvan","Kislev","Tevet","Sh'vat"],i=[c.concat(["Adar","Nisan"]),c.concat(["Adar I","Adar II","Nisan"])],h=Object.create(null),l=-1373428;function s(r,t,n){var e=n;if(t<7){for(var o=7;o<=b(r);o++)e+=m(o,r);for(var a=1;a<t;a++)e+=m(a,r)}else for(var u=7;u<t;u++)e+=m(u,r);return l+M(r)+e-1}function y(r){return l+M(r)}function v(r){return(1+7*r)%19<7}function b(r){return 12+v(r)}function m(r,t){switch(r){case 2:case 4:case 6:case 10:case 13:return 29}return 12===r&&!v(t)||8===r&&!A(t)||9===r&&g(t)?29:30}function M(r){var t=h[r]=h[r]||function(r){var t=r-1,n=235*Math.floor(t/19)+t%19*12+Math.floor((t%19*7+1)/19),e=204+n%1080*793,o=5+12*n+793*Math.floor(n/1080)+Math.floor(e/1080),a=e%1080+o%24*1080,u=1+29*n+Math.floor(o/24),f=u+(a>=19440||2==u%7&&a>=9924&&!v(r)||1==u%7&&a>=16789&&v(t));return f+(f%7==0||f%7==3||f%7==5)}(r);return t}function p(r){return M(r+1)-M(r)}function A(r){return p(r)%10==5}function g(r){return p(r)%10==3}var I={abs2hebrew:function(r){if("number"!=typeof r||isNaN(r))throw new TypeError("invalid parameter to abs2hebrew ".concat(r));r=Math.trunc(r);for(var t=Math.floor((r-l)/365.24682220597794);y(t)<=r;)++t;for(var n=r<s(--t,1,1)?7:1;r>s(t,n,m(n,t));)++n;return{yy:t,mm:n,dd:1+r-s(t,n,1)}},daysInMonth:m,daysInYear:p,getMonthName:function(r,t){if("number"!=typeof r||isNaN(r)||r<1||r>14)throw new TypeError("bad month argument ".concat(r));return i[+v(t)][r]},hebrew2abs:s,isLeapYear:v,longCheshvan:A,months:{NISAN:1,IYYAR:2,SIVAN:3,TAMUZ:4,AV:5,ELUL:6,TISHREI:7,CHESHVAN:8,KISLEV:9,TEVET:10,SHVAT:11,ADAR_I:12,ADAR_II:13},monthsInYear:b,shortKislev:g};return r.abs2greg=function(r){if("number"!=typeof r)throw new TypeError("Argument not a Number: ".concat(r));var t=function(r){var t=r-1,n=o(t,146097),a=e(t,146097),u=o(a,36524),f=e(a,36524),c=o(f,1461),i=o(e(f,1461),365),h=400*n+100*u+4*c+i;return 4!=u&&4!=i?h+1:h}(r=Math.trunc(r)),n=o(12*(r-f(t,1,1)+(r<f(t,3,1)?0:a(t)?1:2))+373,367),u=r-f(t,n,1)+1,c=new Date(t,n-1,u);return t<100&&t>=0&&c.setFullYear(t),c},r.greg2abs=function(r){if(!u(r))throw new TypeError("Argument not a Date: ".concat(r));var t=r.getFullYear()-1;return function(r){if(!u(r))throw new TypeError("Argument not a Date: ".concat(r));var t=r.getDate()+31*r.getMonth();return r.getMonth()>1&&(t-=Math.floor((4*(r.getMonth()+1)+23)/10),a(r.getFullYear())&&t++),t}(r)+365*t+(Math.floor(t/4)-Math.floor(t/100)+Math.floor(t/400))},r.hdate=I,Object.defineProperty(r,"__esModule",{value:!0}),r}({});