@hebcal/core 3.50.3 → 4.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +55 -383
- package/dist/bundle.js +368 -835
- package/dist/bundle.min.js +2 -2
- package/dist/greg0.mjs +1 -1
- package/dist/hdate-bundle.js +28 -9
- package/dist/hdate-bundle.min.js +2 -2
- package/dist/hdate.js +28 -10
- package/dist/hdate.mjs +29 -10
- package/dist/hdate0-bundle.js +19 -5
- package/dist/hdate0-bundle.min.js +2 -2
- package/dist/hdate0.mjs +20 -5
- package/dist/index.js +181 -666
- package/dist/index.mjs +181 -657
- package/hebcal.d.ts +18 -103
- package/package.json +12 -12
package/dist/greg0.mjs
CHANGED
package/dist/hdate-bundle.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! @hebcal/core
|
|
1
|
+
/*! @hebcal/core v4.0.0 */
|
|
2
2
|
var hebcal = (function (exports) {
|
|
3
3
|
'use strict';
|
|
4
4
|
|
|
@@ -489,7 +489,7 @@ var Locale = /*#__PURE__*/function () {
|
|
|
489
489
|
/**
|
|
490
490
|
* Register locale translations.
|
|
491
491
|
* @param {string} locale Locale name (i.e.: `'he'`, `'fr'`)
|
|
492
|
-
* @param {
|
|
492
|
+
* @param {LocaleData} data parsed data from a `.po` file.
|
|
493
493
|
*/
|
|
494
494
|
}, {
|
|
495
495
|
key: "addLocale",
|
|
@@ -668,6 +668,17 @@ var EPOCH = -1373428;
|
|
|
668
668
|
// Avg year length in the cycle (19 solar years with 235 lunar months)
|
|
669
669
|
var AVG_HEBYEAR_DAYS = 365.24682220597794;
|
|
670
670
|
|
|
671
|
+
/**
|
|
672
|
+
* @private
|
|
673
|
+
* @param {any} n
|
|
674
|
+
* @param {string} name
|
|
675
|
+
*/
|
|
676
|
+
function assertNumber(n, name) {
|
|
677
|
+
if (typeof n !== 'number' || isNaN(n)) {
|
|
678
|
+
throw new TypeError("invalid parameter '".concat(name, "' not a number: ").concat(n));
|
|
679
|
+
}
|
|
680
|
+
}
|
|
681
|
+
|
|
671
682
|
/**
|
|
672
683
|
* Converts Hebrew date to R.D. (Rata Die) fixed days.
|
|
673
684
|
* R.D. 1 is the imaginary date Monday, January 1, 1 on the Gregorian
|
|
@@ -679,6 +690,9 @@ var AVG_HEBYEAR_DAYS = 365.24682220597794;
|
|
|
679
690
|
* @return {number}
|
|
680
691
|
*/
|
|
681
692
|
function hebrew2abs(year, month, day) {
|
|
693
|
+
assertNumber(year, 'year');
|
|
694
|
+
assertNumber(month, 'month');
|
|
695
|
+
assertNumber(day, 'day');
|
|
682
696
|
if (year < 1) {
|
|
683
697
|
throw new RangeError("hebrew2abs: invalid year ".concat(year));
|
|
684
698
|
}
|
|
@@ -714,9 +728,7 @@ function newYear(year) {
|
|
|
714
728
|
* @return {SimpleHebrewDate}
|
|
715
729
|
*/
|
|
716
730
|
function abs2hebrew(abs) {
|
|
717
|
-
|
|
718
|
-
throw new TypeError("invalid parameter to abs2hebrew ".concat(abs));
|
|
719
|
-
}
|
|
731
|
+
assertNumber(abs, 'abs');
|
|
720
732
|
abs = Math.trunc(abs);
|
|
721
733
|
if (abs <= EPOCH) {
|
|
722
734
|
throw new RangeError("abs2hebrew: ".concat(abs, " is before epoch"));
|
|
@@ -791,7 +803,9 @@ function daysInMonth(month, year) {
|
|
|
791
803
|
* @return {string}
|
|
792
804
|
*/
|
|
793
805
|
function getMonthName(month, year) {
|
|
794
|
-
|
|
806
|
+
assertNumber(month, 'month');
|
|
807
|
+
assertNumber(year, 'year');
|
|
808
|
+
if (month < 1 || month > 14) {
|
|
795
809
|
throw new TypeError("bad month argument ".concat(month));
|
|
796
810
|
}
|
|
797
811
|
return monthNames[+isLeapYear(year)][month];
|
|
@@ -1200,11 +1214,14 @@ var HDate = /*#__PURE__*/function () {
|
|
|
1200
1214
|
* import {HDate, months} from '@hebcal/core';
|
|
1201
1215
|
* const hd = new HDate(15, months.CHESHVAN, 5769);
|
|
1202
1216
|
* console.log(hd.renderGematriya()); // 'ט״ו חֶשְׁוָן תשס״ט'
|
|
1217
|
+
* @param {boolean} [suppressNikud]
|
|
1203
1218
|
* @return {string}
|
|
1204
1219
|
*/
|
|
1205
1220
|
function renderGematriya() {
|
|
1221
|
+
var suppressNikud = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
|
|
1206
1222
|
var d = this.getDate();
|
|
1207
|
-
var
|
|
1223
|
+
var locale = suppressNikud ? 'he-x-NoNikud' : 'he';
|
|
1224
|
+
var m = Locale.gettext(this.getMonthName(), locale);
|
|
1208
1225
|
var y = this.getFullYear();
|
|
1209
1226
|
return gematriya(d) + ' ' + m + ' ' + gematriya(y);
|
|
1210
1227
|
}
|
|
@@ -1848,7 +1865,9 @@ function getYahrzeit_(hyear, gdate) {
|
|
|
1848
1865
|
function getBirthdayOrAnniversary_(hyear, gdate) {
|
|
1849
1866
|
var orig = HDate.isHDate(gdate) ? gdate : new HDate(gdate);
|
|
1850
1867
|
var origYear = orig.getFullYear();
|
|
1851
|
-
if (hyear
|
|
1868
|
+
if (hyear === origYear) {
|
|
1869
|
+
return orig;
|
|
1870
|
+
} else if (hyear < origYear) {
|
|
1852
1871
|
// `Hebrew year ${hyear} occurs on or before original date in ${origYear}`
|
|
1853
1872
|
return undefined;
|
|
1854
1873
|
}
|
|
@@ -1870,7 +1889,7 @@ function getBirthdayOrAnniversary_(hyear, gdate) {
|
|
|
1870
1889
|
return new HDate(day, month, hyear);
|
|
1871
1890
|
}
|
|
1872
1891
|
|
|
1873
|
-
var version="
|
|
1892
|
+
var version="4.0.0";
|
|
1874
1893
|
|
|
1875
1894
|
var headers={"plural-forms":"nplurals=2; plural=(n > 1);"};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};
|
|
1876
1895
|
|
package/dist/hdate-bundle.min.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
/*! @hebcal/core
|
|
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,(a=n.key,o=void 0,"symbol"==typeof(o=function(e,t){if("object"!=typeof e||null===e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var n=r.call(e,t||"default");if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(a,"string"))?o:String(o)),n)}var a,o}function i(e,t,r){return t&&u(e.prototype,t),r&&u(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}var s=[0,31,28,31,30,31,30,31,31,30,31,30,31],c=[s,s.slice()];function h(e,t){return e-t*Math.floor(e/t)}function l(e,t){return Math.floor(e/t)}function f(e){return!(e%4||!(e%100)&&e%400)}function y(e){return"object"===a(e)&&Date.prototype===e.__proto__}function v(e){if(!y(e))throw new TypeError("Argument not a Date: ".concat(e));return d(e.getFullYear(),e.getMonth()+1,e.getDate())}function d(e,t,r){var n=e-1;return 365*n+l(n,4)-l(n,100)+l(n,400)+l(367*t-362,12)+(t<=2?0:f(e)?-1:-2)+r}function m(e){if("number"!=typeof e)throw new TypeError("Argument not a Number: ".concat(e));var t=function(e){var t=e-1,r=l(t,146097),n=h(t,146097),a=l(n,36524),o=h(n,36524),u=l(o,1461),i=l(h(o,1461),365),s=400*r+100*a+4*u+i;return 4!=a&&4!=i?s+1:s}(e=Math.trunc(e)),r=l(12*(e-d(t,1,1)+(e<d(t,3,1)?0:f(t)?1:2))+373,367),n=e-d(t,r,1)+1,a=new Date(t,r-1,n);return t<100&&t>=0&&a.setFullYear(t),a}c[1][2]=29;var g={monthNames:["","January","February","March","April","May","June","July","August","September","October","November","December"],isLeapYear:f,daysInMonth:function(e,t){return c[+f(t)][e]},isDate:y,dayOfYear:function(e){if(!y(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),f(e.getFullYear())&&r++),r},greg2abs:v,abs2greg:m},b={headers:{"plural-forms":"nplurals=2; plural=(n!=1);"},contexts:{"":{}}},w={h:"he",a:"ashkenazi",s:"en","":"en"},p=Object.create(null),k=null,A=null,I=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&&p[r]||k)[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"));p[e.toLowerCase()]=t.contexts[""]}},{key:"useLocale",value:function(e){var t=e.toLowerCase(),r=p[t];if(!r)throw new RangeError("Locale '".concat(e,"' not found"));return A=w[t]||t,k=r}},{key:"getLocaleName",value:function(){return A}},{key:"getLocaleNames",value:function(){return Object.keys(p).sort()}},{key:"ordinal",value:function(e,t){var r=t&&t.toLowerCase()||A;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}();I.addLocale("en",b),I.addLocale("s",b),I.addLocale("",b),I.useLocale("en");var N={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},E=["","Nisan","Iyyar","Sivan","Tamuz","Av","Elul","Tishrei","Cheshvan","Kislev","Tevet","Sh'vat"],T=[E.concat(["Adar","Nisan"]),E.concat(["Adar I","Adar II","Nisan"])],D=Object.create(null),M=-1373428;function S(e,t,r){if(e<1)throw new RangeError("hebrew2abs: invalid year ".concat(e));var n=r;if(t<7){for(var a=7;a<=R(e);a++)n+=V(a,e);for(var o=1;o<t;o++)n+=V(o,e)}else for(var u=7;u<t;u++)n+=V(u,e);return M+F(e)+n-1}function L(e){return M+F(e)}function Y(e){if("number"!=typeof e||isNaN(e))throw new TypeError("invalid parameter to abs2hebrew ".concat(e));if((e=Math.trunc(e))<=M)throw new RangeError("abs2hebrew: ".concat(e," is before epoch"));for(var t=Math.floor((e-M)/365.24682220597794);L(t)<=e;)++t;for(var r=e<S(--t,1,1)?7:1;e>S(t,r,V(r,t));)++r;return{yy:t,mm:r,dd:1+e-S(t,r,1)}}function H(e){return(1+7*e)%19<7}function R(e){return 12+H(e)}function V(e,t){switch(e){case 2:case 4:case 6:case 10:case 13:return 29}return 12===e&&!H(t)||8===e&&!C(t)||9===e&&x(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 T[+H(t)][e]}function F(e){var t=D[e]=D[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&&!H(e)||1==u%7&&o>=16789&&H(t));return i+(i%7==0||i%7==3||i%7==5)}(e);return t}function _(e){return F(e+1)-F(e)}function C(e){return _(e)%10==5}function x(e){return _(e)%10==3}function j(e){throw new TypeError(e)}var z="day",U="week",K="month",B="year",P={d:z,w:U,M:K,y:B},J={day:z,week:U,month:K,year:B},Z=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)?y(t)?v(t):e.isHDate(t)?{dd:t.day,mm:t.month,yy:t.year}:j("HDate called with bad argument: ".concat(t)):t,u="number"==typeof a,i=u?Y(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 H(this.year)}},{key:"getMonth",value:function(){return this.month}},{key:"getTishreiMonth",value:function(){var e=R(this.getFullYear());return(this.getMonth()+e-6)%e||e}},{key:"daysInMonth",value:function(){return V(this.getMonth(),this.getFullYear())}},{key:"getDate",value:function(){return this.day}},{key:"getDay",value:function(){return h(this.abs(),7)}},{key:"setFullYear",value:function(e){return this.year=e,$(this),this}},{key:"setMonth",value:function(t){return this.month=e.monthNum(t),$(this),this}},{key:"setDate",value:function(e){return this.day=e,$(this),this}},{key:"greg",value:function(){return m(this.abs())}},{key:"abs",value:function(){return"number"!=typeof this.abs0&&(this.abs0=S(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||I.getLocaleName(),a=this.getDate(),o=I.gettext(this.getMonthName(),n),u=I.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=I.gettext(this.getMonthName(),"he"),r=this.getFullYear();return n(e)+" "+t+" "+n(r)}},{key:"before",value:function(e){return G(e,this,-1)}},{key:"onOrBefore",value:function(e){return G(e,this,0)}},{key:"nearest",value:function(e){return G(e,this,3)}},{key:"onOrAfter",value:function(e){return G(e,this,6)}},{key:"after",value:function(e){return G(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===U)return new e(this.abs()+7*t);if(r===B)return new e(this.getDate(),this.getMonth(),this.getFullYear()+t);if(r===K){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 S(e,t,r)}},{key:"abs2hebrew",value:function(e){return Y(e)}},{key:"getDayOfTranslation",value:function(e){switch(e){case"en":case"s":case"a":case"ashkenazi":return" of"}var t=I.lookupTranslation("of",e);return t?" "+t:"ashkenazi"===e.substring(0,9)?" of":""}},{key:"standardizeUnits",value:function(e){var t=P[e]||String(e||"").toLowerCase().replace(/s$/,"");return J[t]||j("Invalid units '".concat(e,"'"))}},{key:"isLeapYear",value:function(e){return H(e)}},{key:"monthsInYear",value:function(e){return R(e)}},{key:"daysInMonth",value:function(e,t){return V(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 _(e)}},{key:"longCheshvan",value:function(e){return C(e)}},{key:"shortKislev",value:function(e){return x(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 N.NISAN;case"i":return N.IYYAR;case"e":return N.ELUL;case"c":case"ח":return N.CHESHVAN;case"k":case"כ":return N.KISLEV;case"s":switch(t[1]){case"i":return N.SIVAN;case"h":return N.SHVAT}case"t":switch(t[1]){case"a":return N.TAMUZ;case"i":return N.TISHREI;case"e":return N.TEVET}break;case"a":switch(t[1]){case"v":return N.AV;case"d":return/(1|[^i]i|a|א)$/i.test(e)?N.ADAR_I:N.ADAR_II}break;case"ס":return N.SIVAN;case"ט":return N.TEVET;case"ש":return N.SHVAT;case"א":switch(t[1]){case"ב":return N.AV;case"ד":return/(1|[^i]i|a|א)$/i.test(e)?N.ADAR_I:N.ADAR_II;case"י":return N.IYYAR;case"ל":return N.ELUL}break;case"ת":switch(t[1]){case"מ":return N.TAMUZ;case"ש":return N.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 $(e){q(e),function(e){e.day<1&&(e.month==N.TISHREI&&(e.year-=1),e.day+=V(e.month,e.year),e.month-=1,$(e));e.day>V(e.month,e.year)&&(e.month===N.ELUL&&(e.year+=1),e.day-=V(e.month,e.year),e.month+=1,$(e));q(e)}(e)}function q(e){e.month!==N.ADAR_II||e.isLeapYear()?e.month<1?(e.month+=R(e.year),e.year-=1,$(e)):e.month>R(e.year)&&(e.month-=R(e.year),e.year+=1,$(e)):(e.month-=1,$(e)),delete e.abs0}function G(e,t,r){return new Z(Z.dayOnOrBefore(e,t.abs()+r))}var Q=N.NISAN,W=N.CHESHVAN,X=N.KISLEV,ee=N.TEVET,te=N.SHVAT,re=N.ADAR_I,ne=N.ADAR_II;var ae={headers:{"plural-forms":"nplurals=2; plural=(n > 1);"},contexts:{"":{Adar:["אַדָר"],"Adar I":["אַדָר א׳"],"Adar II":["אַדָר ב׳"],Av:["אָב"],Cheshvan:["חֶשְׁוָן"],Elul:["אֱלוּל"],Iyyar:["אִיָיר"],Kislev:["כִּסְלֵו"],Nisan:["נִיסָן"],"Sh'vat":["שְׁבָט"],Sivan:["סִיוָן"],Tamuz:["תַּמּוּז"],Tevet:["טֵבֵת"],Tishrei:["תִשְׁרֵי"]}}};I.addLocale("he",ae),I.addLocale("h",ae);var oe=ae.contexts[""],ue={};return Object.keys(oe).forEach((function(e){ue[e]=[I.hebrewStripNikkud(oe[e][0])]})),I.addLocale("he-x-NoNikud",{headers:ae.headers,contexts:{"":ue}}),e.HDate=Z,e.Locale=I,e.gematriya=n,e.getBirthdayOrAnniversary=function(e,t){var r=Z.isHDate(t)?t:new Z(t),n=r.getFullYear();if(!(e<=n)){var a=H(n),o=r.getMonth(),u=r.getDate();return o==re&&!a||o==ne&&a?o=R(e):o!=W||30!=u||C(e)?o==X&&30==u&&x(e)?(o=ee,u=1):o==re&&30==u&&a&&!H(e)&&(o=Q,u=1):(o=X,u=1),new Z(u,o,e)}},e.getYahrzeit=function(e,t){var r=Z.isHDate(t)?t:new Z(t),n={yy:r.getFullYear(),mm:r.getMonth(),dd:r.getDate()};if(!(e<=n.yy))return n.mm!=W||30!=n.dd||C(n.yy+1)?n.mm==X&&30==n.dd&&x(n.yy+1)?n=Y(S(e,ee,1)-1):n.mm==ne?n.mm=R(e):n.mm!=re||30!=n.dd||H(e)||(n.dd=30,n.mm=te):n=Y(S(e,X,1)-1),n.mm!=W||30!=n.dd||C(e)?n.mm==X&&30==n.dd&&x(e)&&(n.mm=ee,n.dd=1):(n.mm=X,n.dd=1),new Z(n.dd,n.mm,e)},e.greg=g,e.months=N,e.version="3.50.3",e}({});
|
|
1
|
+
/*! @hebcal/core v4.0.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,(a=n.key,o=void 0,"symbol"==typeof(o=function(e,t){if("object"!=typeof e||null===e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var n=r.call(e,t||"default");if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(a,"string"))?o:String(o)),n)}var a,o}function i(e,t,r){return t&&u(e.prototype,t),r&&u(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}var s=[0,31,28,31,30,31,30,31,31,30,31,30,31],c=[s,s.slice()];function h(e,t){return e-t*Math.floor(e/t)}function l(e,t){return Math.floor(e/t)}function f(e){return!(e%4||!(e%100)&&e%400)}function y(e){return"object"===a(e)&&Date.prototype===e.__proto__}function v(e){if(!y(e))throw new TypeError("Argument not a Date: ".concat(e));return d(e.getFullYear(),e.getMonth()+1,e.getDate())}function d(e,t,r){var n=e-1;return 365*n+l(n,4)-l(n,100)+l(n,400)+l(367*t-362,12)+(t<=2?0:f(e)?-1:-2)+r}function m(e){if("number"!=typeof e)throw new TypeError("Argument not a Number: ".concat(e));var t=function(e){var t=e-1,r=l(t,146097),n=h(t,146097),a=l(n,36524),o=h(n,36524),u=l(o,1461),i=l(h(o,1461),365),s=400*r+100*a+4*u+i;return 4!=a&&4!=i?s+1:s}(e=Math.trunc(e)),r=l(12*(e-d(t,1,1)+(e<d(t,3,1)?0:f(t)?1:2))+373,367),n=e-d(t,r,1)+1,a=new Date(t,r-1,n);return t<100&&t>=0&&a.setFullYear(t),a}c[1][2]=29;var g={monthNames:["","January","February","March","April","May","June","July","August","September","October","November","December"],isLeapYear:f,daysInMonth:function(e,t){return c[+f(t)][e]},isDate:y,dayOfYear:function(e){if(!y(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),f(e.getFullYear())&&r++),r},greg2abs:v,abs2greg:m},b={headers:{"plural-forms":"nplurals=2; plural=(n!=1);"},contexts:{"":{}}},w={h:"he",a:"ashkenazi",s:"en","":"en"},p=Object.create(null),k=null,A=null,I=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&&p[r]||k)[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"));p[e.toLowerCase()]=t.contexts[""]}},{key:"useLocale",value:function(e){var t=e.toLowerCase(),r=p[t];if(!r)throw new RangeError("Locale '".concat(e,"' not found"));return A=w[t]||t,k=r}},{key:"getLocaleName",value:function(){return A}},{key:"getLocaleNames",value:function(){return Object.keys(p).sort()}},{key:"ordinal",value:function(e,t){var r=t&&t.toLowerCase()||A;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}();I.addLocale("en",b),I.addLocale("s",b),I.addLocale("",b),I.useLocale("en");var N=1,E=2,T=4,D=6,M=7,S=8,L=9,Y=10,H=12,R=13,V={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},O=["","Nisan","Iyyar","Sivan","Tamuz","Av","Elul","Tishrei","Cheshvan","Kislev","Tevet","Sh'vat"],F=[O.concat(["Adar","Nisan"]),O.concat(["Adar I","Adar II","Nisan"])],_=Object.create(null),C=-1373428,x=365.24682220597794;function j(e,t){if("number"!=typeof e||isNaN(e))throw new TypeError("invalid parameter '".concat(t,"' not a number: ").concat(e))}function z(e,t,r){if(j(e,"year"),j(t,"month"),j(r,"day"),e<1)throw new RangeError("hebrew2abs: invalid year ".concat(e));var n=r;if(t<M){for(var a=M;a<=P(e);a++)n+=J(a,e);for(var o=N;o<t;o++)n+=J(o,e)}else for(var u=M;u<t;u++)n+=J(u,e);return C+$(e)+n-1}function U(e){return C+$(e)}function K(e){if(j(e,"abs"),(e=Math.trunc(e))<=C)throw new RangeError("abs2hebrew: ".concat(e," is before epoch"));for(var t=Math.floor((e-C)/x);U(t)<=e;)++t;for(var r=e<z(--t,1,1)?7:1;e>z(t,r,J(r,t));)++r;return{yy:t,mm:r,dd:1+e-z(t,r,1)}}function B(e){return(1+7*e)%19<7}function P(e){return 12+B(e)}function J(e,t){switch(e){case E:case T:case D:case Y:case R:return 29}return e===H&&!B(t)||e===S&&!G(t)||e===L&&Q(t)?29:30}function Z(e,t){if(j(e,"month"),j(t,"year"),e<1||e>14)throw new TypeError("bad month argument ".concat(e));return F[+B(t)][e]}function $(e){var t=_[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&&!B(e)||1==u%7&&o>=16789&&B(t));return i+(i%7==0||i%7==3||i%7==5)}(e);return t}function q(e){return $(e+1)-$(e)}function G(e){return q(e)%10==5}function Q(e){return q(e)%10==3}function W(e){throw new TypeError(e)}var X="day",ee="week",te="month",re="year",ne={d:X,w:ee,M:te,y:re},ae={day:X,week:ee,month:te,year:re},oe=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)?y(t)?v(t):e.isHDate(t)?{dd:t.day,mm:t.month,yy:t.year}:W("HDate called with bad argument: ".concat(t)):t,u="number"==typeof a,i=u?K(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 B(this.year)}},{key:"getMonth",value:function(){return this.month}},{key:"getTishreiMonth",value:function(){var e=P(this.getFullYear());return(this.getMonth()+e-6)%e||e}},{key:"daysInMonth",value:function(){return J(this.getMonth(),this.getFullYear())}},{key:"getDate",value:function(){return this.day}},{key:"getDay",value:function(){return h(this.abs(),7)}},{key:"setFullYear",value:function(e){return this.year=e,ue(this),this}},{key:"setMonth",value:function(t){return this.month=e.monthNum(t),ue(this),this}},{key:"setDate",value:function(e){return this.day=e,ue(this),this}},{key:"greg",value:function(){return m(this.abs())}},{key:"abs",value:function(){return"number"!=typeof this.abs0&&(this.abs0=z(this.year,this.month,this.day)),this.abs0}},{key:"getMonthName",value:function(){return Z(this.getMonth(),this.getFullYear())}},{key:"render",value:function(){var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],r=(arguments.length>0&&void 0!==arguments[0]?arguments[0]:null)||I.getLocaleName(),n=this.getDate(),a=I.gettext(this.getMonthName(),r),o=I.ordinal(n,r),u=e.getDayOfTranslation(r),i="".concat(o).concat(u," ").concat(a);if(t){var s=this.getFullYear();return"".concat(i,", ").concat(s)}return i}},{key:"renderGematriya",value:function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0],t=this.getDate(),r=e?"he-x-NoNikud":"he",a=I.gettext(this.getMonthName(),r),o=this.getFullYear();return n(t)+" "+a+" "+n(o)}},{key:"before",value:function(e){return se(e,this,-1)}},{key:"onOrBefore",value:function(e){return se(e,this,0)}},{key:"nearest",value:function(e){return se(e,this,3)}},{key:"onOrAfter",value:function(e){return se(e,this,6)}},{key:"after",value:function(e){return se(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===ee)return new e(this.abs()+7*t);if(r===re)return new e(this.getDate(),this.getMonth(),this.getFullYear()+t);if(r===te){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 z(e,t,r)}},{key:"abs2hebrew",value:function(e){return K(e)}},{key:"getDayOfTranslation",value:function(e){switch(e){case"en":case"s":case"a":case"ashkenazi":return" of"}var t=I.lookupTranslation("of",e);return t?" "+t:"ashkenazi"===e.substring(0,9)?" of":""}},{key:"standardizeUnits",value:function(e){var t=ne[e]||String(e||"").toLowerCase().replace(/s$/,"");return ae[t]||W("Invalid units '".concat(e,"'"))}},{key:"isLeapYear",value:function(e){return B(e)}},{key:"monthsInYear",value:function(e){return P(e)}},{key:"daysInMonth",value:function(e,t){return J(e,t)}},{key:"getMonthName",value:function(e,t){return Z(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 q(e)}},{key:"longCheshvan",value:function(e){return G(e)}},{key:"shortKislev",value:function(e){return Q(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 V.NISAN;case"i":return V.IYYAR;case"e":return V.ELUL;case"c":case"ח":return V.CHESHVAN;case"k":case"כ":return V.KISLEV;case"s":switch(t[1]){case"i":return V.SIVAN;case"h":return V.SHVAT}case"t":switch(t[1]){case"a":return V.TAMUZ;case"i":return V.TISHREI;case"e":return V.TEVET}break;case"a":switch(t[1]){case"v":return V.AV;case"d":return/(1|[^i]i|a|א)$/i.test(e)?V.ADAR_I:V.ADAR_II}break;case"ס":return V.SIVAN;case"ט":return V.TEVET;case"ש":return V.SHVAT;case"א":switch(t[1]){case"ב":return V.AV;case"ד":return/(1|[^i]i|a|א)$/i.test(e)?V.ADAR_I:V.ADAR_II;case"י":return V.IYYAR;case"ל":return V.ELUL}break;case"ת":switch(t[1]){case"מ":return V.TAMUZ;case"ש":return V.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 ue(e){ie(e),function(e){e.day<1&&(e.month==V.TISHREI&&(e.year-=1),e.day+=J(e.month,e.year),e.month-=1,ue(e));e.day>J(e.month,e.year)&&(e.month===V.ELUL&&(e.year+=1),e.day-=J(e.month,e.year),e.month+=1,ue(e));ie(e)}(e)}function ie(e){e.month!==V.ADAR_II||e.isLeapYear()?e.month<1?(e.month+=P(e.year),e.year-=1,ue(e)):e.month>P(e.year)&&(e.month-=P(e.year),e.year+=1,ue(e)):(e.month-=1,ue(e)),delete e.abs0}function se(e,t,r){return new oe(oe.dayOnOrBefore(e,t.abs()+r))}var ce=V.NISAN,he=V.CHESHVAN,le=V.KISLEV,fe=V.TEVET,ye=V.SHVAT,ve=V.ADAR_I,de=V.ADAR_II;var me={headers:{"plural-forms":"nplurals=2; plural=(n > 1);"},contexts:{"":{Adar:["אַדָר"],"Adar I":["אַדָר א׳"],"Adar II":["אַדָר ב׳"],Av:["אָב"],Cheshvan:["חֶשְׁוָן"],Elul:["אֱלוּל"],Iyyar:["אִיָיר"],Kislev:["כִּסְלֵו"],Nisan:["נִיסָן"],"Sh'vat":["שְׁבָט"],Sivan:["סִיוָן"],Tamuz:["תַּמּוּז"],Tevet:["טֵבֵת"],Tishrei:["תִשְׁרֵי"]}}};I.addLocale("he",me),I.addLocale("h",me);var ge=me.contexts[""],be={};return Object.keys(ge).forEach((function(e){be[e]=[I.hebrewStripNikkud(ge[e][0])]})),I.addLocale("he-x-NoNikud",{headers:me.headers,contexts:{"":be}}),e.HDate=oe,e.Locale=I,e.gematriya=n,e.getBirthdayOrAnniversary=function(e,t){var r=oe.isHDate(t)?t:new oe(t),n=r.getFullYear();if(e===n)return r;if(!(e<n)){var a=B(n),o=r.getMonth(),u=r.getDate();return o==ve&&!a||o==de&&a?o=P(e):o!=he||30!=u||G(e)?o==le&&30==u&&Q(e)?(o=fe,u=1):o==ve&&30==u&&a&&!B(e)&&(o=ce,u=1):(o=le,u=1),new oe(u,o,e)}},e.getYahrzeit=function(e,t){var r=oe.isHDate(t)?t:new oe(t),n={yy:r.getFullYear(),mm:r.getMonth(),dd:r.getDate()};if(!(e<=n.yy))return n.mm!=he||30!=n.dd||G(n.yy+1)?n.mm==le&&30==n.dd&&Q(n.yy+1)?n=K(z(e,fe,1)-1):n.mm==de?n.mm=P(e):n.mm!=ve||30!=n.dd||B(e)||(n.dd=30,n.mm=ye):n=K(z(e,le,1)-1),n.mm!=he||30!=n.dd||G(e)?n.mm==le&&30==n.dd&&Q(e)&&(n.mm=fe,n.dd=1):(n.mm=le,n.dd=1),new oe(n.dd,n.mm,e)},e.greg=g,e.months=V,e.version="4.0.0",e}({});
|
package/dist/hdate.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! @hebcal/core
|
|
1
|
+
/*! @hebcal/core v4.0.0 */
|
|
2
2
|
'use strict';
|
|
3
3
|
|
|
4
4
|
const GERESH = '׳';
|
|
@@ -434,7 +434,7 @@ class Locale {
|
|
|
434
434
|
/**
|
|
435
435
|
* Register locale translations.
|
|
436
436
|
* @param {string} locale Locale name (i.e.: `'he'`, `'fr'`)
|
|
437
|
-
* @param {
|
|
437
|
+
* @param {LocaleData} data parsed data from a `.po` file.
|
|
438
438
|
*/
|
|
439
439
|
static addLocale(locale, data) {
|
|
440
440
|
if (typeof data.contexts !== 'object' || typeof data.contexts[''] !== 'object') {
|
|
@@ -597,6 +597,17 @@ const EPOCH = -1373428;
|
|
|
597
597
|
// Avg year length in the cycle (19 solar years with 235 lunar months)
|
|
598
598
|
const AVG_HEBYEAR_DAYS = 365.24682220597794;
|
|
599
599
|
|
|
600
|
+
/**
|
|
601
|
+
* @private
|
|
602
|
+
* @param {any} n
|
|
603
|
+
* @param {string} name
|
|
604
|
+
*/
|
|
605
|
+
function assertNumber(n, name) {
|
|
606
|
+
if (typeof n !== 'number' || isNaN(n)) {
|
|
607
|
+
throw new TypeError(`invalid parameter '${name}' not a number: ${n}`);
|
|
608
|
+
}
|
|
609
|
+
}
|
|
610
|
+
|
|
600
611
|
/**
|
|
601
612
|
* Converts Hebrew date to R.D. (Rata Die) fixed days.
|
|
602
613
|
* R.D. 1 is the imaginary date Monday, January 1, 1 on the Gregorian
|
|
@@ -608,6 +619,9 @@ const AVG_HEBYEAR_DAYS = 365.24682220597794;
|
|
|
608
619
|
* @return {number}
|
|
609
620
|
*/
|
|
610
621
|
function hebrew2abs(year, month, day) {
|
|
622
|
+
assertNumber(year, 'year');
|
|
623
|
+
assertNumber(month, 'month');
|
|
624
|
+
assertNumber(day, 'day');
|
|
611
625
|
if (year < 1) {
|
|
612
626
|
throw new RangeError(`hebrew2abs: invalid year ${year}`);
|
|
613
627
|
}
|
|
@@ -643,9 +657,7 @@ function newYear(year) {
|
|
|
643
657
|
* @return {SimpleHebrewDate}
|
|
644
658
|
*/
|
|
645
659
|
function abs2hebrew(abs) {
|
|
646
|
-
|
|
647
|
-
throw new TypeError(`invalid parameter to abs2hebrew ${abs}`);
|
|
648
|
-
}
|
|
660
|
+
assertNumber(abs, 'abs');
|
|
649
661
|
abs = Math.trunc(abs);
|
|
650
662
|
if (abs <= EPOCH) {
|
|
651
663
|
throw new RangeError(`abs2hebrew: ${abs} is before epoch`);
|
|
@@ -720,7 +732,9 @@ function daysInMonth(month, year) {
|
|
|
720
732
|
* @return {string}
|
|
721
733
|
*/
|
|
722
734
|
function getMonthName(month, year) {
|
|
723
|
-
|
|
735
|
+
assertNumber(month, 'month');
|
|
736
|
+
assertNumber(year, 'year');
|
|
737
|
+
if (month < 1 || month > 14) {
|
|
724
738
|
throw new TypeError(`bad month argument ${month}`);
|
|
725
739
|
}
|
|
726
740
|
return monthNames[+isLeapYear(year)][month];
|
|
@@ -1146,11 +1160,13 @@ class HDate {
|
|
|
1146
1160
|
* import {HDate, months} from '@hebcal/core';
|
|
1147
1161
|
* const hd = new HDate(15, months.CHESHVAN, 5769);
|
|
1148
1162
|
* console.log(hd.renderGematriya()); // 'ט״ו חֶשְׁוָן תשס״ט'
|
|
1163
|
+
* @param {boolean} [suppressNikud]
|
|
1149
1164
|
* @return {string}
|
|
1150
1165
|
*/
|
|
1151
|
-
renderGematriya() {
|
|
1166
|
+
renderGematriya(suppressNikud = false) {
|
|
1152
1167
|
const d = this.getDate();
|
|
1153
|
-
const
|
|
1168
|
+
const locale = suppressNikud ? 'he-x-NoNikud' : 'he';
|
|
1169
|
+
const m = Locale.gettext(this.getMonthName(), locale);
|
|
1154
1170
|
const y = this.getFullYear();
|
|
1155
1171
|
return gematriya(d) + ' ' + m + ' ' + gematriya(y);
|
|
1156
1172
|
}
|
|
@@ -1706,7 +1722,9 @@ function getYahrzeit_(hyear, gdate) {
|
|
|
1706
1722
|
function getBirthdayOrAnniversary_(hyear, gdate) {
|
|
1707
1723
|
const orig = HDate.isHDate(gdate) ? gdate : new HDate(gdate);
|
|
1708
1724
|
const origYear = orig.getFullYear();
|
|
1709
|
-
if (hyear
|
|
1725
|
+
if (hyear === origYear) {
|
|
1726
|
+
return orig;
|
|
1727
|
+
} else if (hyear < origYear) {
|
|
1710
1728
|
// `Hebrew year ${hyear} occurs on or before original date in ${origYear}`
|
|
1711
1729
|
return undefined;
|
|
1712
1730
|
}
|
|
@@ -1728,7 +1746,7 @@ function getBirthdayOrAnniversary_(hyear, gdate) {
|
|
|
1728
1746
|
return new HDate(day, month, hyear);
|
|
1729
1747
|
}
|
|
1730
1748
|
|
|
1731
|
-
const version="
|
|
1749
|
+
const version="4.0.0";
|
|
1732
1750
|
|
|
1733
1751
|
const headers={"plural-forms":"nplurals=2; plural=(n > 1);"};const contexts={"":{Adar:["אַדָר"],"Adar I":["אַדָר א׳"],"Adar II":["אַדָר ב׳"],Av:["אָב"],Cheshvan:["חֶשְׁוָן"],Elul:["אֱלוּל"],Iyyar:["אִיָיר"],Kislev:["כִּסְלֵו"],Nisan:["נִיסָן"],"Sh'vat":["שְׁבָט"],Sivan:["סִיוָן"],Tamuz:["תַּמּוּז"],Tevet:["טֵבֵת"],Tishrei:["תִשְׁרֵי"]}};var poHeMin = {headers:headers,contexts:contexts};
|
|
1734
1752
|
|
package/dist/hdate.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! @hebcal/core
|
|
1
|
+
/*! @hebcal/core v4.0.0 */
|
|
2
2
|
const GERESH = '׳';
|
|
3
3
|
const GERSHAYIM = '״';
|
|
4
4
|
|
|
@@ -434,7 +434,7 @@ class Locale {
|
|
|
434
434
|
/**
|
|
435
435
|
* Register locale translations.
|
|
436
436
|
* @param {string} locale Locale name (i.e.: `'he'`, `'fr'`)
|
|
437
|
-
* @param {
|
|
437
|
+
* @param {LocaleData} data parsed data from a `.po` file.
|
|
438
438
|
*/
|
|
439
439
|
static addLocale(locale, data) {
|
|
440
440
|
if (typeof data.contexts !== 'object' || typeof data.contexts[''] !== 'object') {
|
|
@@ -624,6 +624,17 @@ const EPOCH = -1373428;
|
|
|
624
624
|
// Avg year length in the cycle (19 solar years with 235 lunar months)
|
|
625
625
|
const AVG_HEBYEAR_DAYS = 365.24682220597794;
|
|
626
626
|
|
|
627
|
+
/**
|
|
628
|
+
* @private
|
|
629
|
+
* @param {any} n
|
|
630
|
+
* @param {string} name
|
|
631
|
+
*/
|
|
632
|
+
function assertNumber(n, name) {
|
|
633
|
+
if (typeof n !== 'number' || isNaN(n)) {
|
|
634
|
+
throw new TypeError(`invalid parameter '${name}' not a number: ${n}`);
|
|
635
|
+
}
|
|
636
|
+
}
|
|
637
|
+
|
|
627
638
|
/**
|
|
628
639
|
* Converts Hebrew date to R.D. (Rata Die) fixed days.
|
|
629
640
|
* R.D. 1 is the imaginary date Monday, January 1, 1 on the Gregorian
|
|
@@ -635,6 +646,10 @@ const AVG_HEBYEAR_DAYS = 365.24682220597794;
|
|
|
635
646
|
* @return {number}
|
|
636
647
|
*/
|
|
637
648
|
function hebrew2abs(year, month, day) {
|
|
649
|
+
assertNumber(year, 'year');
|
|
650
|
+
assertNumber(month, 'month');
|
|
651
|
+
assertNumber(day, 'day');
|
|
652
|
+
|
|
638
653
|
if (year < 1) {
|
|
639
654
|
throw new RangeError(`hebrew2abs: invalid year ${year}`);
|
|
640
655
|
}
|
|
@@ -673,9 +688,7 @@ function newYear(year) {
|
|
|
673
688
|
* @return {SimpleHebrewDate}
|
|
674
689
|
*/
|
|
675
690
|
function abs2hebrew(abs) {
|
|
676
|
-
|
|
677
|
-
throw new TypeError(`invalid parameter to abs2hebrew ${abs}`);
|
|
678
|
-
}
|
|
691
|
+
assertNumber(abs, 'abs');
|
|
679
692
|
abs = Math.trunc(abs);
|
|
680
693
|
if (abs <= EPOCH) {
|
|
681
694
|
throw new RangeError(`abs2hebrew: ${abs} is before epoch`);
|
|
@@ -750,7 +763,9 @@ function daysInMonth(month, year) {
|
|
|
750
763
|
* @return {string}
|
|
751
764
|
*/
|
|
752
765
|
function getMonthName(month, year) {
|
|
753
|
-
|
|
766
|
+
assertNumber(month, 'month');
|
|
767
|
+
assertNumber(year, 'year');
|
|
768
|
+
if (month < 1 || month > 14) {
|
|
754
769
|
throw new TypeError(`bad month argument ${month}`);
|
|
755
770
|
}
|
|
756
771
|
return monthNames[+isLeapYear(year)][month];
|
|
@@ -1174,11 +1189,13 @@ class HDate {
|
|
|
1174
1189
|
* import {HDate, months} from '@hebcal/core';
|
|
1175
1190
|
* const hd = new HDate(15, months.CHESHVAN, 5769);
|
|
1176
1191
|
* console.log(hd.renderGematriya()); // 'ט״ו חֶשְׁוָן תשס״ט'
|
|
1192
|
+
* @param {boolean} [suppressNikud]
|
|
1177
1193
|
* @return {string}
|
|
1178
1194
|
*/
|
|
1179
|
-
renderGematriya() {
|
|
1195
|
+
renderGematriya(suppressNikud=false) {
|
|
1180
1196
|
const d = this.getDate();
|
|
1181
|
-
const
|
|
1197
|
+
const locale = suppressNikud ? 'he-x-NoNikud' : 'he';
|
|
1198
|
+
const m = Locale.gettext(this.getMonthName(), locale);
|
|
1182
1199
|
const y = this.getFullYear();
|
|
1183
1200
|
return gematriya(d) + ' ' + m + ' ' + gematriya(y);
|
|
1184
1201
|
}
|
|
@@ -1741,7 +1758,9 @@ function getYahrzeit_(hyear, gdate) {
|
|
|
1741
1758
|
function getBirthdayOrAnniversary_(hyear, gdate) {
|
|
1742
1759
|
const orig = HDate.isHDate(gdate) ? gdate : new HDate(gdate);
|
|
1743
1760
|
const origYear = orig.getFullYear();
|
|
1744
|
-
if (hyear
|
|
1761
|
+
if (hyear === origYear) {
|
|
1762
|
+
return orig;
|
|
1763
|
+
} else if (hyear < origYear) {
|
|
1745
1764
|
// `Hebrew year ${hyear} occurs on or before original date in ${origYear}`
|
|
1746
1765
|
return undefined;
|
|
1747
1766
|
}
|
|
@@ -1765,7 +1784,7 @@ function getBirthdayOrAnniversary_(hyear, gdate) {
|
|
|
1765
1784
|
return new HDate(day, month, hyear);
|
|
1766
1785
|
}
|
|
1767
1786
|
|
|
1768
|
-
const version="
|
|
1787
|
+
const version="4.0.0";
|
|
1769
1788
|
|
|
1770
1789
|
const headers={"plural-forms":"nplurals=2; plural=(n > 1);"};const contexts={"":{Adar:["אַדָר"],"Adar I":["אַדָר א׳"],"Adar II":["אַדָר ב׳"],Av:["אָב"],Cheshvan:["חֶשְׁוָן"],Elul:["אֱלוּל"],Iyyar:["אִיָיר"],Kislev:["כִּסְלֵו"],Nisan:["נִיסָן"],"Sh'vat":["שְׁבָט"],Sivan:["סִיוָן"],Tamuz:["תַּמּוּז"],Tevet:["טֵבֵת"],Tishrei:["תִשְׁרֵי"]}};var poHeMin = {headers:headers,contexts:contexts};
|
|
1771
1790
|
|
package/dist/hdate0-bundle.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! @hebcal/core
|
|
1
|
+
/*! @hebcal/core v4.0.0 */
|
|
2
2
|
var hebcal = (function (exports) {
|
|
3
3
|
'use strict';
|
|
4
4
|
|
|
@@ -212,6 +212,17 @@ var EPOCH = -1373428;
|
|
|
212
212
|
// Avg year length in the cycle (19 solar years with 235 lunar months)
|
|
213
213
|
var AVG_HEBYEAR_DAYS = 365.24682220597794;
|
|
214
214
|
|
|
215
|
+
/**
|
|
216
|
+
* @private
|
|
217
|
+
* @param {any} n
|
|
218
|
+
* @param {string} name
|
|
219
|
+
*/
|
|
220
|
+
function assertNumber(n, name) {
|
|
221
|
+
if (typeof n !== 'number' || isNaN(n)) {
|
|
222
|
+
throw new TypeError("invalid parameter '".concat(name, "' not a number: ").concat(n));
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
|
|
215
226
|
/**
|
|
216
227
|
* Converts Hebrew date to R.D. (Rata Die) fixed days.
|
|
217
228
|
* R.D. 1 is the imaginary date Monday, January 1, 1 on the Gregorian
|
|
@@ -223,6 +234,9 @@ var AVG_HEBYEAR_DAYS = 365.24682220597794;
|
|
|
223
234
|
* @return {number}
|
|
224
235
|
*/
|
|
225
236
|
function hebrew2abs(year, month, day) {
|
|
237
|
+
assertNumber(year, 'year');
|
|
238
|
+
assertNumber(month, 'month');
|
|
239
|
+
assertNumber(day, 'day');
|
|
226
240
|
if (year < 1) {
|
|
227
241
|
throw new RangeError("hebrew2abs: invalid year ".concat(year));
|
|
228
242
|
}
|
|
@@ -258,9 +272,7 @@ function newYear(year) {
|
|
|
258
272
|
* @return {SimpleHebrewDate}
|
|
259
273
|
*/
|
|
260
274
|
function abs2hebrew(abs) {
|
|
261
|
-
|
|
262
|
-
throw new TypeError("invalid parameter to abs2hebrew ".concat(abs));
|
|
263
|
-
}
|
|
275
|
+
assertNumber(abs, 'abs');
|
|
264
276
|
abs = Math.trunc(abs);
|
|
265
277
|
if (abs <= EPOCH) {
|
|
266
278
|
throw new RangeError("abs2hebrew: ".concat(abs, " is before epoch"));
|
|
@@ -335,7 +347,9 @@ function daysInMonth(month, year) {
|
|
|
335
347
|
* @return {string}
|
|
336
348
|
*/
|
|
337
349
|
function getMonthName(month, year) {
|
|
338
|
-
|
|
350
|
+
assertNumber(month, 'month');
|
|
351
|
+
assertNumber(year, 'year');
|
|
352
|
+
if (month < 1 || month > 14) {
|
|
339
353
|
throw new TypeError("bad month argument ".concat(month));
|
|
340
354
|
}
|
|
341
355
|
return monthNames[+isLeapYear(year)][month];
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
/*! @hebcal/core
|
|
2
|
-
var hebcal=function(r){"use strict";function
|
|
1
|
+
/*! @hebcal/core v4.0.0 */
|
|
2
|
+
var hebcal=function(r){"use strict";function n(r){return n="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},n(r)}var t=[0,31,28,31,30,31,30,31,31,30,31,30,31];function e(r,n){return r-n*Math.floor(r/n)}function o(r,n){return Math.floor(r/n)}function a(r){return!(r%4||!(r%100)&&r%400)}function u(r,n,t){var e=r-1;return 365*e+o(e,4)-o(e,100)+o(e,400)+o(367*n-362,12)+(n<=2?0:a(r)?-1:-2)+t}[t,t.slice()][1][2]=29;var c=1,f=2,i=4,h=6,s=7,l=8,y=9,b=10,v=12,m=13,p=["","Nisan","Iyyar","Sivan","Tamuz","Av","Elul","Tishrei","Cheshvan","Kislev","Tevet","Sh'vat"],w=[p.concat(["Adar","Nisan"]),p.concat(["Adar I","Adar II","Nisan"])],A=Object.create(null),I=-1373428;function g(r,n){if("number"!=typeof r||isNaN(r))throw new TypeError("invalid parameter '".concat(n,"' not a number: ").concat(r))}function M(r,n,t){if(g(r,"year"),g(n,"month"),g(t,"day"),r<1)throw new RangeError("hebrew2abs: invalid year ".concat(r));var e=t;if(n<s){for(var o=s;o<=d(r);o++)e+=T(o,r);for(var a=c;a<n;a++)e+=T(a,r)}else for(var u=s;u<n;u++)e+=T(u,r);return I+N(r)+e-1}function E(r){return I+N(r)}function S(r){return(1+7*r)%19<7}function d(r){return 12+S(r)}function T(r,n){switch(r){case f:case i:case h:case b:case m:return 29}return r===v&&!S(n)||r===l&&!D(n)||r===y&&R(n)?29:30}function N(r){var n=A[r]=A[r]||function(r){var n=r-1,t=235*Math.floor(n/19)+n%19*12+Math.floor((n%19*7+1)/19),e=204+t%1080*793,o=5+12*t+793*Math.floor(t/1080)+Math.floor(e/1080),a=e%1080+o%24*1080,u=1+29*t+Math.floor(o/24),c=u+(a>=19440||2==u%7&&a>=9924&&!S(r)||1==u%7&&a>=16789&&S(n));return c+(c%7==0||c%7==3||c%7==5)}(r);return n}function Y(r){return N(r+1)-N(r)}function D(r){return Y(r)%10==5}function R(r){return Y(r)%10==3}var V={abs2hebrew:function(r){if(g(r,"abs"),(r=Math.trunc(r))<=I)throw new RangeError("abs2hebrew: ".concat(r," is before epoch"));for(var n=Math.floor((r-I)/365.24682220597794);E(n)<=r;)++n;for(var t=r<M(--n,1,1)?7:1;r>M(n,t,T(t,n));)++t;return{yy:n,mm:t,dd:1+r-M(n,t,1)}},daysInMonth:T,daysInYear:Y,getMonthName:function(r,n){if(g(r,"month"),g(n,"year"),r<1||r>14)throw new TypeError("bad month argument ".concat(r));return w[+S(n)][r]},hebrew2abs:M,isLeapYear:S,longCheshvan:D,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:d,shortKislev:R};return r.abs2greg=function(r){if("number"!=typeof r)throw new TypeError("Argument not a Number: ".concat(r));var n=function(r){var n=r-1,t=o(n,146097),a=e(n,146097),u=o(a,36524),c=e(a,36524),f=o(c,1461),i=o(e(c,1461),365),h=400*t+100*u+4*f+i;return 4!=u&&4!=i?h+1:h}(r=Math.trunc(r)),t=o(12*(r-u(n,1,1)+(r<u(n,3,1)?0:a(n)?1:2))+373,367),c=r-u(n,t,1)+1,f=new Date(n,t-1,c);return n<100&&n>=0&&f.setFullYear(n),f},r.greg2abs=function(r){if("object"!==n(t=r)||Date.prototype!==t.__proto__)throw new TypeError("Argument not a Date: ".concat(r));var t;return u(r.getFullYear(),r.getMonth()+1,r.getDate())},r.hdate=V,r}({});
|
package/dist/hdate0.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! @hebcal/core
|
|
1
|
+
/*! @hebcal/core v4.0.0 */
|
|
2
2
|
/*
|
|
3
3
|
* More minimal greg routines
|
|
4
4
|
*/
|
|
@@ -234,6 +234,17 @@ const EPOCH = -1373428;
|
|
|
234
234
|
// Avg year length in the cycle (19 solar years with 235 lunar months)
|
|
235
235
|
const AVG_HEBYEAR_DAYS = 365.24682220597794;
|
|
236
236
|
|
|
237
|
+
/**
|
|
238
|
+
* @private
|
|
239
|
+
* @param {any} n
|
|
240
|
+
* @param {string} name
|
|
241
|
+
*/
|
|
242
|
+
function assertNumber(n, name) {
|
|
243
|
+
if (typeof n !== 'number' || isNaN(n)) {
|
|
244
|
+
throw new TypeError(`invalid parameter '${name}' not a number: ${n}`);
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
|
|
237
248
|
/**
|
|
238
249
|
* Converts Hebrew date to R.D. (Rata Die) fixed days.
|
|
239
250
|
* R.D. 1 is the imaginary date Monday, January 1, 1 on the Gregorian
|
|
@@ -245,6 +256,10 @@ const AVG_HEBYEAR_DAYS = 365.24682220597794;
|
|
|
245
256
|
* @return {number}
|
|
246
257
|
*/
|
|
247
258
|
function hebrew2abs(year, month, day) {
|
|
259
|
+
assertNumber(year, 'year');
|
|
260
|
+
assertNumber(month, 'month');
|
|
261
|
+
assertNumber(day, 'day');
|
|
262
|
+
|
|
248
263
|
if (year < 1) {
|
|
249
264
|
throw new RangeError(`hebrew2abs: invalid year ${year}`);
|
|
250
265
|
}
|
|
@@ -283,9 +298,7 @@ function newYear(year) {
|
|
|
283
298
|
* @return {SimpleHebrewDate}
|
|
284
299
|
*/
|
|
285
300
|
function abs2hebrew(abs) {
|
|
286
|
-
|
|
287
|
-
throw new TypeError(`invalid parameter to abs2hebrew ${abs}`);
|
|
288
|
-
}
|
|
301
|
+
assertNumber(abs, 'abs');
|
|
289
302
|
abs = Math.trunc(abs);
|
|
290
303
|
if (abs <= EPOCH) {
|
|
291
304
|
throw new RangeError(`abs2hebrew: ${abs} is before epoch`);
|
|
@@ -360,7 +373,9 @@ function daysInMonth(month, year) {
|
|
|
360
373
|
* @return {string}
|
|
361
374
|
*/
|
|
362
375
|
function getMonthName(month, year) {
|
|
363
|
-
|
|
376
|
+
assertNumber(month, 'month');
|
|
377
|
+
assertNumber(year, 'year');
|
|
378
|
+
if (month < 1 || month > 14) {
|
|
364
379
|
throw new TypeError(`bad month argument ${month}`);
|
|
365
380
|
}
|
|
366
381
|
return monthNames[+isLeapYear(year)][month];
|