@hebcal/core 3.38.0 → 3.38.1

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.
@@ -217,10 +217,14 @@ function _defineProperty(obj, key, value) {
217
217
  return obj;
218
218
  }
219
219
 
220
- /**
220
+ /*
221
221
  * More minimal greg routines
222
222
  */
223
+
224
+ /** @private */
223
225
  var lengths = [0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
226
+ /** @private */
227
+
224
228
  var monthLengths = [lengths, lengths.slice()];
225
229
  monthLengths[1][2] = 29;
226
230
  /**
@@ -285,7 +289,7 @@ function isDate(obj) {
285
289
 
286
290
  function dayOfYear(date) {
287
291
  if (!isDate(date)) {
288
- throw new TypeError('Argument to greg.dayOfYear not a Date');
292
+ throw new TypeError("Argument not a Date: ".concat(date));
289
293
  }
290
294
 
291
295
  var doy = date.getDate() + 31 * date.getMonth();
@@ -310,7 +314,7 @@ function dayOfYear(date) {
310
314
 
311
315
  function greg2abs(date) {
312
316
  if (!isDate(date)) {
313
- throw new TypeError('Argument to greg.greg2abs not a Date');
317
+ throw new TypeError("Argument not a Date: ".concat(date));
314
318
  }
315
319
 
316
320
  var year = date.getFullYear() - 1;
@@ -365,7 +369,7 @@ function toFixed(year, month, day) {
365
369
 
366
370
  function abs2greg(abs) {
367
371
  if (typeof abs !== 'number') {
368
- throw new TypeError('Argument to greg.abs2greg not a Number');
372
+ throw new TypeError("Argument not a Number: ".concat(abs));
369
373
  }
370
374
 
371
375
  abs = Math.trunc(abs);
@@ -684,7 +688,7 @@ Locale.addLocale('s', noopLocale);
684
688
  Locale.addLocale('', noopLocale);
685
689
  Locale.useLocale('en');
686
690
 
687
- /**
691
+ /*
688
692
  * More minimal HDate
689
693
  */
690
694
  var NISAN$1 = 1;
@@ -762,6 +766,7 @@ var AVG_HEBYEAR_DAYS = 365.24682220597794;
762
766
  * Converts Hebrew date to R.D. (Rata Die) fixed days.
763
767
  * R.D. 1 is the imaginary date Monday, January 1, 1 on the Gregorian
764
768
  * Calendar.
769
+ * @private
765
770
  * @param {number} year Hebrew year
766
771
  * @param {number} month Hebrew month
767
772
  * @param {number} day Hebrew date (1-30)
@@ -794,25 +799,7 @@ function hebrew2abs(year, month, day) {
794
799
  */
795
800
 
796
801
  function newYear(year) {
797
- return EPOCH + elapsedDays(year) + newYearDelay(year);
798
- }
799
- /**
800
- * @private
801
- * @param {number} year
802
- * @return {number}
803
- */
804
-
805
-
806
- function newYearDelay(year) {
807
- var ny1 = elapsedDays(year);
808
- var ny2 = elapsedDays(year + 1);
809
-
810
- if (ny2 - ny1 === 356) {
811
- return 2;
812
- } else {
813
- var ny0 = elapsedDays(year - 1);
814
- return ny1 - ny0 === 382 ? 1 : 0;
815
- }
802
+ return EPOCH + elapsedDays(year);
816
803
  }
817
804
  /**
818
805
  * Converts absolute R.D. days to Hebrew date
@@ -851,6 +838,7 @@ function abs2hebrew(abs) {
851
838
  }
852
839
  /**
853
840
  * Returns true if Hebrew year is a leap year
841
+ * @private
854
842
  * @param {number} year Hebrew year
855
843
  * @return {boolean}
856
844
  */
@@ -860,6 +848,7 @@ function isLeapYear(year) {
860
848
  }
861
849
  /**
862
850
  * Number of months in this Hebrew year (either 12 or 13 depending on leap year)
851
+ * @private
863
852
  * @param {number} year Hebrew year
864
853
  * @return {number}
865
854
  */
@@ -869,6 +858,7 @@ function monthsInYear(year) {
869
858
  }
870
859
  /**
871
860
  * Number of days in Hebrew month in a given year (29 or 30)
861
+ * @private
872
862
  * @param {number} month Hebrew month (e.g. months.TISHREI)
873
863
  * @param {number} year Hebrew year
874
864
  * @return {number}
@@ -893,13 +883,14 @@ function daysInMonth(month, year) {
893
883
  /**
894
884
  * Returns a transliterated string name of Hebrew month in year,
895
885
  * for example 'Elul' or 'Cheshvan'.
886
+ * @private
896
887
  * @param {number} month Hebrew month (e.g. months.TISHREI)
897
888
  * @param {number} year Hebrew year
898
889
  * @return {string}
899
890
  */
900
891
 
901
892
  function getMonthName(month, year) {
902
- if (typeof month !== 'number' || month < 1 || month > 14) {
893
+ if (typeof month !== 'number' || isNaN(month) || month < 1 || month > 14) {
903
894
  throw new TypeError("bad month argument ".concat(month));
904
895
  }
905
896
 
@@ -908,6 +899,7 @@ function getMonthName(month, year) {
908
899
  /**
909
900
  * Days from sunday prior to start of Hebrew calendar to mean
910
901
  * conjunction of Tishrei in Hebrew YEAR
902
+ * @private
911
903
  * @param {number} year Hebrew year
912
904
  * @return {number}
913
905
  */
@@ -938,7 +930,10 @@ function elapsedDays0(year) {
938
930
  return altDay + (altDay % 7 === 0 || altDay % 7 === 3 || altDay % 7 === 5);
939
931
  }
940
932
  /**
941
- * Number of days in the hebrew YEAR
933
+ * Number of days in the hebrew YEAR.
934
+ * A common Hebrew calendar year can have a length of 353, 354 or 355 days
935
+ * A leap Hebrew calendar year can have a length of 383, 384 or 385 days
936
+ * @private
942
937
  * @param {number} year Hebrew year
943
938
  * @return {number}
944
939
  */
@@ -949,6 +944,7 @@ function daysInYear(year) {
949
944
  }
950
945
  /**
951
946
  * true if Cheshvan is long in Hebrew year
947
+ * @private
952
948
  * @param {number} year Hebrew year
953
949
  * @return {boolean}
954
950
  */
@@ -958,6 +954,7 @@ function longCheshvan(year) {
958
954
  }
959
955
  /**
960
956
  * true if Kislev is short in Hebrew year
957
+ * @private
961
958
  * @param {number} year Hebrew year
962
959
  * @return {boolean}
963
960
  */
@@ -1048,19 +1045,22 @@ var HDate = /*#__PURE__*/function () {
1048
1045
  * @type {number}
1049
1046
  */
1050
1047
 
1051
- this.year = +year;
1048
+ year = parseInt(year, 10);
1052
1049
 
1053
- if (isNaN(this.year)) {
1050
+ if (isNaN(year)) {
1054
1051
  throw new TypeError("HDate called with bad year argument: ".concat(year));
1055
1052
  }
1056
1053
 
1054
+ this.year = year;
1057
1055
  this.setMonth(month); // will throw if we can't parse
1058
1056
 
1059
- this.setDate(+day);
1057
+ day = parseInt(day, 10);
1060
1058
 
1061
- if (isNaN(this.day)) {
1059
+ if (isNaN(day)) {
1062
1060
  throw new TypeError("HDate called with bad day argument: ".concat(day));
1063
1061
  }
1062
+
1063
+ this.setDate(day);
1064
1064
  } else {
1065
1065
  // 0 arguments
1066
1066
  if (typeof day === 'undefined') {
@@ -1068,7 +1068,7 @@ var HDate = /*#__PURE__*/function () {
1068
1068
  } // 1 argument
1069
1069
 
1070
1070
 
1071
- var abs0 = typeof day === 'number' && !isNaN(day) ? day : greg.isDate(day) ? greg.greg2abs(day) : HDate.isHDate(day) ? {
1071
+ var abs0 = typeof day === 'number' && !isNaN(day) ? day : isDate(day) ? greg2abs(day) : HDate.isHDate(day) ? {
1072
1072
  dd: day.day,
1073
1073
  mm: day.month,
1074
1074
  yy: day.year
@@ -1225,8 +1225,8 @@ var HDate = /*#__PURE__*/function () {
1225
1225
 
1226
1226
  }, {
1227
1227
  key: "greg",
1228
- value: function greg$1() {
1229
- return greg.abs2greg(this.abs());
1228
+ value: function greg() {
1229
+ return abs2greg(this.abs());
1230
1230
  }
1231
1231
  /**
1232
1232
  * Returns R.D. (Rata Die) fixed days.
@@ -1654,7 +1654,15 @@ var HDate = /*#__PURE__*/function () {
1654
1654
  }, {
1655
1655
  key: "monthNum",
1656
1656
  value: function monthNum(month) {
1657
- return typeof month === 'number' ? month : month.charCodeAt(0) >= 48 && month.charCodeAt(0) <= 57 ?
1657
+ if (typeof month === 'number') {
1658
+ if (isNaN(month) || month > 14) {
1659
+ throw new RangeError("Invalid month number: ".concat(month));
1660
+ }
1661
+
1662
+ return month;
1663
+ }
1664
+
1665
+ return month.charCodeAt(0) >= 48 && month.charCodeAt(0) <= 57 ?
1658
1666
  /* number */
1659
1667
  parseInt(month, 10) : HDate.monthFromName(month);
1660
1668
  }
@@ -1700,7 +1708,14 @@ var HDate = /*#__PURE__*/function () {
1700
1708
  }, {
1701
1709
  key: "monthFromName",
1702
1710
  value: function monthFromName(monthName) {
1703
- if (typeof monthName === 'number') return monthName;
1711
+ if (typeof monthName === 'number') {
1712
+ if (isNaN(monthName) || monthName < 1 || monthName > 14) {
1713
+ throw new RangeError("Invalid month name: ".concat(monthName));
1714
+ }
1715
+
1716
+ return monthName;
1717
+ }
1718
+
1704
1719
  var c = monthName.toLowerCase();
1705
1720
  /*
1706
1721
  the Hebrew months are unique to their second letter
@@ -1,2 +1,2 @@
1
1
  /*! @hebcal/core v3.38.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="",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 to greg.dayOfYear not a Date");var t=e.getDate()+31*e.getMonth();return e.getMonth()>1&&(t-=Math.floor((4*(e.getMonth()+1)+23)/10),y(e.getFullYear())&&t++),t}function m(e,t,r){var n=e-1;return 0+365*n+f(n,4)-f(n,100)+f(n,400)+f(367*t-362,12)+Math.floor(t<=2?0:y(e)?-1:-2)+r}function g(e){if("number"!=typeof e)throw new TypeError("Argument to greg.abs2greg not a Number");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){return d(e)}},{key:"greg2abs",value:function(e){return function(e){if(!v(e))throw new TypeError("Argument to greg.greg2abs not a Date");var t=e.getFullYear()-1;return d(e)+365*t+(Math.floor(t/4)-Math.floor(t/100)+Math.floor(t/400))}(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"],M=[I.concat(["Adar","Nisan"]),I.concat(["Adar I","Adar II","Nisan"])],N=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 E(e){return D+V(e)+function(e){var t=V(e);return V(e+1)-t==356?2:t-V(e-1)==382?1:0}(e)}function L(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);E(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||e<1||e>14)throw new TypeError("bad month argument ".concat(e));return M[+S(t)][e]}function V(e){var t=N[e]=N[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 z="day",j="week",x="month",U="year",K={d:z,w:j,M:x,y:U},B={day:z,week:j,month:x,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,this.year=+n,isNaN(this.year))throw new TypeError("HDate called with bad year argument: ".concat(n));if(this.setMonth(r),this.setDate(+t),isNaN(this.day))throw new TypeError("HDate called with bad day argument: ".concat(t))}else{void 0===t&&(t=new Date);var a="number"!=typeof t||isNaN(t)?b.isDate(t)?b.greg2abs(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?L(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 b.abs2greg(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))===z)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===x){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 L(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){return"number"==typeof t?t: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)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:["תִשְׁרֵי"]}}};return w.addLocale("he",re),w.addLocale("h",re),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=L(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=L(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.38.0",Object.defineProperty(e,"__esModule",{value:!0}),e}({});
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 m(e){if(!v(e))throw new TypeError("Argument not a Date: ".concat(e));var t=e.getDate()+31*e.getMonth();return e.getMonth()>1&&(t-=Math.floor((4*(e.getMonth()+1)+23)/10),y(e.getFullYear())&&t++),t}function d(e){if(!v(e))throw new TypeError("Argument not a Date: ".concat(e));var t=e.getFullYear()-1;return m(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 0+365*n+f(n,4)-f(n,100)+f(n,400)+f(367*t-362,12)+Math.floor(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 m(e)}},{key:"greg2abs",value:function(e){return d(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"],M=[N.concat(["Adar","Nisan"]),N.concat(["Adar I","Adar II","Nisan"])],E=Object.create(null),T=-1373428;function D(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 T+R(e)+n-1}function L(e){return T+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-T)/365.24682220597794);L(t)<=e;)++t;for(var r=e<D(--t,1,1)?7:1;e>D(t,r,O(r,t));)++r;return{yy:t,mm:r,dd:1+e-D(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 M[+Y(t)][e]}function R(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),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 z(e){throw new TypeError(e)}var j="day",x="week",U="month",K="year",B={d:j,w:x,M:U,y:K},P={day:j,week:x,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)?d(t):e.isHDate(t)?{dd:t.day,mm:t.month,yy:t.year}:z("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=D(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===x)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 D(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]||z("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:["תִשְׁרֵי"]}}};return A.addLocale("he",ne),A.addLocale("h",ne),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(D(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(D(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.38.0",Object.defineProperty(e,"__esModule",{value:!0}),e}({});
package/dist/hdate.js CHANGED
@@ -168,10 +168,14 @@ function gematriya(number) {
168
168
  return str;
169
169
  }
170
170
 
171
- /**
171
+ /*
172
172
  * More minimal greg routines
173
173
  */
174
+
175
+ /** @private */
174
176
  const lengths = [0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
177
+ /** @private */
178
+
175
179
  const monthLengths = [lengths, lengths.slice()];
176
180
  monthLengths[1][2] = 29;
177
181
  /**
@@ -236,7 +240,7 @@ function isDate(obj) {
236
240
 
237
241
  function dayOfYear(date) {
238
242
  if (!isDate(date)) {
239
- throw new TypeError('Argument to greg.dayOfYear not a Date');
243
+ throw new TypeError(`Argument not a Date: ${date}`);
240
244
  }
241
245
 
242
246
  let doy = date.getDate() + 31 * date.getMonth();
@@ -261,7 +265,7 @@ function dayOfYear(date) {
261
265
 
262
266
  function greg2abs(date) {
263
267
  if (!isDate(date)) {
264
- throw new TypeError('Argument to greg.greg2abs not a Date');
268
+ throw new TypeError(`Argument not a Date: ${date}`);
265
269
  }
266
270
 
267
271
  const year = date.getFullYear() - 1;
@@ -316,7 +320,7 @@ function toFixed(year, month, day) {
316
320
 
317
321
  function abs2greg(abs) {
318
322
  if (typeof abs !== 'number') {
319
- throw new TypeError('Argument to greg.abs2greg not a Number');
323
+ throw new TypeError(`Argument not a Number: ${abs}`);
320
324
  }
321
325
 
322
326
  abs = Math.trunc(abs);
@@ -619,7 +623,7 @@ Locale.addLocale('s', noopLocale);
619
623
  Locale.addLocale('', noopLocale);
620
624
  Locale.useLocale('en');
621
625
 
622
- /**
626
+ /*
623
627
  * More minimal HDate
624
628
  */
625
629
  const NISAN$1 = 1;
@@ -697,6 +701,7 @@ const AVG_HEBYEAR_DAYS = 365.24682220597794;
697
701
  * Converts Hebrew date to R.D. (Rata Die) fixed days.
698
702
  * R.D. 1 is the imaginary date Monday, January 1, 1 on the Gregorian
699
703
  * Calendar.
704
+ * @private
700
705
  * @param {number} year Hebrew year
701
706
  * @param {number} month Hebrew month
702
707
  * @param {number} day Hebrew date (1-30)
@@ -729,25 +734,7 @@ function hebrew2abs(year, month, day) {
729
734
  */
730
735
 
731
736
  function newYear(year) {
732
- return EPOCH + elapsedDays(year) + newYearDelay(year);
733
- }
734
- /**
735
- * @private
736
- * @param {number} year
737
- * @return {number}
738
- */
739
-
740
-
741
- function newYearDelay(year) {
742
- const ny1 = elapsedDays(year);
743
- const ny2 = elapsedDays(year + 1);
744
-
745
- if (ny2 - ny1 === 356) {
746
- return 2;
747
- } else {
748
- const ny0 = elapsedDays(year - 1);
749
- return ny1 - ny0 === 382 ? 1 : 0;
750
- }
737
+ return EPOCH + elapsedDays(year);
751
738
  }
752
739
  /**
753
740
  * Converts absolute R.D. days to Hebrew date
@@ -786,6 +773,7 @@ function abs2hebrew(abs) {
786
773
  }
787
774
  /**
788
775
  * Returns true if Hebrew year is a leap year
776
+ * @private
789
777
  * @param {number} year Hebrew year
790
778
  * @return {boolean}
791
779
  */
@@ -795,6 +783,7 @@ function isLeapYear(year) {
795
783
  }
796
784
  /**
797
785
  * Number of months in this Hebrew year (either 12 or 13 depending on leap year)
786
+ * @private
798
787
  * @param {number} year Hebrew year
799
788
  * @return {number}
800
789
  */
@@ -804,6 +793,7 @@ function monthsInYear(year) {
804
793
  }
805
794
  /**
806
795
  * Number of days in Hebrew month in a given year (29 or 30)
796
+ * @private
807
797
  * @param {number} month Hebrew month (e.g. months.TISHREI)
808
798
  * @param {number} year Hebrew year
809
799
  * @return {number}
@@ -828,13 +818,14 @@ function daysInMonth(month, year) {
828
818
  /**
829
819
  * Returns a transliterated string name of Hebrew month in year,
830
820
  * for example 'Elul' or 'Cheshvan'.
821
+ * @private
831
822
  * @param {number} month Hebrew month (e.g. months.TISHREI)
832
823
  * @param {number} year Hebrew year
833
824
  * @return {string}
834
825
  */
835
826
 
836
827
  function getMonthName(month, year) {
837
- if (typeof month !== 'number' || month < 1 || month > 14) {
828
+ if (typeof month !== 'number' || isNaN(month) || month < 1 || month > 14) {
838
829
  throw new TypeError(`bad month argument ${month}`);
839
830
  }
840
831
 
@@ -843,6 +834,7 @@ function getMonthName(month, year) {
843
834
  /**
844
835
  * Days from sunday prior to start of Hebrew calendar to mean
845
836
  * conjunction of Tishrei in Hebrew YEAR
837
+ * @private
846
838
  * @param {number} year Hebrew year
847
839
  * @return {number}
848
840
  */
@@ -873,7 +865,10 @@ function elapsedDays0(year) {
873
865
  return altDay + (altDay % 7 === 0 || altDay % 7 === 3 || altDay % 7 === 5);
874
866
  }
875
867
  /**
876
- * Number of days in the hebrew YEAR
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
877
872
  * @param {number} year Hebrew year
878
873
  * @return {number}
879
874
  */
@@ -884,6 +879,7 @@ function daysInYear(year) {
884
879
  }
885
880
  /**
886
881
  * true if Cheshvan is long in Hebrew year
882
+ * @private
887
883
  * @param {number} year Hebrew year
888
884
  * @return {boolean}
889
885
  */
@@ -893,6 +889,7 @@ function longCheshvan(year) {
893
889
  }
894
890
  /**
895
891
  * true if Kislev is short in Hebrew year
892
+ * @private
896
893
  * @param {number} year Hebrew year
897
894
  * @return {boolean}
898
895
  */
@@ -1002,19 +999,22 @@ class HDate {
1002
999
  * @type {number}
1003
1000
  */
1004
1001
 
1005
- this.year = +year;
1002
+ year = parseInt(year, 10);
1006
1003
 
1007
- if (isNaN(this.year)) {
1004
+ if (isNaN(year)) {
1008
1005
  throw new TypeError(`HDate called with bad year argument: ${year}`);
1009
1006
  }
1010
1007
 
1008
+ this.year = year;
1011
1009
  this.setMonth(month); // will throw if we can't parse
1012
1010
 
1013
- this.setDate(+day);
1011
+ day = parseInt(day, 10);
1014
1012
 
1015
- if (isNaN(this.day)) {
1013
+ if (isNaN(day)) {
1016
1014
  throw new TypeError(`HDate called with bad day argument: ${day}`);
1017
1015
  }
1016
+
1017
+ this.setDate(day);
1018
1018
  } else {
1019
1019
  // 0 arguments
1020
1020
  if (typeof day === 'undefined') {
@@ -1022,7 +1022,7 @@ class HDate {
1022
1022
  } // 1 argument
1023
1023
 
1024
1024
 
1025
- const abs0 = typeof day === 'number' && !isNaN(day) ? day : greg.isDate(day) ? greg.greg2abs(day) : HDate.isHDate(day) ? {
1025
+ const abs0 = typeof day === 'number' && !isNaN(day) ? day : isDate(day) ? greg2abs(day) : HDate.isHDate(day) ? {
1026
1026
  dd: day.day,
1027
1027
  mm: day.month,
1028
1028
  yy: day.year
@@ -1167,7 +1167,7 @@ class HDate {
1167
1167
 
1168
1168
 
1169
1169
  greg() {
1170
- return greg.abs2greg(this.abs());
1170
+ return abs2greg(this.abs());
1171
1171
  }
1172
1172
  /**
1173
1173
  * Returns R.D. (Rata Die) fixed days.
@@ -1566,7 +1566,15 @@ class HDate {
1566
1566
 
1567
1567
 
1568
1568
  static monthNum(month) {
1569
- return typeof month === 'number' ? month : month.charCodeAt(0) >= 48 && month.charCodeAt(0) <= 57 ?
1569
+ if (typeof month === 'number') {
1570
+ if (isNaN(month) || month > 14) {
1571
+ throw new RangeError(`Invalid month number: ${month}`);
1572
+ }
1573
+
1574
+ return month;
1575
+ }
1576
+
1577
+ return month.charCodeAt(0) >= 48 && month.charCodeAt(0) <= 57 ?
1570
1578
  /* number */
1571
1579
  parseInt(month, 10) : HDate.monthFromName(month);
1572
1580
  }
@@ -1608,7 +1616,14 @@ class HDate {
1608
1616
 
1609
1617
 
1610
1618
  static monthFromName(monthName) {
1611
- if (typeof monthName === 'number') return monthName;
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
+
1612
1627
  const c = monthName.toLowerCase();
1613
1628
  /*
1614
1629
  the Hebrew months are unique to their second letter