@hebcal/core 3.41.0 → 3.41.3

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/greg0.mjs CHANGED
@@ -1,4 +1,4 @@
1
- /*! @hebcal/core v3.41.0 */
1
+ /*! @hebcal/core v3.41.3 */
2
2
  /*
3
3
  * More minimal greg routines
4
4
  */
@@ -64,27 +64,10 @@ function isDate(obj) {
64
64
  return typeof obj === 'object' && Date.prototype === obj.__proto__;
65
65
  }
66
66
 
67
- /**
68
- * Returns number of days since January 1 of that year
69
- * @private
70
- * @param {Date} date Gregorian date
71
- * @return {number}
72
- */
73
- function dayOfYear(date) {
74
- if (!isDate(date)) {
75
- throw new TypeError(`Argument not a Date: ${date}`);
76
- }
77
- const month = date.getMonth();
78
- let doy = date.getDate() + 31 * month;
79
- if (month > 1) {
80
- // FEB
81
- doy -= Math.floor((4 * (month + 1) + 23) / 10);
82
- if (isLeapYear(date.getFullYear())) {
83
- doy++;
84
- }
85
- }
86
- return doy;
87
- }
67
+ /*
68
+ const ABS_14SEP1752 = 639797;
69
+ const ABS_2SEP1752 = 639785;
70
+ */
88
71
 
89
72
  /**
90
73
  * Converts Gregorian date to absolute R.D. (Rata Die) days
@@ -96,14 +79,13 @@ function greg2abs(date) {
96
79
  if (!isDate(date)) {
97
80
  throw new TypeError(`Argument not a Date: ${date}`);
98
81
  }
99
- const year = date.getFullYear() - 1;
100
- return (
101
- dayOfYear(date) + // days this year
102
- 365 * year + // + days in prior years
103
- (Math.floor(year / 4) - // + Julian Leap years
104
- Math.floor(year / 100) + // - century years
105
- Math.floor(year / 400))
106
- ); // + Gregorian leap years
82
+ const abs = toFixed(date.getFullYear(), date.getMonth() + 1, date.getDate());
83
+ /*
84
+ if (abs < ABS_14SEP1752 && abs > ABS_2SEP1752) {
85
+ throw new RangeError(`Invalid Date: ${date}`);
86
+ }
87
+ */
88
+ return abs;
107
89
  }
108
90
 
109
91
  /**
@@ -127,8 +109,8 @@ function yearFromFixed(abs) {
127
109
  /**
128
110
  * @private
129
111
  * @param {number} year
130
- * @param {number} month
131
- * @param {number} day
112
+ * @param {number} month (1-12)
113
+ * @param {number} day (1-31)
132
114
  * @return {number}
133
115
  */
