@hebcal/core 3.45.3 → 3.45.5

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