134
116
  function toFixed(year, month, day) {
@@ -157,6 +139,11 @@ function abs2greg(abs) {
157
139
  throw new TypeError(`Argument not a Number: ${abs}`);
158
140
  }
159
141
  abs = Math.trunc(abs);
142
+ /*
143
+ if (abs < ABS_14SEP1752 && abs > ABS_2SEP1752) {
144
+ throw new RangeError(`Invalid Date: ${abs}`);
145
+ }
146
+ */
160
147
  const year = yearFromFixed(abs);
161
148
  const priorDays = abs - toFixed(year, 1, 1);
162
149
  const correction = abs < toFixed(year, 3, 1) ? 0 : (isLeapYear(year) ? 1 : 2);
@@ -169,4 +156,4 @@ function abs2greg(abs) {
169
156
  return dt;
170
157
  }
171
158
 
172
- export { abs2greg, dayOfYear, daysInMonth, greg2abs, isDate, isLeapYear, mod };
159
+ export { abs2greg, daysInMonth, greg2abs, isDate, isLeapYear, mod };
@@ -1,4 +1,4 @@
1
- /*! @hebcal/core v3.41.0 */
1
+ /*! @hebcal/core v3.41.3 */
2
2
  var hebcal = (function (exports) {
3
3
  'use strict';
4
4
 
@@ -280,32 +280,11 @@ function daysInMonth$1(month, year) {
280
280
  function isDate(obj) {
281
281
  return _typeof(obj) === 'object' && Date.prototype === obj.__proto__;
282
282
  }
283
- /**
284
- * Returns number of days since January 1 of that year
285
- * @private
286
- * @param {Date} date Gregorian date
287
- * @return {number}
288
- */
289
-
290
- function dayOfYear(date) {
291
- if (!isDate(date)) {
292
- throw new TypeError("Argument not a Date: ".concat(date));
293
- }
294
-
295
- var month = date.getMonth();
296
- var doy = date.getDate() + 31 * month;
297
-
298
- if (month > 1) {
299
- // FEB
300
- doy -= Math.floor((4 * (month + 1) + 23) / 10);
301
-
302
- if (isLeapYear$1(date.getFullYear())) {
303
- doy++;
304
- }
305
- }
283
+ /*
284
+ const ABS_14SEP1752 = 639797;
285
+ const ABS_2SEP1752 = 639785;
286
+ */
306
287
 
307
- return doy;
308
- }
309
288
  /**
310
289
  * Converts Gregorian date to absolute R.D. (Rata Die) days
311
290
  * @private
@@ -318,12 +297,14 @@ function greg2abs(date) {
318
297
  throw new TypeError("Argument not a Date: ".concat(date));
319
298
  }
320
299
 
321
- var year = date.getFullYear() - 1;
322
- return dayOfYear(date) + // days this year
323
- 365 * year + ( // + days in prior years
324
- Math.floor(year / 4) - // + Julian Leap years
325
- Math.floor(year / 100) + // - century years
326
- Math.floor(year / 400)); // + Gregorian leap years
300
+ var abs = toFixed(date.getFullYear(), date.getMonth() + 1, date.getDate());
301
+ /*
302
+ if (abs < ABS_14SEP1752 && abs > ABS_2SEP1752) {
303
+ throw new RangeError(`Invalid Date: ${date}`);
304
+ }
305
+ */
306
+
307
+ return abs;
327
308
  }
328
309
  /**
329
310
  * @private
@@ -346,8 +327,8 @@ function yearFromFixed(abs) {
346
327
  /**
347
328
  * @private
348
329
  * @param {number} year
349
- * @param {number} month
350
- * @param {number} day
330
+ * @param {number} month (1-12)
331
+ * @param {number} day (1-31)
351
332
  * @return {number}
352
333
  */
353
334
 
@@ -374,6 +355,12 @@ function abs2greg(abs) {
374
355
  }
375
356
 
376
357
  abs = Math.trunc(abs);
358
+ /*
359
+ if (abs < ABS_14SEP1752 && abs > ABS_2SEP1752) {
360
+ throw new RangeError(`Invalid Date: ${abs}`);
361
+ }
362
+ */
363
+
377
364
  var year = yearFromFixed(abs);
378
365
  var priorDays = abs - toFixed(year, 1, 1);
379
366
  var correction = abs < toFixed(year, 3, 1) ? 0 : isLeapYear$1(year) ? 1 : 2;
@@ -439,14 +426,31 @@ var greg = /*#__PURE__*/function () {
439
426
  }
440
427
  /**
441
428
  * Returns number of days since January 1 of that year
429
+ * @deprecated
442
430
  * @param {Date} date Gregorian date
443
431
  * @return {number}
444
432
  */
445
433
 
446
434
  }, {
447
435
  key: "dayOfYear",
448
- value: function dayOfYear$1(date) {
449
- return dayOfYear(date);
436
+ value: function dayOfYear(date) {
437
+ if (!isDate(date)) {
438
+ throw new TypeError("Argument not a Date: ".concat(date));
439
+ }
440
+
441
+ var month = date.getMonth();
442
+ var doy = date.getDate() + 31 * month;
443
+
444
+ if (month > 1) {
445
+ // FEB
446
+ doy -= Math.floor((4 * (month + 1) + 23) / 10);
447
+
448
+ if (isLeapYear$1(date.getFullYear())) {
449
+ doy++;
450
+ }
451
+ }
452
+
453
+ return doy;
450
454
  }
451
455
  /**
452
456
  * Converts Gregorian date to absolute R.D. (Rata Die) days
@@ -2045,7 +2049,7 @@ function getBirthdayOrAnniversary_(hyear, gdate) {
2045
2049
  return new HDate(day, month, hyear);
2046
2050
  }
2047
2051
 
2048
- var version="3.41.0";
2052
+ var version="3.41.3";
2049
2053
 
2050
2054
  var headers={"plural-forms":"nplurals=2; plural=(n > 1);",language:"he"};var contexts={"":{Adar:["אַדָר"],"Adar I":["אַדָר א׳"],"Adar II":["אַדָר ב׳"],Av:["אָב"],Cheshvan:["חֶשְׁוָן"],Elul:["אֱלוּל"],Iyyar:["אִיָיר"],Kislev:["כִּסְלֵו"],Nisan:["נִיסָן"],"Sh'vat":["שְׁבָט"],Sivan:["סִיוָן"],Tamuz:["תַּמּוּז"],Tevet:["טֵבֵת"],Tishrei:["תִשְׁרֵי"]}};var poHeMin = {headers:headers,contexts:contexts};
2051
2055
 
@@ -1,2 +1,2 @@
1
- /*! @hebcal/core v3.41.0 */
2
- var hebcal=function(e){"use strict";function t(e){switch(e){case 1:return"א";case 2:return"ב";case 3:return"ג";case 4:return"ד";case 5:return"ה";case 6:return"ו";case 7:return"ז";case 8:return"ח";case 9:return"ט";case 10:return"י";case 20:return"כ";case 30:return"ל";case 40:return"מ";case 50:return"נ";case 60:return"ס";case 70:return"ע";case 80:return"פ";case 90:return"צ";case 100:return"ק";case 200:return"ר";case 300:return"ש";case 400:return"ת";default:return"*INVALID*"}}function r(e){for(var t=[];e>0;){if(15===e||16===e){t.push(9),t.push(e-9);break}var r=100,n=void 0;for(n=400;n>e;n-=r)n===r&&(r/=10);t.push(n),e-=n}return t}function n(e){var n=parseInt(e,10);if(!n)throw new TypeError("invalid parameter to gematriya ".concat(e));var a="",o=Math.floor(n/1e3);if(o>0&&5!==o){for(var u=r(o),i=0;i<u.length;i++)a+=t(u[i]);a+="׳"}var s=r(n%1e3);if(1==s.length)return a+t(s[0])+"׳";for(var c=0;c<s.length;c++)c+1===s.length&&(a+="״"),a+=t(s[c]);return a}function a(e){return a="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},a(e)}function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function u(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function i(e,t,r){return t&&u(e.prototype,t),r&&u(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function s(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var c=[0,31,28,31,30,31,30,31,31,30,31,30,31],h=[c,c.slice()];function l(e,t){return e-t*Math.floor(e/t)}function f(e,t){return Math.floor(e/t)}function y(e){return!(e%4||!(e%100)&&e%400)}function v(e){return"object"===a(e)&&Date.prototype===e.__proto__}function d(e){if(!v(e))throw new TypeError("Argument not a Date: ".concat(e));var t=e.getMonth(),r=e.getDate()+31*t;return t>1&&(r-=Math.floor((4*(t+1)+23)/10),y(e.getFullYear())&&r++),r}function m(e){if(!v(e))throw new TypeError("Argument not a Date: ".concat(e));var t=e.getFullYear()-1;return d(e)+365*t+(Math.floor(t/4)-Math.floor(t/100)+Math.floor(t/400))}function g(e,t,r){var n=e-1;return 365*n+f(n,4)-f(n,100)+f(n,400)+f(367*t-362,12)+(t<=2?0:y(e)?-1:-2)+r}function b(e){if("number"!=typeof e)throw new TypeError("Argument not a Number: ".concat(e));var t=function(e){var t=e-1,r=f(t,146097),n=l(t,146097),a=f(n,36524),o=l(n,36524),u=f(o,1461),i=f(l(o,1461),365),s=400*r+100*a+4*u+i;return 4!=a&&4!=i?s+1:s}(e=Math.trunc(e)),r=f(12*(e-g(t,1,1)+(e<g(t,3,1)?0:y(t)?1:2))+373,367),n=e-g(t,r,1)+1,a=new Date(t,r-1,n);return t<100&&t>=0&&a.setFullYear(t),a}h[1][2]=29;var k=function(){function e(){o(this,e)}return i(e,null,[{key:"isLeapYear",value:function(e){return y(e)}},{key:"daysInMonth",value:function(e,t){return function(e,t){return h[+y(t)][e]}(e,t)}},{key:"isDate",value:function(e){return v(e)}},{key:"dayOfYear",value:function(e){return d(e)}},{key:"greg2abs",value:function(e){return m(e)}},{key:"abs2greg",value:function(e){return b(e)}}]),e}();s(k,"monthNames",["","January","February","March","April","May","June","July","August","September","October","November","December"]);var p={headers:{"plural-forms":"nplurals=2; plural=(n!=1);"},contexts:{"":{}}},w={h:"he",a:"ashkenazi",s:"en","":"en"},A=function(){function e(){o(this,e)}return i(e,null,[{key:"lookupTranslation",value:function(e,t){var r=t&&t.toLowerCase(),n=("string"==typeof t&&this.locales[r]||this.activeLocale)[e];if(n&&n.length&&n[0].length)return n[0]}},{key:"gettext",value:function(e,t){var r=this.lookupTranslation(e,t);return void 0===r?e:r}},{key:"addLocale",value:function(e,t){if("object"!==a(t.contexts)||"object"!==a(t.contexts[""]))throw new TypeError("Locale '".concat(e,"' invalid compact format"));this.locales[e.toLowerCase()]=t.contexts[""]}},{key:"useLocale",value:function(e){var t=e.toLowerCase(),r=this.locales[t];if(!r)throw new RangeError("Locale '".concat(e,"' not found"));return this.activeName=w[t]||t,this.activeLocale=r,this.activeLocale}},{key:"getLocaleName",value:function(){return this.activeName}},{key:"getLocaleNames",value:function(){return Object.keys(this.locales).sort()}},{key:"ordinal",value:function(e,t){var r=t&&t.toLowerCase()||this.activeName;if(!r)return this.getEnOrdinal(e);switch(r){case"en":case"s":case"a":case"ashkenazi":case"ashkenazi_litvish":case"ashkenazi_poylish":case"ashkenazi_standard":return this.getEnOrdinal(e);case"es":return e+"º";case"h":case"he":case"he-x-nonikud":return String(e);default:return e+"."}}},{key:"getEnOrdinal",value:function(e){var t=["th","st","nd","rd"],r=e%100;return e+(t[(r-20)%10]||t[r]||t[0])}},{key:"hebrewStripNikkud",value:function(e){return e.replace(/[\u0590-\u05bd]/g,"").replace(/[\u05bf-\u05c7]/g,"")}}]),e}();s(A,"locales",Object.create(null)),s(A,"activeLocale",null),s(A,"activeName",null),A.addLocale("en",p),A.addLocale("s",p),A.addLocale("",p),A.useLocale("en");var I={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},N=["","Nisan","Iyyar","Sivan","Tamuz","Av","Elul","Tishrei","Cheshvan","Kislev","Tevet","Sh'vat"],E=[N.concat(["Adar","Nisan"]),N.concat(["Adar I","Adar II","Nisan"])],T=Object.create(null),D=-1373428;function M(e,t,r){var n=r;if(t<7){for(var a=7;a<=H(e);a++)n+=O(a,e);for(var o=1;o<t;o++)n+=O(o,e)}else for(var u=7;u<t;u++)n+=O(u,e);return D+R(e)+n-1}function L(e){return D+R(e)}function S(e){if("number"!=typeof e||isNaN(e))throw new TypeError("invalid parameter to abs2hebrew ".concat(e));e=Math.trunc(e);for(var t=Math.floor((e-D)/365.24682220597794);L(t)<=e;)++t;for(var r=e<M(--t,1,1)?7:1;e>M(t,r,O(r,t));)++r;return{yy:t,mm:r,dd:1+e-M(t,r,1)}}function Y(e){return(1+7*e)%19<7}function H(e){return 12+Y(e)}function O(e,t){switch(e){case 2:case 4:case 6:case 10:case 13:return 29}return 12===e&&!Y(t)||8===e&&!F(t)||9===e&&C(t)?29:30}function V(e,t){if("number"!=typeof e||isNaN(e)||e<1||e>14)throw new TypeError("bad month argument ".concat(e));return E[+Y(t)][e]}function R(e){var t=T[e]=T[e]||function(e){var t=e-1,r=235*Math.floor(t/19)+t%19*12+Math.floor((t%19*7+1)/19),n=204+r%1080*793,a=5+12*r+793*Math.floor(r/1080)+Math.floor(n/1080),o=n%1080+a%24*1080,u=1+29*r+Math.floor(a/24),i=u+(o>=19440||2==u%7&&o>=9924&&!Y(e)||1==u%7&&o>=16789&&Y(t));return i+(i%7==0||i%7==3||i%7==5)}(e);return t}function _(e){return R(e+1)-R(e)}function F(e){return _(e)%10==5}function C(e){return _(e)%10==3}function x(e){throw new TypeError(e)}var j="day",z="week",U="month",K="year",B={d:j,w:z,M:U,y:K},P={day:j,week:z,month:U,year:K},J=function(){function e(t,r,n){if(o(this,e),2==arguments.length||arguments.length>3)throw new TypeError("HDate constructor requires 0, 1 or 3 arguments");if(3==arguments.length){if(this.day=this.month=1,n=parseInt(n,10),isNaN(n))throw new TypeError("HDate called with bad year argument: ".concat(n));if(this.year=n,this.setMonth(r),t=parseInt(t,10),isNaN(t))throw new TypeError("HDate called with bad day argument: ".concat(t));this.setDate(t)}else{void 0===t&&(t=new Date);var a="number"!=typeof t||isNaN(t)?v(t)?m(t):e.isHDate(t)?{dd:t.day,mm:t.month,yy:t.year}:x("HDate called with bad argument: ".concat(t)):t,u="number"==typeof a,i=u?S(a):a;this.day=i.dd,this.month=i.mm,this.year=i.yy,u&&(this.abs0=a)}}return i(e,[{key:"getFullYear",value:function(){return this.year}},{key:"isLeapYear",value:function(){return Y(this.year)}},{key:"getMonth",value:function(){return this.month}},{key:"getTishreiMonth",value:function(){var e=H(this.getFullYear());return(this.getMonth()+e-6)%e||e}},{key:"daysInMonth",value:function(){return O(this.getMonth(),this.getFullYear())}},{key:"getDate",value:function(){return this.day}},{key:"getDay",value:function(){return l(this.abs(),7)}},{key:"setFullYear",value:function(e){return this.year=e,Z(this),this}},{key:"setMonth",value:function(t){return this.month=e.monthNum(t),Z(this),this}},{key:"setDate",value:function(e){return this.day=e,Z(this),this}},{key:"greg",value:function(){return b(this.abs())}},{key:"abs",value:function(){return"number"!=typeof this.abs0&&(this.abs0=M(this.year,this.month,this.day)),this.abs0}},{key:"getMonthName",value:function(){return V(this.getMonth(),this.getFullYear())}},{key:"render",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null,r=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],n=t||A.getLocaleName(),a=this.getDate(),o=A.gettext(this.getMonthName(),n),u=A.ordinal(a,n),i=e.getDayOfTranslation(n),s="".concat(u).concat(i," ").concat(o);if(r){var c=this.getFullYear();return"".concat(s,", ").concat(c)}return s}},{key:"renderGematriya",value:function(){var e=this.getDate(),t=A.gettext(this.getMonthName(),"he"),r=this.getFullYear();return n(e)+" "+t+" "+n(r)}},{key:"before",value:function(e){return q(e,this,-1)}},{key:"onOrBefore",value:function(e){return q(e,this,0)}},{key:"nearest",value:function(e){return q(e,this,3)}},{key:"onOrAfter",value:function(e){return q(e,this,6)}},{key:"after",value:function(e){return q(e,this,7)}},{key:"next",value:function(){return new e(this.abs()+1)}},{key:"prev",value:function(){return new e(this.abs()-1)}},{key:"add",value:function(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"d";if(!(t=parseInt(t,10)))return new e(this);if((r=e.standardizeUnits(r))===j)return new e(this.abs()+t);if(r===z)return new e(this.abs()+7*t);if(r===K)return new e(this.getDate(),this.getMonth(),this.getFullYear()+t);if(r===U){var n=new e(this),a=t>0?1:-1;t=Math.abs(t);for(var o=0;o<t;o++)n=new e(n.abs()+a*n.daysInMonth());return n}}},{key:"subtract",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"d";return this.add(-1*e,t)}},{key:"deltaDays",value:function(t){if(!e.isHDate(t))throw new TypeError("Bad argument: ".concat(t));return this.abs()-t.abs()}},{key:"isSameDate",value:function(t){return!!e.isHDate(t)&&(this.year==t.year&&this.month==t.month&&this.day==t.day)}},{key:"toString",value:function(){var e=this.getDate(),t=this.getFullYear(),r=this.getMonthName();return"".concat(e," ").concat(r," ").concat(t)}}],[{key:"hebrew2abs",value:function(e,t,r){return M(e,t,r)}},{key:"abs2hebrew",value:function(e){return S(e)}},{key:"getDayOfTranslation",value:function(e){switch(e){case"en":case"s":case"a":case"ashkenazi":return" of"}var t=A.lookupTranslation("of",e);return t?" "+t:"ashkenazi"===e.substring(0,9)?" of":""}},{key:"standardizeUnits",value:function(e){var t=B[e]||String(e||"").toLowerCase().replace(/s$/,"");return P[t]||x("Invalid units '".concat(e,"'"))}},{key:"isLeapYear",value:function(e){return Y(e)}},{key:"monthsInYear",value:function(e){return H(e)}},{key:"daysInMonth",value:function(e,t){return O(e,t)}},{key:"getMonthName",value:function(e,t){return V(e,t)}},{key:"monthNum",value:function(t){if("number"==typeof t){if(isNaN(t)||t>14)throw new RangeError("Invalid month number: ".concat(t));return t}return t.charCodeAt(0)>=48&&t.charCodeAt(0)<=57?parseInt(t,10):e.monthFromName(t)}},{key:"daysInYear",value:function(e){return _(e)}},{key:"longCheshvan",value:function(e){return F(e)}},{key:"shortKislev",value:function(e){return C(e)}},{key:"monthFromName",value:function(e){if("number"==typeof e){if(isNaN(e)||e<1||e>14)throw new RangeError("Invalid month name: ".concat(e));return e}var t=e.toLowerCase();switch(t[0]){case"n":case"נ":if("o"==t[1])break;return I.NISAN;case"i":return I.IYYAR;case"e":return I.ELUL;case"c":case"ח":return I.CHESHVAN;case"k":case"כ":return I.KISLEV;case"s":switch(t[1]){case"i":return I.SIVAN;case"h":return I.SHVAT}case"t":switch(t[1]){case"a":return I.TAMUZ;case"i":return I.TISHREI;case"e":return I.TEVET}break;case"a":switch(t[1]){case"v":return I.AV;case"d":return/(1|[^i]i|a|א)$/i.test(e)?I.ADAR_I:I.ADAR_II}break;case"ס":return I.SIVAN;case"ט":return I.TEVET;case"ש":return I.SHVAT;case"א":switch(t[1]){case"ב":return I.AV;case"ד":return/(1|[^i]i|a|א)$/i.test(e)?I.ADAR_I:I.ADAR_II;case"י":return I.IYYAR;case"ל":return I.ELUL}break;case"ת":switch(t[1]){case"מ":return I.TAMUZ;case"ש":return I.TISHREI}}throw new RangeError("Unable to parse month name: ".concat(e))}},{key:"dayOnOrBefore",value:function(e,t){return t-(t-e)%7}},{key:"isHDate",value:function(e){return null!==e&&"object"===a(e)&&"number"==typeof e.year&&"number"==typeof e.month&&"number"==typeof e.day&&"function"==typeof e.greg&&"function"==typeof e.abs}}]),e}();function Z(e){$(e),function(e){e.day<1&&(e.month==I.TISHREI&&(e.year-=1),e.day+=O(e.month,e.year),e.month-=1,Z(e));e.day>O(e.month,e.year)&&(e.month===I.ELUL&&(e.year+=1),e.day-=O(e.month,e.year),e.month+=1,Z(e));$(e)}(e)}function $(e){e.month!==I.ADAR_II||e.isLeapYear()?e.month<1?(e.month+=H(e.year),e.year-=1,Z(e)):e.month>H(e.year)&&(e.month-=H(e.year),e.year+=1,Z(e)):(e.month-=1,Z(e)),delete e.abs0}function q(e,t,r){return new J(J.dayOnOrBefore(e,t.abs()+r))}var G=I.NISAN,Q=I.CHESHVAN,W=I.KISLEV,X=I.TEVET,ee=I.SHVAT,te=I.ADAR_I,re=I.ADAR_II;var ne={headers:{"plural-forms":"nplurals=2; plural=(n > 1);",language:"he"},contexts:{"":{Adar:["אַדָר"],"Adar I":["אַדָר א׳"],"Adar II":["אַדָר ב׳"],Av:["אָב"],Cheshvan:["חֶשְׁוָן"],Elul:["אֱלוּל"],Iyyar:["אִיָיר"],Kislev:["כִּסְלֵו"],Nisan:["נִיסָן"],"Sh'vat":["שְׁבָט"],Sivan:["סִיוָן"],Tamuz:["תַּמּוּז"],Tevet:["טֵבֵת"],Tishrei:["תִשְׁרֵי"]}}};A.addLocale("he",ne),A.addLocale("h",ne);var ae=ne.contexts[""],oe={};return Object.keys(ae).forEach((function(e){oe[e]=[A.hebrewStripNikkud(ae[e][0])]})),A.addLocale("he-x-NoNikud",{headers:ne.headers,contexts:{"":oe}}),e.HDate=J,e.Locale=A,e.gematriya=n,e.getBirthdayOrAnniversary=function(e,t){var r=J.isHDate(t)?t:new J(t),n=r.getFullYear();if(!(e<=n)){var a=Y(n),o=r.getMonth(),u=r.getDate();return o==te&&!a||o==re&&a?o=H(e):o!=Q||30!=u||F(e)?o==W&&30==u&&C(e)?(o=X,u=1):o==te&&30==u&&a&&!Y(e)&&(o=G,u=1):(o=W,u=1),new J(u,o,e)}},e.getYahrzeit=function(e,t){var r=J.isHDate(t)?t:new J(t),n={yy:r.getFullYear(),mm:r.getMonth(),dd:r.getDate()};if(!(e<=n.yy))return n.mm!=Q||30!=n.dd||F(n.yy+1)?n.mm==W&&30==n.dd&&C(n.yy+1)?n=S(M(e,X,1)-1):n.mm==re?n.mm=H(e):n.mm!=te||30!=n.dd||Y(e)||(n.dd=30,n.mm=ee):n=S(M(e,W,1)-1),n.mm!=Q||30!=n.dd||F(e)?n.mm==W&&30==n.dd&&C(e)&&(n.mm=X,n.dd=1):(n.mm=W,n.dd=1),new J(n.dd,n.mm,e)},e.greg=k,e.months=I,e.version="3.41.0",Object.defineProperty(e,"__esModule",{value:!0}),e}({});
1
+ /*! @hebcal/core v3.41.3 */
2
+ var hebcal=function(e){"use strict";function t(e){switch(e){case 1:return"א";case 2:return"ב";case 3:return"ג";case 4:return"ד";case 5:return"ה";case 6:return"ו";case 7:return"ז";case 8:return"ח";case 9:return"ט";case 10:return"י";case 20:return"כ";case 30:return"ל";case 40:return"מ";case 50:return"נ";case 60:return"ס";case 70:return"ע";case 80:return"פ";case 90:return"צ";case 100:return"ק";case 200:return"ר";case 300:return"ש";case 400:return"ת";default:return"*INVALID*"}}function r(e){for(var t=[];e>0;){if(15===e||16===e){t.push(9),t.push(e-9);break}var r=100,n=void 0;for(n=400;n>e;n-=r)n===r&&(r/=10);t.push(n),e-=n}return t}function n(e){var n=parseInt(e,10);if(!n)throw new TypeError("invalid parameter to gematriya ".concat(e));var a="",u=Math.floor(n/1e3);if(u>0&&5!==u){for(var o=r(u),i=0;i<o.length;i++)a+=t(o[i]);a+="׳"}var s=r(n%1e3);if(1==s.length)return a+t(s[0])+"׳";for(var c=0;c<s.length;c++)c+1===s.length&&(a+="״"),a+=t(s[c]);return a}function a(e){return a="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},a(e)}function u(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function i(e,t,r){return t&&o(e.prototype,t),r&&o(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function s(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var c=[0,31,28,31,30,31,30,31,31,30,31,30,31],h=[c,c.slice()];function l(e,t){return e-t*Math.floor(e/t)}function f(e,t){return Math.floor(e/t)}function y(e){return!(e%4||!(e%100)&&e%400)}function v(e){return"object"===a(e)&&Date.prototype===e.__proto__}function d(e){if(!v(e))throw new TypeError("Argument not a Date: ".concat(e));return m(e.getFullYear(),e.getMonth()+1,e.getDate())}function m(e,t,r){var n=e-1;return 365*n+f(n,4)-f(n,100)+f(n,400)+f(367*t-362,12)+(t<=2?0:y(e)?-1:-2)+r}function g(e){if("number"!=typeof e)throw new TypeError("Argument not a Number: ".concat(e));var t=function(e){var t=e-1,r=f(t,146097),n=l(t,146097),a=f(n,36524),u=l(n,36524),o=f(u,1461),i=f(l(u,1461),365),s=400*r+100*a+4*o+i;return 4!=a&&4!=i?s+1:s}(e=Math.trunc(e)),r=f(12*(e-m(t,1,1)+(e<m(t,3,1)?0:y(t)?1:2))+373,367),n=e-m(t,r,1)+1,a=new Date(t,r-1,n);return t<100&&t>=0&&a.setFullYear(t),a}h[1][2]=29;var b=function(){function e(){u(this,e)}return i(e,null,[{key:"isLeapYear",value:function(e){return y(e)}},{key:"daysInMonth",value:function(e,t){return function(e,t){return h[+y(t)][e]}(e,t)}},{key:"isDate",value:function(e){return v(e)}},{key:"dayOfYear",value:function(e){if(!v(e))throw new TypeError("Argument not a Date: ".concat(e));var t=e.getMonth(),r=e.getDate()+31*t;return t>1&&(r-=Math.floor((4*(t+1)+23)/10),y(e.getFullYear())&&r++),r}},{key:"greg2abs",value:function(e){return d(e)}},{key:"abs2greg",value:function(e){return g(e)}}]),e}();s(b,"monthNames",["","January","February","March","April","May","June","July","August","September","October","November","December"]);var k={headers:{"plural-forms":"nplurals=2; plural=(n!=1);"},contexts:{"":{}}},p={h:"he",a:"ashkenazi",s:"en","":"en"},w=function(){function e(){u(this,e)}return i(e,null,[{key:"lookupTranslation",value:function(e,t){var r=t&&t.toLowerCase(),n=("string"==typeof t&&this.locales[r]||this.activeLocale)[e];if(n&&n.length&&n[0].length)return n[0]}},{key:"gettext",value:function(e,t){var r=this.lookupTranslation(e,t);return void 0===r?e:r}},{key:"addLocale",value:function(e,t){if("object"!==a(t.contexts)||"object"!==a(t.contexts[""]))throw new TypeError("Locale '".concat(e,"' invalid compact format"));this.locales[e.toLowerCase()]=t.contexts[""]}},{key:"useLocale",value:function(e){var t=e.toLowerCase(),r=this.locales[t];if(!r)throw new RangeError("Locale '".concat(e,"' not found"));return this.activeName=p[t]||t,this.activeLocale=r,this.activeLocale}},{key:"getLocaleName",value:function(){return this.activeName}},{key:"getLocaleNames",value:function(){return Object.keys(this.locales).sort()}},{key:"ordinal",value:function(e,t){var r=t&&t.toLowerCase()||this.activeName;if(!r)return this.getEnOrdinal(e);switch(r){case"en":case"s":case"a":case"ashkenazi":case"ashkenazi_litvish":case"ashkenazi_poylish":case"ashkenazi_standard":return this.getEnOrdinal(e);case"es":return e+"º";case"h":case"he":case"he-x-nonikud":return String(e);default:return e+"."}}},{key:"getEnOrdinal",value:function(e){var t=["th","st","nd","rd"],r=e%100;return e+(t[(r-20)%10]||t[r]||t[0])}},{key:"hebrewStripNikkud",value:function(e){return e.replace(/[\u0590-\u05bd]/g,"").replace(/[\u05bf-\u05c7]/g,"")}}]),e}();s(w,"locales",Object.create(null)),s(w,"activeLocale",null),s(w,"activeName",null),w.addLocale("en",k),w.addLocale("s",k),w.addLocale("",k),w.useLocale("en");var A={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},I=["","Nisan","Iyyar","Sivan","Tamuz","Av","Elul","Tishrei","Cheshvan","Kislev","Tevet","Sh'vat"],N=[I.concat(["Adar","Nisan"]),I.concat(["Adar I","Adar II","Nisan"])],E=Object.create(null),D=-1373428;function T(e,t,r){var n=r;if(t<7){for(var a=7;a<=Y(e);a++)n+=H(a,e);for(var u=1;u<t;u++)n+=H(u,e)}else for(var o=7;o<t;o++)n+=H(o,e);return D+V(e)+n-1}function L(e){return D+V(e)}function M(e){if("number"!=typeof e||isNaN(e))throw new TypeError("invalid parameter to abs2hebrew ".concat(e));e=Math.trunc(e);for(var t=Math.floor((e-D)/365.24682220597794);L(t)<=e;)++t;for(var r=e<T(--t,1,1)?7:1;e>T(t,r,H(r,t));)++r;return{yy:t,mm:r,dd:1+e-T(t,r,1)}}function S(e){return(1+7*e)%19<7}function Y(e){return 12+S(e)}function H(e,t){switch(e){case 2:case 4:case 6:case 10:case 13:return 29}return 12===e&&!S(t)||8===e&&!_(t)||9===e&&F(t)?29:30}function O(e,t){if("number"!=typeof e||isNaN(e)||e<1||e>14)throw new TypeError("bad month argument ".concat(e));return N[+S(t)][e]}function V(e){var t=E[e]=E[e]||function(e){var t=e-1,r=235*Math.floor(t/19)+t%19*12+Math.floor((t%19*7+1)/19),n=204+r%1080*793,a=5+12*r+793*Math.floor(r/1080)+Math.floor(n/1080),u=n%1080+a%24*1080,o=1+29*r+Math.floor(a/24),i=o+(u>=19440||2==o%7&&u>=9924&&!S(e)||1==o%7&&u>=16789&&S(t));return i+(i%7==0||i%7==3||i%7==5)}(e);return t}function R(e){return V(e+1)-V(e)}function _(e){return R(e)%10==5}function F(e){return R(e)%10==3}function C(e){throw new TypeError(e)}var x="day",j="week",z="month",U="year",K={d:x,w:j,M:z,y:U},B={day:x,week:j,month:z,year:U},P=function(){function e(t,r,n){if(u(this,e),2==arguments.length||arguments.length>3)throw new TypeError("HDate constructor requires 0, 1 or 3 arguments");if(3==arguments.length){if(this.day=this.month=1,n=parseInt(n,10),isNaN(n))throw new TypeError("HDate called with bad year argument: ".concat(n));if(this.year=n,this.setMonth(r),t=parseInt(t,10),isNaN(t))throw new TypeError("HDate called with bad day argument: ".concat(t));this.setDate(t)}else{void 0===t&&(t=new Date);var a="number"!=typeof t||isNaN(t)?v(t)?d(t):e.isHDate(t)?{dd:t.day,mm:t.month,yy:t.year}:C("HDate called with bad argument: ".concat(t)):t,o="number"==typeof a,i=o?M(a):a;this.day=i.dd,this.month=i.mm,this.year=i.yy,o&&(this.abs0=a)}}return i(e,[{key:"getFullYear",value:function(){return this.year}},{key:"isLeapYear",value:function(){return S(this.year)}},{key:"getMonth",value:function(){return this.month}},{key:"getTishreiMonth",value:function(){var e=Y(this.getFullYear());return(this.getMonth()+e-6)%e||e}},{key:"daysInMonth",value:function(){return H(this.getMonth(),this.getFullYear())}},{key:"getDate",value:function(){return this.day}},{key:"getDay",value:function(){return l(this.abs(),7)}},{key:"setFullYear",value:function(e){return this.year=e,J(this),this}},{key:"setMonth",value:function(t){return this.month=e.monthNum(t),J(this),this}},{key:"setDate",value:function(e){return this.day=e,J(this),this}},{key:"greg",value:function(){return g(this.abs())}},{key:"abs",value:function(){return"number"!=typeof this.abs0&&(this.abs0=T(this.year,this.month,this.day)),this.abs0}},{key:"getMonthName",value:function(){return O(this.getMonth(),this.getFullYear())}},{key:"render",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null,r=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],n=t||w.getLocaleName(),a=this.getDate(),u=w.gettext(this.getMonthName(),n),o=w.ordinal(a,n),i=e.getDayOfTranslation(n),s="".concat(o).concat(i," ").concat(u);if(r){var c=this.getFullYear();return"".concat(s,", ").concat(c)}return s}},{key:"renderGematriya",value:function(){var e=this.getDate(),t=w.gettext(this.getMonthName(),"he"),r=this.getFullYear();return n(e)+" "+t+" "+n(r)}},{key:"before",value:function(e){return $(e,this,-1)}},{key:"onOrBefore",value:function(e){return $(e,this,0)}},{key:"nearest",value:function(e){return $(e,this,3)}},{key:"onOrAfter",value:function(e){return $(e,this,6)}},{key:"after",value:function(e){return $(e,this,7)}},{key:"next",value:function(){return new e(this.abs()+1)}},{key:"prev",value:function(){return new e(this.abs()-1)}},{key:"add",value:function(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"d";if(!(t=parseInt(t,10)))return new e(this);if((r=e.standardizeUnits(r))===x)return new e(this.abs()+t);if(r===j)return new e(this.abs()+7*t);if(r===U)return new e(this.getDate(),this.getMonth(),this.getFullYear()+t);if(r===z){var n=new e(this),a=t>0?1:-1;t=Math.abs(t);for(var u=0;u<t;u++)n=new e(n.abs()+a*n.daysInMonth());return n}}},{key:"subtract",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"d";return this.add(-1*e,t)}},{key:"deltaDays",value:function(t){if(!e.isHDate(t))throw new TypeError("Bad argument: ".concat(t));return this.abs()-t.abs()}},{key:"isSameDate",value:function(t){return!!e.isHDate(t)&&(this.year==t.year&&this.month==t.month&&this.day==t.day)}},{key:"toString",value:function(){var e=this.getDate(),t=this.getFullYear(),r=this.getMonthName();return"".concat(e," ").concat(r," ").concat(t)}}],[{key:"hebrew2abs",value:function(e,t,r){return T(e,t,r)}},{key:"abs2hebrew",value:function(e){return M(e)}},{key:"getDayOfTranslation",value:function(e){switch(e){case"en":case"s":case"a":case"ashkenazi":return" of"}var t=w.lookupTranslation("of",e);return t?" "+t:"ashkenazi"===e.substring(0,9)?" of":""}},{key:"standardizeUnits",value:function(e){var t=K[e]||String(e||"").toLowerCase().replace(/s$/,"");return B[t]||C("Invalid units '".concat(e,"'"))}},{key:"isLeapYear",value:function(e){return S(e)}},{key:"monthsInYear",value:function(e){return Y(e)}},{key:"daysInMonth",value:function(e,t){return H(e,t)}},{key:"getMonthName",value:function(e,t){return O(e,t)}},{key:"monthNum",value:function(t){if("number"==typeof t){if(isNaN(t)||t>14)throw new RangeError("Invalid month number: ".concat(t));return t}return t.charCodeAt(0)>=48&&t.charCodeAt(0)<=57?parseInt(t,10):e.monthFromName(t)}},{key:"daysInYear",value:function(e){return R(e)}},{key:"longCheshvan",value:function(e){return _(e)}},{key:"shortKislev",value:function(e){return F(e)}},{key:"monthFromName",value:function(e){if("number"==typeof e){if(isNaN(e)||e<1||e>14)throw new RangeError("Invalid month name: ".concat(e));return e}var t=e.toLowerCase();switch(t[0]){case"n":case"נ":if("o"==t[1])break;return A.NISAN;case"i":return A.IYYAR;case"e":return A.ELUL;case"c":case"ח":return A.CHESHVAN;case"k":case"כ":return A.KISLEV;case"s":switch(t[1]){case"i":return A.SIVAN;case"h":return A.SHVAT}case"t":switch(t[1]){case"a":return A.TAMUZ;case"i":return A.TISHREI;case"e":return A.TEVET}break;case"a":switch(t[1]){case"v":return A.AV;case"d":return/(1|[^i]i|a|א)$/i.test(e)?A.ADAR_I:A.ADAR_II}break;case"ס":return A.SIVAN;case"ט":return A.TEVET;case"ש":return A.SHVAT;case"א":switch(t[1]){case"ב":return A.AV;case"ד":return/(1|[^i]i|a|א)$/i.test(e)?A.ADAR_I:A.ADAR_II;case"י":return A.IYYAR;case"ל":return A.ELUL}break;case"ת":switch(t[1]){case"מ":return A.TAMUZ;case"ש":return A.TISHREI}}throw new RangeError("Unable to parse month name: ".concat(e))}},{key:"dayOnOrBefore",value:function(e,t){return t-(t-e)%7}},{key:"isHDate",value:function(e){return null!==e&&"object"===a(e)&&"number"==typeof e.year&&"number"==typeof e.month&&"number"==typeof e.day&&"function"==typeof e.greg&&"function"==typeof e.abs}}]),e}();function J(e){Z(e),function(e){e.day<1&&(e.month==A.TISHREI&&(e.year-=1),e.day+=H(e.month,e.year),e.month-=1,J(e));e.day>H(e.month,e.year)&&(e.month===A.ELUL&&(e.year+=1),e.day-=H(e.month,e.year),e.month+=1,J(e));Z(e)}(e)}function Z(e){e.month!==A.ADAR_II||e.isLeapYear()?e.month<1?(e.month+=Y(e.year),e.year-=1,J(e)):e.month>Y(e.year)&&(e.month-=Y(e.year),e.year+=1,J(e)):(e.month-=1,J(e)),delete e.abs0}function $(e,t,r){return new P(P.dayOnOrBefore(e,t.abs()+r))}var q=A.NISAN,G=A.CHESHVAN,Q=A.KISLEV,W=A.TEVET,X=A.SHVAT,ee=A.ADAR_I,te=A.ADAR_II;var re={headers:{"plural-forms":"nplurals=2; plural=(n > 1);",language:"he"},contexts:{"":{Adar:["אַדָר"],"Adar I":["אַדָר א׳"],"Adar II":["אַדָר ב׳"],Av:["אָב"],Cheshvan:["חֶשְׁוָן"],Elul:["אֱלוּל"],Iyyar:["אִיָיר"],Kislev:["כִּסְלֵו"],Nisan:["נִיסָן"],"Sh'vat":["שְׁבָט"],Sivan:["סִיוָן"],Tamuz:["תַּמּוּז"],Tevet:["טֵבֵת"],Tishrei:["תִשְׁרֵי"]}}};w.addLocale("he",re),w.addLocale("h",re);var ne=re.contexts[""],ae={};return Object.keys(ne).forEach((function(e){ae[e]=[w.hebrewStripNikkud(ne[e][0])]})),w.addLocale("he-x-NoNikud",{headers:re.headers,contexts:{"":ae}}),e.HDate=P,e.Locale=w,e.gematriya=n,e.getBirthdayOrAnniversary=function(e,t){var r=P.isHDate(t)?t:new P(t),n=r.getFullYear();if(!(e<=n)){var a=S(n),u=r.getMonth(),o=r.getDate();return u==ee&&!a||u==te&&a?u=Y(e):u!=G||30!=o||_(e)?u==Q&&30==o&&F(e)?(u=W,o=1):u==ee&&30==o&&a&&!S(e)&&(u=q,o=1):(u=Q,o=1),new P(o,u,e)}},e.getYahrzeit=function(e,t){var r=P.isHDate(t)?t:new P(t),n={yy:r.getFullYear(),mm:r.getMonth(),dd:r.getDate()};if(!(e<=n.yy))return n.mm!=G||30!=n.dd||_(n.yy+1)?n.mm==Q&&30==n.dd&&F(n.yy+1)?n=M(T(e,W,1)-1):n.mm==te?n.mm=Y(e):n.mm!=ee||30!=n.dd||S(e)||(n.dd=30,n.mm=X):n=M(T(e,Q,1)-1),n.mm!=G||30!=n.dd||_(e)?n.mm==Q&&30==n.dd&&F(e)&&(n.mm=W,n.dd=1):(n.mm=Q,n.dd=1),new P(n.dd,n.mm,e)},e.greg=b,e.months=A,e.version="3.41.3",Object.defineProperty(e,"__esModule",{value:!0}),e}({});
package/dist/hdate.js CHANGED
@@ -1,4 +1,4 @@
1
- /*! @hebcal/core v3.41.0 */
1
+ /*! @hebcal/core v3.41.3 */
2
2
  'use strict';
3
3
 
4
4
  Object.defineProperty(exports, '__esModule', { value: true });
@@ -231,32 +231,11 @@ function daysInMonth$1(month, year) {
231
231
  function isDate(obj) {
232
232
  return typeof obj === 'object' && Date.prototype === obj.__proto__;
233
233
  }
234
- /**
235
- * Returns number of days since January 1 of that year
236
- * @private
237
- * @param {Date} date Gregorian date
238
- * @return {number}
239
- */
240
-
241
- function dayOfYear(date) {
242
- if (!isDate(date)) {
243
- throw new TypeError(`Argument not a Date: ${date}`);
244
- }
245
-
246
- const month = date.getMonth();
247
- let doy = date.getDate() + 31 * month;
248
-
249
- if (month > 1) {
250
- // FEB
251
- doy -= Math.floor((4 * (month + 1) + 23) / 10);
252
-
253
- if (isLeapYear$1(date.getFullYear())) {
254
- doy++;
255
- }
256
- }
234
+ /*
235
+ const ABS_14SEP1752 = 639797;
236
+ const ABS_2SEP1752 = 639785;
237
+ */
257
238
 
258
- return doy;
259
- }
260
239
  /**
261
240
  * Converts Gregorian date to absolute R.D. (Rata Die) days
262
241
  * @private
@@ -269,12 +248,14 @@ function greg2abs(date) {
269
248
  throw new TypeError(`Argument not a Date: ${date}`);
270
249
  }
271
250
 
272
- const year = date.getFullYear() - 1;
273
- return dayOfYear(date) + // days this year
274
- 365 * year + ( // + days in prior years
275
- Math.floor(year / 4) - // + Julian Leap years
276
- Math.floor(year / 100) + // - century years
277
- Math.floor(year / 400)); // + Gregorian leap years
251
+ const abs = toFixed(date.getFullYear(), date.getMonth() + 1, date.getDate());
252
+ /*
253
+ if (abs < ABS_14SEP1752 && abs > ABS_2SEP1752) {
254
+ throw new RangeError(`Invalid Date: ${date}`);
255
+ }
256
+ */
257
+
258
+ return abs;
278
259
  }
279
260
  /**
280
261
  * @private
@@ -297,8 +278,8 @@ function yearFromFixed(abs) {
297
278
  /**
298
279
  * @private
299
280
  * @param {number} year
300
- * @param {number} month
301
- * @param {number} day
281
+ * @param {number} month (1-12)
282
+ * @param {number} day (1-31)
302
283
  * @return {number}
303
284
  */
304
285
 
@@ -325,6 +306,12 @@ function abs2greg(abs) {
325
306
  }
326
307
 
327
308
  abs = Math.trunc(abs);
309
+ /*
310
+ if (abs < ABS_14SEP1752 && abs > ABS_2SEP1752) {
311
+ throw new RangeError(`Invalid Date: ${abs}`);
312
+ }
313
+ */
314
+
328
315
  const year = yearFromFixed(abs);
329
316
  const priorDays = abs - toFixed(year, 1, 1);
330
317
  const correction = abs < toFixed(year, 3, 1) ? 0 : isLeapYear$1(year) ? 1 : 2;
@@ -402,13 +389,30 @@ class greg {
402
389
  }
403
390
  /**
404
391
  * Returns number of days since January 1 of that year
392
+ * @deprecated
405
393
  * @param {Date} date Gregorian date
406
394
  * @return {number}
407
395
  */
408
396
 
409
397
 
410
398
  static dayOfYear(date) {
411
- return dayOfYear(date);
399
+ if (!isDate(date)) {
400
+ throw new TypeError(`Argument not a Date: ${date}`);
401
+ }
402
+
403
+ const month = date.getMonth();
404
+ let doy = date.getDate() + 31 * month;
405
+
406
+ if (month > 1) {
407
+ // FEB
408
+ doy -= Math.floor((4 * (month + 1) + 23) / 10);
409
+
410
+ if (isLeapYear$1(date.getFullYear())) {
411
+ doy++;
412
+ }
413
+ }
414
+
415
+ return doy;
412
416
  }
413
417
  /**
414
418
  * Converts Gregorian date to absolute R.D. (Rata Die) days
@@ -1949,7 +1953,7 @@ function getBirthdayOrAnniversary_(hyear, gdate) {
1949
1953
  return new HDate(day, month, hyear);
1950
1954
  }
1951
1955
 
1952
- const version="3.41.0";
1956
+ const version="3.41.3";
1953
1957
 
1954
1958
  const headers={"plural-forms":"nplurals=2; plural=(n > 1);",language:"he"};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};
1955
1959
 
package/dist/hdate.mjs CHANGED
@@ -1,4 +1,4 @@
1
- /*! @hebcal/core v3.41.0 */
1
+ /*! @hebcal/core v3.41.3 */
2
2
  const GERESH = '׳';
3
3
  const GERSHAYIM = '״';
4
4
 
@@ -167,27 +167,10 @@ function isDate(obj) {
167
167
  return typeof obj === 'object' && Date.prototype === obj.__proto__;
168
168
  }
169
169
 
170
- /**
171
- * Returns number of days since January 1 of that year
172
- * @private
173
- * @param {Date} date Gregorian date
174
- * @return {number}
175
- */
176
- function dayOfYear(date) {
177
- if (!isDate(date)) {
178
- throw new TypeError(`Argument not a Date: ${date}`);
179
- }
180
- const month = date.getMonth();
181
- let doy = date.getDate() + 31 * month;
182
- if (month > 1) {
183
- // FEB
184
- doy -= Math.floor((4 * (month + 1) + 23) / 10);
185
- if (isLeapYear$1(date.getFullYear())) {
186
- doy++;
187
- }
188
- }
189
- return doy;
190
- }
170
+ /*
171
+ const ABS_14SEP1752 = 639797;
172
+ const ABS_2SEP1752 = 639785;
173
+ */
191
174
 
192
175
  /**
193
176
  * Converts Gregorian date to absolute R.D. (Rata Die) days
@@ -199,14 +182,13 @@ function greg2abs(date) {
199
182
  if (!isDate(date)) {
200
183
  throw new TypeError(`Argument not a Date: ${date}`);
201
184
  }
202
- const year = date.getFullYear() - 1;
203
- return (
204
- dayOfYear(date) + // days this year
205
- 365 * year + // + days in prior years
206
- (Math.floor(year / 4) - // + Julian Leap years
207
- Math.floor(year / 100) + // - century years
208
- Math.floor(year / 400))
209
- ); // + Gregorian leap years
185
+ const abs = toFixed(date.getFullYear(), date.getMonth() + 1, date.getDate());
186
+ /*
187
+ if (abs < ABS_14SEP1752 && abs > ABS_2SEP1752) {
188
+ throw new RangeError(`Invalid Date: ${date}`);
189
+ }
190
+ */
191
+ return abs;
210
192
  }
211
193
 
212
194
  /**
@@ -230,8 +212,8 @@ function yearFromFixed(abs) {
230
212
  /**
231
213
  * @private
232
214
  * @param {number} year
233
- * @param {number} month
234
- * @param {number} day
215
+ * @param {number} month (1-12)
216
+ * @param {number} day (1-31)
235
217
  * @return {number}
236
218
  */
237
219
  function toFixed(year, month, day) {
@@ -260,6 +242,11 @@ function abs2greg(abs) {
260
242
  throw new TypeError(`Argument not a Number: ${abs}`);
261
243
  }
262
244
  abs = Math.trunc(abs);
245
+ /*
246
+ if (abs < ABS_14SEP1752 && abs > ABS_2SEP1752) {
247
+ throw new RangeError(`Invalid Date: ${abs}`);
248
+ }
249
+ */
263
250
  const year = yearFromFixed(abs);
264
251
  const priorDays = abs - toFixed(year, 1, 1);
265
252
  const correction = abs < toFixed(year, 3, 1) ? 0 : (isLeapYear$1(year) ? 1 : 2);
@@ -348,11 +335,24 @@ class greg {
348
335
 
349
336
  /**
350
337
  * Returns number of days since January 1 of that year
338
+ * @deprecated
351
339
  * @param {Date} date Gregorian date
352
340
  * @return {number}
353
341
  */
354
342
  static dayOfYear(date) {
355
- return dayOfYear(date);
343
+ if (!isDate(date)) {
344
+ throw new TypeError(`Argument not a Date: ${date}`);
345
+ }
346
+ const month = date.getMonth();
347
+ let doy = date.getDate() + 31 * month;
348
+ if (month > 1) {
349
+ // FEB
350
+ doy -= Math.floor((4 * (month + 1) + 23) / 10);
351
+ if (isLeapYear$1(date.getFullYear())) {
352
+ doy++;
353
+ }
354
+ }
355
+ return doy;
356
356
  }
357
357
 
358
358
  /**
@@ -1761,7 +1761,7 @@ function getBirthdayOrAnniversary_(hyear, gdate) {
1761
1761
  return new HDate(day, month, hyear);
1762
1762
  }
1763
1763
 
1764
- const version="3.41.0";
1764
+ const version="3.41.3";
1765
1765
 
1766
1766
  const headers={"plural-forms":"nplurals=2; plural=(n > 1);",language:"he"};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
1767
 
@@ -1,4 +1,4 @@
1
- /*! @hebcal/core v3.41.0 */
1
+ /*! @hebcal/core v3.41.3 */
2
2
  var hebcal = (function (exports) {
3
3
  'use strict';
4
4
 
@@ -63,32 +63,11 @@ function isLeapYear$1(year) {
63
63
  function isDate(obj) {
64
64
  return _typeof(obj) === 'object' && Date.prototype === obj.__proto__;
65
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 month = date.getMonth();
79
- var doy = date.getDate() + 31 * month;
80
-
81
- if (month > 1) {
82
- // FEB
83
- doy -= Math.floor((4 * (month + 1) + 23) / 10);
84
-
85
- if (isLeapYear$1(date.getFullYear())) {
86
- doy++;
87
- }
88
- }
66
+ /*
67
+ const ABS_14SEP1752 = 639797;
68
+ const ABS_2SEP1752 = 639785;
69
+ */
89
70
 
90
- return doy;
91
- }
92
71
  /**
93
72
  * Converts Gregorian date to absolute R.D. (Rata Die) days
94
73
  * @private
@@ -101,12 +80,14 @@ function greg2abs(date) {
101
80
  throw new TypeError("Argument not a Date: ".concat(date));
102
81
  }
103
82
 
104
- var year = date.getFullYear() - 1;
105
- return dayOfYear(date) + // days this year
106
- 365 * year + ( // + days in prior years
107
- Math.floor(year / 4) - // + Julian Leap years
108
- Math.floor(year / 100) + // - century years
109
- Math.floor(year / 400)); // + Gregorian leap years
83
+ var abs = toFixed(date.getFullYear(), date.getMonth() + 1, date.getDate());
84
+ /*
85
+ if (abs < ABS_14SEP1752 && abs > ABS_2SEP1752) {
86
+ throw new RangeError(`Invalid Date: ${date}`);
87
+ }
88
+ */
89
+
90
+ return abs;
110
91
  }
111
92
  /**
112
93
  * @private
@@ -129,8 +110,8 @@ function yearFromFixed(abs) {
129
110
  /**
130
111
  * @private
131
112
  * @param {number} year
132
- * @param {number} month
133
- * @param {number} day
113
+ * @param {number} month (1-12)
114
+ * @param {number} day (1-31)
134
115
  * @return {number}
135
116
  */
136
117
 
@@ -157,6 +138,12 @@ function abs2greg(abs) {
157
138
  }
158
139
 
159
140
  abs = Math.trunc(abs);
141
+ /*
142
+ if (abs < ABS_14SEP1752 && abs > ABS_2SEP1752) {
143
+ throw new RangeError(`Invalid Date: ${abs}`);
144
+ }
145
+ */
146
+
160
147
  var year = yearFromFixed(abs);
161
148
  var priorDays = abs - toFixed(year, 1, 1);
162
149
  var correction = abs < toFixed(year, 3, 1) ? 0 : isLeapYear$1(year) ? 1 : 2;
@@ -1,2 +1,2 @@
1
- /*! @hebcal/core v3.41.0 */
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 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"],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+p(r)+e-1}function y(r){return l+p(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&&I(t)?29:30}function p(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 M(r){return p(r+1)-p(r)}function A(r){return M(r)%10==5}function I(r){return M(r)%10==3}var w={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:M,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: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),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.getMonth(),n=r.getDate()+31*t;return t>1&&(n-=Math.floor((4*(t+1)+23)/10),a(r.getFullYear())&&n++),n}(r)+365*t+(Math.floor(t/4)-Math.floor(t/100)+Math.floor(t/400))},r.hdate=w,Object.defineProperty(r,"__esModule",{value:!0}),r}({});
1
+ /*! @hebcal/core v3.41.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}({});