@hebcal/core 3.33.2 → 3.33.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +343 -354
- package/dist/bundle.js +869 -745
- package/dist/bundle.min.js +2 -2
- package/dist/hdate-bundle.js +429 -266
- package/dist/hdate-bundle.min.js +2 -2
- package/dist/hdate.js +193 -83
- package/dist/hdate.mjs +192 -84
- package/dist/index.js +319 -219
- package/dist/index.mjs +301 -221
- package/hebcal.d.ts +116 -115
- package/package.json +11 -19
package/dist/hdate-bundle.min.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
/*! @hebcal/core v3.33.
|
|
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,a=void 0;for(a=400;a>e;a-=r)a===r&&(r/=10);t.push(a),e-=a}return t}function a(e){var a=parseInt(e,10);if(!a)throw new TypeError("invalid parameter to gematriya ".concat(e));var n="",o=Math.floor(a/1e3);if(o>0&&5!==o){for(var s=r(o),u=0;u<s.length;u++)n+=t(s[u]);n+="׳"}var i=r(a%1e3);if(1==i.length)return n+t(i[0])+"׳";for(var c=0;c<i.length;c++)c+1===i.length&&(n+="״"),n+=t(i[c]);return n}function n(e){return n="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},n(e)}function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function s(e,t){for(var r=0;r<t.length;r++){var a=t[r];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(e,a.key,a)}}var u=[[0,31,28,31,30,31,30,31,31,30,31,30,31],[0,31,29,31,30,31,30,31,31,30,31,30,31]];function i(e,t){return e-t*Math.floor(e/t)}function c(e,t){return Math.floor(e/t)}var h={monthNames:["","January","February","March","April","May","June","July","August","September","October","November","December"],isLeapYear:function(e){return!(e%4||!(e%100)&&e%400)},daysInMonth:function(e,t){return u[+this.isLeapYear(t)][e]},isDate:function(e){return"object"===n(e)&&Date.prototype===e.__proto__},dayOfYear:function(e){if(!this.isDate(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),this.isLeapYear(e.getFullYear())&&t++),t},greg2abs:function(e){if(!this.isDate(e))throw new TypeError("Argument to greg.greg2abs not a Date");var t=e.getFullYear()-1;return this.dayOfYear(e)+365*t+(Math.floor(t/4)-Math.floor(t/100)+Math.floor(t/400))},yearFromFixed:function(e){var t=e-1,r=c(t,146097),a=i(t,146097),n=c(a,36524),o=i(a,36524),s=c(o,1461),u=c(i(o,1461),365),h=400*r+100*n+4*s+u;return 4!=n&&4!=u?h+1:h},toFixed:function(e,t,r){var a=e-1;return 0+365*a+c(a,4)-c(a,100)+c(a,400)+c(367*t-362,12)+Math.floor(t<=2?0:this.isLeapYear(e)?-1:-2)+r},abs2greg:function(e){if("number"!=typeof e)throw new TypeError("Argument to greg.abs2greg not a Number");e=Math.trunc(e);var t=this.yearFromFixed(e),r=c(12*(e-this.toFixed(t,1,1)+(e<this.toFixed(t,3,1)?0:this.isLeapYear(t)?1:2))+373,367),a=e-this.toFixed(t,r,1)+1,n=new Date(t,r-1,a);return t<100&&t>=0&&n.setFullYear(t),n}},l={headers:{"plural-forms":"nplurals=2; plural=(n!=1);"},contexts:{"":{}}},y={h:"he",a:"ashkenazi",s:"en","":"en"},f={locales:Object.create(null),activeLocale:null,activeName:null,lookupTranslation:function(e,t){var r=t&&t.toLowerCase(),a=("string"==typeof t&&this.locales[r]||this.activeLocale)[e];if(a&&a.length&&a[0].length)return a[0]},gettext:function(e,t){var r=this.lookupTranslation(e,t);return void 0===r?e:r},addLocale:function(e,t){if("object"!==n(t.contexts)||"object"!==n(t.contexts[""]))throw new TypeError("Locale '".concat(e,"' invalid compact format"));this.locales[e.toLowerCase()]=t.contexts[""]},useLocale:function(e){var t=e.toLowerCase(),r=this.locales[t];if(!r)throw new RangeError("Locale '".concat(e,"' not found"));return this.activeName=y[t]||t,this.activeLocale=r,this.activeLocale},getLocaleName:function(){return this.activeName},getLocaleNames:function(){return Object.keys(this.locales).sort()},ordinal: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+"."}},getEnOrdinal:function(e){var t=["th","st","nd","rd"],r=e%100;return e+(t[(r-20)%10]||t[r]||t[0])},hebrewStripNikkud:function(e){return e.replace(/[\u0590-\u05bd]/g,"").replace(/[\u05bf-\u05c7]/g,"")}};f.addLocale("en",l),f.addLocale("s",l),f.addLocale("",l),f.useLocale("en");var d=["","Nisan","Iyyar","Sivan","Tamuz","Av","Elul","Tishrei","Cheshvan","Kislev","Tevet","Sh'vat"],v=[d.concat(["Adar","Nisan"]),d.concat(["Adar I","Adar II","Nisan"])];function m(e){throw new TypeError(e)}var g=Object.create(null),b=-1373428,p="day",w="week",k="month",M="year",D={d:p,w:w,M:k,y:M},I={day:p,week:w,month:k,year:M},Y=function(){function e(t,r,a){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,this.year=+a,isNaN(this.year))throw new TypeError("HDate called with bad year argument: ".concat(a));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 n="number"!=typeof t||isNaN(t)?h.isDate(t)?h.greg2abs(t):e.isHDate(t)?{dd:t.day,mm:t.month,yy:t.year}:m("HDate called with bad argument: ".concat(t)):t,s="number"==typeof n,u=s?e.abs2hebrew(n):n;this.day=u.dd,this.month=u.mm,this.year=u.yy,s&&(this.abs0=n)}}var t,r,u;return t=e,r=[{key:"getFullYear",value:function(){return this.year}},{key:"isLeapYear",value:function(){return e.isLeapYear(this.year)}},{key:"getMonth",value:function(){return this.month}},{key:"getTishreiMonth",value:function(){var t=e.monthsInYear(this.getFullYear());return(this.getMonth()+t-6)%t||t}},{key:"daysInMonth",value:function(){return e.daysInMonth(this.getMonth(),this.getFullYear())}},{key:"getDate",value:function(){return this.day}},{key:"getDay",value:function(){return i(this.abs(),7)}},{key:"setFullYear",value:function(e){return this.year=e,L(this),this}},{key:"setMonth",value:function(t){return this.month=e.monthNum(t),L(this),this}},{key:"setDate",value:function(e){return this.day=e,L(this),this}},{key:"greg",value:function(){return h.abs2greg(this.abs())}},{key:"abs",value:function(){return"number"!=typeof this.abs0&&(this.abs0=e.hebrew2abs(this.year,this.month,this.day)),this.abs0}},{key:"getMonthName",value:function(){return e.getMonthName(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],a=t||f.getLocaleName(),n=this.getDate(),o=f.gettext(this.getMonthName(),a),s=f.ordinal(n,a),u=e.getDayOfTranslation(a),i="".concat(s).concat(u," ").concat(o);if(r){var c=this.getFullYear();return"".concat(i,", ").concat(c)}return i}},{key:"renderGematriya",value:function(){var e=this.getDate(),t=f.gettext(this.getMonthName(),"he"),r=this.getFullYear();return a(e)+" "+t+" "+a(r)}},{key:"before",value:function(e){return T(e,this,-1)}},{key:"onOrBefore",value:function(e){return T(e,this,0)}},{key:"nearest",value:function(e){return T(e,this,3)}},{key:"onOrAfter",value:function(e){return T(e,this,6)}},{key:"after",value:function(e){return T(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))===p)return new e(this.abs()+t);if(r===w)return new e(this.abs()+7*t);if(r===M)return new e(this.getDate(),this.getMonth(),this.getFullYear()+t);if(r===k){var a=new e(this),n=t>0?1:-1;t=Math.abs(t);for(var o=0;o<t;o++)a=new e(a.abs()+n*a.daysInMonth());return a}}},{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)}}],u=[{key:"hebrew2abs",value:function(t,r,a){var n=a;if(r<7){for(var o=7;o<=e.monthsInYear(t);o++)n+=e.daysInMonth(o,t);for(var s=1;s<r;s++)n+=e.daysInMonth(s,t)}else for(var u=7;u<r;u++)n+=e.daysInMonth(u,t);return b+e.elapsedDays(t)+n-1}},{key:"newYear",value:function(t){return b+e.elapsedDays(t)+e.newYearDelay(t)}},{key:"newYearDelay",value:function(t){var r=e.elapsedDays(t);return e.elapsedDays(t+1)-r==356?2:r-e.elapsedDays(t-1)==382?1:0}},{key:"abs2hebrew",value:function(t){if("number"!=typeof t||isNaN(t))throw new TypeError("invalid parameter to abs2hebrew ".concat(t));t=Math.trunc(t);for(var r=Math.floor((t-b)/365.24682220597794);e.newYear(r)<=t;)++r;--r;for(var a=t<e.hebrew2abs(r,1,1)?7:1;t>e.hebrew2abs(r,a,e.daysInMonth(a,r));)++a;return{yy:r,mm:a,dd:1+t-e.hebrew2abs(r,a,1)}}},{key:"getDayOfTranslation",value:function(e){switch(e){case"en":case"s":case"a":case"ashkenazi":return" of"}var t=f.lookupTranslation("of",e);return t?" "+t:"ashkenazi"===e.substring(0,9)?" of":""}},{key:"standardizeUnits",value:function(e){var t=D[e]||String(e||"").toLowerCase().replace(/s$/,"");return I[t]||m("Invalid units '".concat(e,"'"))}},{key:"isLeapYear",value:function(e){return(1+7*e)%19<7}},{key:"monthsInYear",value:function(t){return 12+e.isLeapYear(t)}},{key:"daysInMonth",value:function(t,r){return 2==t||4==t||6==t||10==t||13==t||12==t&&!e.isLeapYear(r)||8==t&&!e.longCheshvan(r)||9==t&&e.shortKislev(r)?29:30}},{key:"getMonthName",value:function(t,r){if("number"!=typeof t||t<1||t>14)throw new TypeError("bad month argument ".concat(t));return v[+e.isLeapYear(r)][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:"elapsedDays",value:function(t){return g[t]=g[t]||e.elapsedDays0(t)}},{key:"elapsedDays0",value:function(t){var r=t-1,a=235*Math.floor(r/19)+r%19*12+Math.floor((r%19*7+1)/19),n=204+a%1080*793,o=5+12*a+793*Math.floor(a/1080)+Math.floor(n/1080),s=n%1080+o%24*1080,u=1+29*a+Math.floor(o/24),i=u+(s>=19440||2==u%7&&s>=9924&&!e.isLeapYear(t)||1==u%7&&s>=16789&&e.isLeapYear(r));return i+(i%7==0||i%7==3||i%7==5)}},{key:"daysInYear",value:function(t){return e.elapsedDays(t+1)-e.elapsedDays(t)}},{key:"longCheshvan",value:function(t){return e.daysInYear(t)%10==5}},{key:"shortKislev",value:function(t){return e.daysInYear(t)%10==3}},{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 1;case"i":return 2;case"e":return 6;case"c":case"ח":return 8;case"k":case"כ":return 9;case"s":switch(t[1]){case"i":return 3;case"h":return 11}case"t":switch(t[1]){case"a":return 4;case"i":return 7;case"e":return 10}break;case"a":switch(t[1]){case"v":return 5;case"d":return/(1|[^i]i|a|א)$/i.test(e)?12:13}break;case"ס":return 3;case"ט":return 10;case"ש":return 11;case"א":switch(t[1]){case"ב":return 5;case"ד":return/(1|[^i]i|a|א)$/i.test(e)?12:13;case"י":return 2;case"ל":return 6}break;case"ת":switch(t[1]){case"מ":return 4;case"ש":return 7}}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"===n(e)&&"number"==typeof e.year&&"number"==typeof e.month&&"number"==typeof e.day&&"function"==typeof e.greg&&"function"==typeof e.abs}}],r&&s(t.prototype,r),u&&s(t,u),Object.defineProperty(t,"prototype",{writable:!1}),e}();function L(e){N(e),function(e){e.day<1&&(7==e.month&&(e.year-=1),e.day+=Y.daysInMonth(e.month,e.year),e.month-=1,L(e));e.day>Y.daysInMonth(e.month,e.year)&&(6==e.month&&(e.year+=1),e.day-=Y.daysInMonth(e.month,e.year),e.month+=1,L(e));N(e)}(e)}function N(e){13!=e.month||e.isLeapYear()?e.month<1?(e.month+=Y.monthsInYear(e.year),e.year-=1,L(e)):e.month>Y.monthsInYear(e.year)&&(e.month-=Y.monthsInYear(e.year),e.year+=1,L(e)):(e.month-=1,L(e)),delete e.abs0}function T(e,t,r){return new Y(Y.dayOnOrBefore(e,t.abs()+r))}var A={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 f.addLocale("he",A),f.addLocale("h",A),e.HDate=Y,e.Locale=f,e.gematriya=a,e.greg=h,e.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},e.version="3.33.2",Object.defineProperty(e,"__esModule",{value:!0}),e}({});
|
|
1
|
+
/*! @hebcal/core v3.33.5 */
|
|
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 a(e){for(var t=[];e>0;){if(15===e||16===e){t.push(9),t.push(e-9);break}var a=100,r=void 0;for(r=400;r>e;r-=a)r===a&&(a/=10);t.push(r),e-=r}return t}function r(e){var r=parseInt(e,10);if(!r)throw new TypeError("invalid parameter to gematriya ".concat(e));var n="",o=Math.floor(r/1e3);if(o>0&&5!==o){for(var s=a(o),u=0;u<s.length;u++)n+=t(s[u]);n+="׳"}var i=a(r%1e3);if(1==i.length)return n+t(i[0])+"׳";for(var h=0;h<i.length;h++)h+1===i.length&&(n+="״"),n+=t(i[h]);return n}function n(e){return n="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},n(e)}function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function s(e,t){for(var a=0;a<t.length;a++){var r=t[a];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function u(e,t,a){return t&&s(e.prototype,t),a&&s(e,a),Object.defineProperty(e,"prototype",{writable:!1}),e}function i(e,t,a){return t in e?Object.defineProperty(e,t,{value:a,enumerable:!0,configurable:!0,writable:!0}):e[t]=a,e}var h=[[0,31,28,31,30,31,30,31,31,30,31,30,31],[0,31,29,31,30,31,30,31,31,30,31,30,31]];function c(e,t){return e-t*Math.floor(e/t)}function l(e,t){return Math.floor(e/t)}var y=function(){function e(){o(this,e)}return u(e,null,[{key:"isLeapYear",value:function(e){return!(e%4||!(e%100)&&e%400)}},{key:"daysInMonth",value:function(e,t){return h[+this.isLeapYear(t)][e]}},{key:"isDate",value:function(e){return"object"===n(e)&&Date.prototype===e.__proto__}},{key:"dayOfYear",value:function(e){if(!this.isDate(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),this.isLeapYear(e.getFullYear())&&t++),t}},{key:"greg2abs",value:function(e){if(!this.isDate(e))throw new TypeError("Argument to greg.greg2abs not a Date");var t=e.getFullYear()-1;return this.dayOfYear(e)+365*t+(Math.floor(t/4)-Math.floor(t/100)+Math.floor(t/400))}},{key:"yearFromFixed",value:function(e){var t=e-1,a=l(t,146097),r=c(t,146097),n=l(r,36524),o=c(r,36524),s=l(o,1461),u=l(c(o,1461),365),i=400*a+100*n+4*s+u;return 4!=n&&4!=u?i+1:i}},{key:"toFixed",value:function(e,t,a){var r=e-1;return 0+365*r+l(r,4)-l(r,100)+l(r,400)+l(367*t-362,12)+Math.floor(t<=2?0:this.isLeapYear(e)?-1:-2)+a}},{key:"abs2greg",value:function(e){if("number"!=typeof e)throw new TypeError("Argument to greg.abs2greg not a Number");e=Math.trunc(e);var t=this.yearFromFixed(e),a=l(12*(e-this.toFixed(t,1,1)+(e<this.toFixed(t,3,1)?0:this.isLeapYear(t)?1:2))+373,367),r=e-this.toFixed(t,a,1)+1,n=new Date(t,a-1,r);return t<100&&t>=0&&n.setFullYear(t),n}}]),e}();i(y,"monthNames",["","January","February","March","April","May","June","July","August","September","October","November","December"]);var f={headers:{"plural-forms":"nplurals=2; plural=(n!=1);"},contexts:{"":{}}},v={h:"he",a:"ashkenazi",s:"en","":"en"},d=function(){function e(){o(this,e)}return u(e,null,[{key:"lookupTranslation",value:function(e,t){var a=t&&t.toLowerCase(),r=("string"==typeof t&&this.locales[a]||this.activeLocale)[e];if(r&&r.length&&r[0].length)return r[0]}},{key:"gettext",value:function(e,t){var a=this.lookupTranslation(e,t);return void 0===a?e:a}},{key:"addLocale",value:function(e,t){if("object"!==n(t.contexts)||"object"!==n(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(),a=this.locales[t];if(!a)throw new RangeError("Locale '".concat(e,"' not found"));return this.activeName=v[t]||t,this.activeLocale=a,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 a=t&&t.toLowerCase()||this.activeName;if(!a)return this.getEnOrdinal(e);switch(a){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"],a=e%100;return e+(t[(a-20)%10]||t[a]||t[0])}},{key:"hebrewStripNikkud",value:function(e){return e.replace(/[\u0590-\u05bd]/g,"").replace(/[\u05bf-\u05c7]/g,"")}}]),e}();i(d,"locales",Object.create(null)),i(d,"activeLocale",null),i(d,"activeName",null),d.addLocale("en",f),d.addLocale("s",f),d.addLocale("",f),d.useLocale("en");var m={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},g=["","Nisan","Iyyar","Sivan","Tamuz","Av","Elul","Tishrei","Cheshvan","Kislev","Tevet","Sh'vat"],b=[g.concat(["Adar","Nisan"]),g.concat(["Adar I","Adar II","Nisan"])];function p(e){throw new TypeError(e)}var k=Object.create(null),w=-1373428,D="day",M="week",Y="month",I="year",L={d:D,w:M,M:Y,y:I},N={day:D,week:M,month:Y,year:I},A=function(){function e(t,a,r){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,this.year=+r,isNaN(this.year))throw new TypeError("HDate called with bad year argument: ".concat(r));if(this.setMonth(a),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 n="number"!=typeof t||isNaN(t)?y.isDate(t)?y.greg2abs(t):e.isHDate(t)?{dd:t.day,mm:t.month,yy:t.year}:p("HDate called with bad argument: ".concat(t)):t,s="number"==typeof n,u=s?e.abs2hebrew(n):n;this.day=u.dd,this.month=u.mm,this.year=u.yy,s&&(this.abs0=n)}}return u(e,[{key:"getFullYear",value:function(){return this.year}},{key:"isLeapYear",value:function(){return e.isLeapYear(this.year)}},{key:"getMonth",value:function(){return this.month}},{key:"getTishreiMonth",value:function(){var t=e.monthsInYear(this.getFullYear());return(this.getMonth()+t-6)%t||t}},{key:"daysInMonth",value:function(){return e.daysInMonth(this.getMonth(),this.getFullYear())}},{key:"getDate",value:function(){return this.day}},{key:"getDay",value:function(){return c(this.abs(),7)}},{key:"setFullYear",value:function(e){return this.year=e,T(this),this}},{key:"setMonth",value:function(t){return this.month=e.monthNum(t),T(this),this}},{key:"setDate",value:function(e){return this.day=e,T(this),this}},{key:"greg",value:function(){return y.abs2greg(this.abs())}},{key:"abs",value:function(){return"number"!=typeof this.abs0&&(this.abs0=e.hebrew2abs(this.year,this.month,this.day)),this.abs0}},{key:"getMonthName",value:function(){return e.getMonthName(this.getMonth(),this.getFullYear())}},{key:"render",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null,a=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],r=t||d.getLocaleName(),n=this.getDate(),o=d.gettext(this.getMonthName(),r),s=d.ordinal(n,r),u=e.getDayOfTranslation(r),i="".concat(s).concat(u," ").concat(o);if(a){var h=this.getFullYear();return"".concat(i,", ").concat(h)}return i}},{key:"renderGematriya",value:function(){var e=this.getDate(),t=d.gettext(this.getMonthName(),"he"),a=this.getFullYear();return r(e)+" "+t+" "+r(a)}},{key:"before",value:function(e){return F(e,this,-1)}},{key:"onOrBefore",value:function(e){return F(e,this,0)}},{key:"nearest",value:function(e){return F(e,this,3)}},{key:"onOrAfter",value:function(e){return F(e,this,6)}},{key:"after",value:function(e){return F(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 a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"d";if(!(t=parseInt(t,10)))return new e(this);if((a=e.standardizeUnits(a))===D)return new e(this.abs()+t);if(a===M)return new e(this.abs()+7*t);if(a===I)return new e(this.getDate(),this.getMonth(),this.getFullYear()+t);if(a===Y){var r=new e(this),n=t>0?1:-1;t=Math.abs(t);for(var o=0;o<t;o++)r=new e(r.abs()+n*r.daysInMonth());return r}}},{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(),a=this.getMonthName();return"".concat(e," ").concat(a," ").concat(t)}}],[{key:"hebrew2abs",value:function(t,a,r){var n=r;if(a<7){for(var o=7;o<=e.monthsInYear(t);o++)n+=e.daysInMonth(o,t);for(var s=1;s<a;s++)n+=e.daysInMonth(s,t)}else for(var u=7;u<a;u++)n+=e.daysInMonth(u,t);return w+e.elapsedDays(t)+n-1}},{key:"newYear",value:function(t){return w+e.elapsedDays(t)+e.newYearDelay(t)}},{key:"newYearDelay",value:function(t){var a=e.elapsedDays(t);return e.elapsedDays(t+1)-a==356?2:a-e.elapsedDays(t-1)==382?1:0}},{key:"abs2hebrew",value:function(t){if("number"!=typeof t||isNaN(t))throw new TypeError("invalid parameter to abs2hebrew ".concat(t));t=Math.trunc(t);for(var a=Math.floor((t-w)/365.24682220597794);e.newYear(a)<=t;)++a;--a;for(var r=t<e.hebrew2abs(a,1,1)?7:1;t>e.hebrew2abs(a,r,e.daysInMonth(r,a));)++r;return{yy:a,mm:r,dd:1+t-e.hebrew2abs(a,r,1)}}},{key:"getDayOfTranslation",value:function(e){switch(e){case"en":case"s":case"a":case"ashkenazi":return" of"}var t=d.lookupTranslation("of",e);return t?" "+t:"ashkenazi"===e.substring(0,9)?" of":""}},{key:"standardizeUnits",value:function(e){var t=L[e]||String(e||"").toLowerCase().replace(/s$/,"");return N[t]||p("Invalid units '".concat(e,"'"))}},{key:"isLeapYear",value:function(e){return(1+7*e)%19<7}},{key:"monthsInYear",value:function(t){return 12+e.isLeapYear(t)}},{key:"daysInMonth",value:function(t,a){return 2==t||4==t||6==t||10==t||13==t||12==t&&!e.isLeapYear(a)||8==t&&!e.longCheshvan(a)||9==t&&e.shortKislev(a)?29:30}},{key:"getMonthName",value:function(t,a){if("number"!=typeof t||t<1||t>14)throw new TypeError("bad month argument ".concat(t));return b[+e.isLeapYear(a)][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:"elapsedDays",value:function(t){return k[t]=k[t]||e.elapsedDays0(t)}},{key:"elapsedDays0",value:function(t){var a=t-1,r=235*Math.floor(a/19)+a%19*12+Math.floor((a%19*7+1)/19),n=204+r%1080*793,o=5+12*r+793*Math.floor(r/1080)+Math.floor(n/1080),s=n%1080+o%24*1080,u=1+29*r+Math.floor(o/24),i=u+(s>=19440||2==u%7&&s>=9924&&!e.isLeapYear(t)||1==u%7&&s>=16789&&e.isLeapYear(a));return i+(i%7==0||i%7==3||i%7==5)}},{key:"daysInYear",value:function(t){return e.elapsedDays(t+1)-e.elapsedDays(t)}},{key:"longCheshvan",value:function(t){return e.daysInYear(t)%10==5}},{key:"shortKislev",value:function(t){return e.daysInYear(t)%10==3}},{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 1;case"i":return 2;case"e":return 6;case"c":case"ח":return 8;case"k":case"כ":return 9;case"s":switch(t[1]){case"i":return 3;case"h":return 11}case"t":switch(t[1]){case"a":return 4;case"i":return 7;case"e":return 10}break;case"a":switch(t[1]){case"v":return 5;case"d":return/(1|[^i]i|a|א)$/i.test(e)?12:13}break;case"ס":return 3;case"ט":return 10;case"ש":return 11;case"א":switch(t[1]){case"ב":return 5;case"ד":return/(1|[^i]i|a|א)$/i.test(e)?12:13;case"י":return 2;case"ל":return 6}break;case"ת":switch(t[1]){case"מ":return 4;case"ש":return 7}}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"===n(e)&&"number"==typeof e.year&&"number"==typeof e.month&&"number"==typeof e.day&&"function"==typeof e.greg&&"function"==typeof e.abs}}]),e}();function T(e){E(e),function(e){e.day<1&&(7==e.month&&(e.year-=1),e.day+=A.daysInMonth(e.month,e.year),e.month-=1,T(e));e.day>A.daysInMonth(e.month,e.year)&&(6==e.month&&(e.year+=1),e.day-=A.daysInMonth(e.month,e.year),e.month+=1,T(e));E(e)}(e)}function E(e){13!=e.month||e.isLeapYear()?e.month<1?(e.month+=A.monthsInYear(e.year),e.year-=1,T(e)):e.month>A.monthsInYear(e.year)&&(e.month-=A.monthsInYear(e.year),e.year+=1,T(e)):(e.month-=1,T(e)),delete e.abs0}function F(e,t,a){return new A(A.dayOnOrBefore(e,t.abs()+a))}var S=m.NISAN,O=m.CHESHVAN,C=m.KISLEV,H=m.TEVET,x=m.SHVAT,_=m.ADAR_I,z=m.ADAR_II;var j={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 d.addLocale("he",j),d.addLocale("h",j),e.HDate=A,e.Locale=d,e.gematriya=r,e.getBirthdayOrAnniversary=function(e,t){var a=A.isHDate(t)?t:new A(t),r=a.getFullYear();if(!(e<=r)){var n=A.isLeapYear(r),o=a.getMonth(),s=a.getDate();return o==_&&!n||o==z&&n?o=A.monthsInYear(e):o!=O||30!=s||A.longCheshvan(e)?o==C&&30==s&&A.shortKislev(e)?(o=H,s=1):o==_&&30==s&&n&&!A.isLeapYear(e)&&(o=S,s=1):(o=C,s=1),new A(s,o,e)}},e.getYahrzeit=function(e,t){var a=A.isHDate(t)?t:new A(t),r={yy:a.getFullYear(),mm:a.getMonth(),dd:a.getDate()};if(!(e<=r.yy))return r.mm!=O||30!=r.dd||A.longCheshvan(r.yy+1)?r.mm==C&&30==r.dd&&A.shortKislev(r.yy+1)?r=A.abs2hebrew(A.hebrew2abs(e,H,1)-1):r.mm==z?r.mm=A.monthsInYear(e):r.mm!=_||30!=r.dd||A.isLeapYear(e)||(r.dd=30,r.mm=x):r=A.abs2hebrew(A.hebrew2abs(e,C,1)-1),r.mm!=O||30!=r.dd||A.longCheshvan(e)?r.mm==C&&30==r.dd&&A.shortKislev(e)&&(r.mm=H,r.dd=1):(r.mm=C,r.dd=1),new A(r.dd,r.mm,e)},e.greg=y,e.months=m,e.version="3.33.5",Object.defineProperty(e,"__esModule",{value:!0}),e}({});
|
package/dist/hdate.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! @hebcal/core v3.33.
|
|
1
|
+
/*! @hebcal/core v3.33.5 */
|
|
2
2
|
'use strict';
|
|
3
3
|
|
|
4
4
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
@@ -211,53 +211,55 @@ function quotient(x, y) {
|
|
|
211
211
|
}
|
|
212
212
|
/**
|
|
213
213
|
* Gregorian date helper functions.
|
|
214
|
-
* @namespace
|
|
215
214
|
*/
|
|
216
215
|
|
|
217
216
|
|
|
218
|
-
|
|
217
|
+
class greg {
|
|
219
218
|
/**
|
|
220
219
|
* Long names of the Gregorian months (1='January', 12='December')
|
|
221
220
|
* @readonly
|
|
222
221
|
* @type {string[]}
|
|
223
222
|
*/
|
|
224
|
-
monthNames
|
|
225
|
-
|
|
223
|
+
static monthNames = ['', 'January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'];
|
|
226
224
|
/**
|
|
227
225
|
* Returns true if the Gregorian year is a leap year
|
|
228
226
|
* @param {number} year Gregorian year
|
|
229
227
|
* @return {boolean}
|
|
230
228
|
*/
|
|
231
|
-
isLeapYear: function (year) {
|
|
232
|
-
return !(year % 4) && (!!(year % 100) || !(year % 400));
|
|
233
|
-
},
|
|
234
229
|
|
|
230
|
+
static isLeapYear(year) {
|
|
231
|
+
return !(year % 4) && (!!(year % 100) || !(year % 400));
|
|
232
|
+
}
|
|
235
233
|
/**
|
|
236
234
|
* Number of days in the Gregorian month for given year
|
|
237
235
|
* @param {number} month Gregorian month (1=January, 12=December)
|
|
238
236
|
* @param {number} year Gregorian year
|
|
239
237
|
* @return {number}
|
|
240
238
|
*/
|
|
241
|
-
|
|
239
|
+
|
|
240
|
+
|
|
241
|
+
static daysInMonth(month, year) {
|
|
242
242
|
// 1 based months
|
|
243
243
|
return monthLengths[+this.isLeapYear(year)][month];
|
|
244
|
-
}
|
|
245
|
-
|
|
244
|
+
}
|
|
246
245
|
/**
|
|
247
246
|
* Returns true if the object is a Javascript Date
|
|
248
247
|
* @param {Object} obj
|
|
249
248
|
* @return {boolean}
|
|
250
249
|
*/
|
|
251
|
-
isDate: function (obj) {
|
|
252
|
-
return typeof obj === 'object' && Date.prototype === obj.__proto__;
|
|
253
|
-
},
|
|
254
250
|
|
|
251
|
+
|
|
252
|
+
static isDate(obj) {
|
|
253
|
+
return typeof obj === 'object' && Date.prototype === obj.__proto__;
|
|
254
|
+
}
|
|
255
255
|
/**
|
|
256
256
|
* Returns number of days since January 1 of that year
|
|
257
257
|
* @param {Date} date Gregorian date
|
|
258
258
|
* @return {number}
|
|
259
259
|
*/
|
|
260
|
-
|
|
260
|
+
|
|
261
|
+
|
|
262
|
+
static dayOfYear(date) {
|
|
261
263
|
if (!this.isDate(date)) {
|
|
262
264
|
throw new TypeError('Argument to greg.dayOfYear not a Date');
|
|
263
265
|
}
|
|
@@ -274,14 +276,15 @@ const greg = {
|
|
|
274
276
|
}
|
|
275
277
|
|
|
276
278
|
return doy;
|
|
277
|
-
}
|
|
278
|
-
|
|
279
|
+
}
|
|
279
280
|
/**
|
|
280
281
|
* Converts Gregorian date to absolute R.D. (Rata Die) days
|
|
281
282
|
* @param {Date} date Gregorian date
|
|
282
283
|
* @return {number}
|
|
283
284
|
*/
|
|
284
|
-
|
|
285
|
+
|
|
286
|
+
|
|
287
|
+
static greg2abs(date) {
|
|
285
288
|
if (!this.isDate(date)) {
|
|
286
289
|
throw new TypeError('Argument to greg.greg2abs not a Date');
|
|
287
290
|
}
|
|
@@ -292,14 +295,15 @@ const greg = {
|
|
|
292
295
|
Math.floor(year / 4) - // + Julian Leap years
|
|
293
296
|
Math.floor(year / 100) + // - century years
|
|
294
297
|
Math.floor(year / 400)); // + Gregorian leap years
|
|
295
|
-
}
|
|
296
|
-
|
|
298
|
+
}
|
|
297
299
|
/**
|
|
298
300
|
* @private
|
|
299
301
|
* @param {number} theDate - R.D. number of days
|
|
300
302
|
* @return {number}
|
|
301
303
|
*/
|
|
302
|
-
|
|
304
|
+
|
|
305
|
+
|
|
306
|
+
static yearFromFixed(theDate) {
|
|
303
307
|
const l0 = theDate - 1;
|
|
304
308
|
const n400 = quotient(l0, 146097);
|
|
305
309
|
const d1 = mod(l0, 146097);
|
|
@@ -310,8 +314,7 @@ const greg = {
|
|
|
310
314
|
const n1 = quotient(d3, 365);
|
|
311
315
|
const year = 400 * n400 + 100 * n100 + 4 * n4 + n1;
|
|
312
316
|
return n100 != 4 && n1 != 4 ? year + 1 : year;
|
|
313
|
-
}
|
|
314
|
-
|
|
317
|
+
}
|
|
315
318
|
/**
|
|
316
319
|
* @private
|
|
317
320
|
* @param {number} year
|
|
@@ -319,11 +322,12 @@ const greg = {
|
|
|
319
322
|
* @param {number} day
|
|
320
323
|
* @return {number}
|
|
321
324
|
*/
|
|
322
|
-
|
|
325
|
+
|
|
326
|
+
|
|
327
|
+
static toFixed(year, month, day) {
|
|
323
328
|
const py = year - 1;
|
|
324
329
|
return 0 + 365 * py + quotient(py, 4) - quotient(py, 100) + quotient(py, 400) + quotient(367 * month - 362, 12) + Math.floor(month <= 2 ? 0 : this.isLeapYear(year) ? -1 : -2) + day;
|
|
325
|
-
}
|
|
326
|
-
|
|
330
|
+
}
|
|
327
331
|
/**
|
|
328
332
|
* Converts from Rata Die (R.D. number) to Gregorian date.
|
|
329
333
|
* See the footnote on page 384 of ``Calendrical Calculations, Part II:
|
|
@@ -333,7 +337,9 @@ const greg = {
|
|
|
333
337
|
* @param {number} theDate - R.D. number of days
|
|
334
338
|
* @return {Date}
|
|
335
339
|
*/
|
|
336
|
-
|
|
340
|
+
|
|
341
|
+
|
|
342
|
+
static abs2greg(theDate) {
|
|
337
343
|
if (typeof theDate !== 'number') {
|
|
338
344
|
throw new TypeError('Argument to greg.abs2greg not a Number');
|
|
339
345
|
}
|
|
@@ -352,7 +358,8 @@ const greg = {
|
|
|
352
358
|
|
|
353
359
|
return dt;
|
|
354
360
|
}
|
|
355
|
-
|
|
361
|
+
|
|
362
|
+
}
|
|
356
363
|
|
|
357
364
|
const noopLocale = {
|
|
358
365
|
headers: {
|
|
@@ -375,19 +382,17 @@ const alias = {
|
|
|
375
382
|
* * `ashkenazi` - Ashkenazi transliterations (e.g. "Shabbos")
|
|
376
383
|
* * `he` - Hebrew (e.g. "שַׁבָּת")
|
|
377
384
|
* * `he-x-NoNikud` - Hebrew without nikud (e.g. "שבת")
|
|
378
|
-
* @namespace
|
|
379
385
|
*/
|
|
380
386
|
|
|
381
|
-
|
|
387
|
+
class Locale {
|
|
382
388
|
/** @private */
|
|
383
|
-
locales
|
|
384
|
-
|
|
389
|
+
static locales = Object.create(null);
|
|
385
390
|
/** @private */
|
|
386
|
-
activeLocale: null,
|
|
387
391
|
|
|
392
|
+
static activeLocale = null;
|
|
388
393
|
/** @private */
|
|
389
|
-
activeName: null,
|
|
390
394
|
|
|
395
|
+
static activeName = null;
|
|
391
396
|
/**
|
|
392
397
|
* Returns translation only if `locale` offers a non-empty translation for `id`.
|
|
393
398
|
* Otherwise, returns `undefined`.
|
|
@@ -395,7 +400,8 @@ const Locale = {
|
|
|
395
400
|
* @param {string} [locale] Optional locale name (i.e: `'he'`, `'fr'`). Defaults to active locale.
|
|
396
401
|
* @return {string}
|
|
397
402
|
*/
|
|
398
|
-
|
|
403
|
+
|
|
404
|
+
static lookupTranslation(id, locale) {
|
|
399
405
|
const locale0 = locale && locale.toLowerCase();
|
|
400
406
|
const loc = typeof locale == 'string' && this.locales[locale0] || this.activeLocale;
|
|
401
407
|
const array = loc[id];
|
|
@@ -405,15 +411,16 @@ const Locale = {
|
|
|
405
411
|
}
|
|
406
412
|
|
|
407
413
|
return undefined;
|
|
408
|
-
}
|
|
409
|
-
|
|
414
|
+
}
|
|
410
415
|
/**
|
|
411
416
|
* By default, if no translation was found, returns `id`.
|
|
412
417
|
* @param {string} id Message ID to translate
|
|
413
418
|
* @param {string} [locale] Optional locale name (i.e: `'he'`, `'fr'`). Defaults to active locale.
|
|
414
419
|
* @return {string}
|
|
415
420
|
*/
|
|
416
|
-
|
|
421
|
+
|
|
422
|
+
|
|
423
|
+
static gettext(id, locale) {
|
|
417
424
|
const text = this.lookupTranslation(id, locale);
|
|
418
425
|
|
|
419
426
|
if (typeof text == 'undefined') {
|
|
@@ -421,21 +428,21 @@ const Locale = {
|
|
|
421
428
|
}
|
|
422
429
|
|
|
423
430
|
return text;
|
|
424
|
-
}
|
|
425
|
-
|
|
431
|
+
}
|
|
426
432
|
/**
|
|
427
433
|
* Register locale translations.
|
|
428
434
|
* @param {string} locale Locale name (i.e.: `'he'`, `'fr'`)
|
|
429
435
|
* @param {LocaleDate} data parsed data from a `.po` file.
|
|
430
436
|
*/
|
|
431
|
-
|
|
437
|
+
|
|
438
|
+
|
|
439
|
+
static addLocale(locale, data) {
|
|
432
440
|
if (typeof data.contexts !== 'object' || typeof data.contexts[''] !== 'object') {
|
|
433
441
|
throw new TypeError(`Locale '${locale}' invalid compact format`);
|
|
434
442
|
}
|
|
435
443
|
|
|
436
444
|
this.locales[locale.toLowerCase()] = data.contexts[''];
|
|
437
|
-
}
|
|
438
|
-
|
|
445
|
+
}
|
|
439
446
|
/**
|
|
440
447
|
* Activates a locale. Throws an error if the locale has not been previously added.
|
|
441
448
|
* After setting the locale to be used, all strings marked for translations
|
|
@@ -443,7 +450,9 @@ const Locale = {
|
|
|
443
450
|
* @param {string} locale Locale name (i.e: `'he'`, `'fr'`)
|
|
444
451
|
* @return {LocaleData}
|
|
445
452
|
*/
|
|
446
|
-
|
|
453
|
+
|
|
454
|
+
|
|
455
|
+
static useLocale(locale) {
|
|
447
456
|
const locale0 = locale.toLowerCase();
|
|
448
457
|
const obj = this.locales[locale0];
|
|
449
458
|
|
|
@@ -454,30 +463,33 @@ const Locale = {
|
|
|
454
463
|
this.activeName = alias[locale0] || locale0;
|
|
455
464
|
this.activeLocale = obj;
|
|
456
465
|
return this.activeLocale;
|
|
457
|
-
}
|
|
458
|
-
|
|
466
|
+
}
|
|
459
467
|
/**
|
|
460
468
|
* Returns the name of the active locale (i.e. 'he', 'ashkenazi', 'fr')
|
|
461
469
|
* @return {string}
|
|
462
470
|
*/
|
|
463
|
-
getLocaleName: function getLocaleName() {
|
|
464
|
-
return this.activeName;
|
|
465
|
-
},
|
|
466
471
|
|
|
472
|
+
|
|
473
|
+
static getLocaleName() {
|
|
474
|
+
return this.activeName;
|
|
475
|
+
}
|
|
467
476
|
/**
|
|
468
477
|
* Returns the names of registered locales
|
|
469
478
|
* @return {string[]}
|
|
470
479
|
*/
|
|
471
|
-
getLocaleNames: function getLocaleNames() {
|
|
472
|
-
return Object.keys(this.locales).sort();
|
|
473
|
-
},
|
|
474
480
|
|
|
481
|
+
|
|
482
|
+
static getLocaleNames() {
|
|
483
|
+
return Object.keys(this.locales).sort();
|
|
484
|
+
}
|
|
475
485
|
/**
|
|
476
486
|
* @param {number} n
|
|
477
487
|
* @param {string} [locale] Optional locale name (i.e: `'he'`, `'fr'`). Defaults to active locale.
|
|
478
488
|
* @return {string}
|
|
479
489
|
*/
|
|
480
|
-
|
|
490
|
+
|
|
491
|
+
|
|
492
|
+
static ordinal(n, locale) {
|
|
481
493
|
const locale1 = locale && locale.toLowerCase();
|
|
482
494
|
const locale0 = locale1 || this.activeName;
|
|
483
495
|
|
|
@@ -506,28 +518,31 @@ const Locale = {
|
|
|
506
518
|
default:
|
|
507
519
|
return n + '.';
|
|
508
520
|
}
|
|
509
|
-
}
|
|
510
|
-
|
|
521
|
+
}
|
|
511
522
|
/**
|
|
512
523
|
* @private
|
|
513
524
|
* @param {number} n
|
|
514
525
|
* @return {string}
|
|
515
526
|
*/
|
|
516
|
-
|
|
527
|
+
|
|
528
|
+
|
|
529
|
+
static getEnOrdinal(n) {
|
|
517
530
|
const s = ['th', 'st', 'nd', 'rd'];
|
|
518
531
|
const v = n % 100;
|
|
519
532
|
return n + (s[(v - 20) % 10] || s[v] || s[0]);
|
|
520
|
-
}
|
|
521
|
-
|
|
533
|
+
}
|
|
522
534
|
/**
|
|
523
535
|
* Removes nekudot from Hebrew string
|
|
524
536
|
* @param {string} str
|
|
525
537
|
* @return {string}
|
|
526
538
|
*/
|
|
527
|
-
|
|
539
|
+
|
|
540
|
+
|
|
541
|
+
static hebrewStripNikkud(str) {
|
|
528
542
|
return str.replace(/[\u0590-\u05bd]/g, '').replace(/[\u05bf-\u05c7]/g, '');
|
|
529
543
|
}
|
|
530
|
-
|
|
544
|
+
|
|
545
|
+
}
|
|
531
546
|
Locale.addLocale('en', noopLocale);
|
|
532
547
|
Locale.addLocale('s', noopLocale);
|
|
533
548
|
Locale.addLocale('', noopLocale);
|
|
@@ -553,19 +568,19 @@ Locale.useLocale('en');
|
|
|
553
568
|
You should have received a copy of the GNU General Public License
|
|
554
569
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
555
570
|
*/
|
|
556
|
-
const NISAN = 1;
|
|
571
|
+
const NISAN$1 = 1;
|
|
557
572
|
const IYYAR = 2;
|
|
558
573
|
const SIVAN = 3;
|
|
559
574
|
const TAMUZ = 4;
|
|
560
575
|
const AV = 5;
|
|
561
576
|
const ELUL = 6;
|
|
562
577
|
const TISHREI = 7;
|
|
563
|
-
const CHESHVAN = 8;
|
|
564
|
-
const KISLEV = 9;
|
|
565
|
-
const TEVET = 10;
|
|
566
|
-
const SHVAT = 11;
|
|
567
|
-
const ADAR_I = 12;
|
|
568
|
-
const ADAR_II = 13;
|
|
578
|
+
const CHESHVAN$1 = 8;
|
|
579
|
+
const KISLEV$1 = 9;
|
|
580
|
+
const TEVET$1 = 10;
|
|
581
|
+
const SHVAT$1 = 11;
|
|
582
|
+
const ADAR_I$1 = 12;
|
|
583
|
+
const ADAR_II$1 = 13;
|
|
569
584
|
/**
|
|
570
585
|
* Hebrew months of the year (NISAN=1, TISHREI=7)
|
|
571
586
|
* @readonly
|
|
@@ -907,7 +922,7 @@ class HDate {
|
|
|
907
922
|
tempabs += HDate.daysInMonth(m, year);
|
|
908
923
|
}
|
|
909
924
|
|
|
910
|
-
for (let m = NISAN; m < month; m++) {
|
|
925
|
+
for (let m = NISAN$1; m < month; m++) {
|
|
911
926
|
tempabs += HDate.daysInMonth(m, year);
|
|
912
927
|
}
|
|
913
928
|
} else {
|
|
@@ -1053,7 +1068,7 @@ class HDate {
|
|
|
1053
1068
|
* @example
|
|
1054
1069
|
* import {HDate, months} from '@hebcal/core';
|
|
1055
1070
|
* const hd = new HDate(15, months.CHESHVAN, 5769);
|
|
1056
|
-
* console.log(
|
|
1071
|
+
* console.log(hd.renderGematriya()); // 'ט״ו חֶשְׁוָן תשס״ט'
|
|
1057
1072
|
* @return {string}
|
|
1058
1073
|
*/
|
|
1059
1074
|
|
|
@@ -1315,7 +1330,7 @@ class HDate {
|
|
|
1315
1330
|
|
|
1316
1331
|
|
|
1317
1332
|
static daysInMonth(month, year) {
|
|
1318
|
-
if (month == IYYAR || month == TAMUZ || month == ELUL || month == TEVET || month == ADAR_II || month == ADAR_I && !HDate.isLeapYear(year) || month == CHESHVAN && !HDate.longCheshvan(year) || month == KISLEV && HDate.shortKislev(year)) {
|
|
1333
|
+
if (month == IYYAR || month == TAMUZ || month == ELUL || month == TEVET$1 || month == ADAR_II$1 || month == ADAR_I$1 && !HDate.isLeapYear(year) || month == CHESHVAN$1 && !HDate.longCheshvan(year) || month == KISLEV$1 && HDate.shortKislev(year)) {
|
|
1319
1334
|
return 29;
|
|
1320
1335
|
} else {
|
|
1321
1336
|
return 30;
|
|
@@ -1453,7 +1468,7 @@ class HDate {
|
|
|
1453
1468
|
/* this catches "november" */
|
|
1454
1469
|
}
|
|
1455
1470
|
|
|
1456
|
-
return NISAN;
|
|
1471
|
+
return NISAN$1;
|
|
1457
1472
|
|
|
1458
1473
|
case 'i':
|
|
1459
1474
|
return IYYAR;
|
|
@@ -1463,11 +1478,11 @@ class HDate {
|
|
|
1463
1478
|
|
|
1464
1479
|
case 'c':
|
|
1465
1480
|
case 'ח':
|
|
1466
|
-
return CHESHVAN;
|
|
1481
|
+
return CHESHVAN$1;
|
|
1467
1482
|
|
|
1468
1483
|
case 'k':
|
|
1469
1484
|
case 'כ':
|
|
1470
|
-
return KISLEV;
|
|
1485
|
+
return KISLEV$1;
|
|
1471
1486
|
|
|
1472
1487
|
case 's':
|
|
1473
1488
|
switch (c[1]) {
|
|
@@ -1475,7 +1490,7 @@ class HDate {
|
|
|
1475
1490
|
return SIVAN;
|
|
1476
1491
|
|
|
1477
1492
|
case 'h':
|
|
1478
|
-
return SHVAT;
|
|
1493
|
+
return SHVAT$1;
|
|
1479
1494
|
}
|
|
1480
1495
|
|
|
1481
1496
|
case 't':
|
|
@@ -1487,7 +1502,7 @@ class HDate {
|
|
|
1487
1502
|
return TISHREI;
|
|
1488
1503
|
|
|
1489
1504
|
case 'e':
|
|
1490
|
-
return TEVET;
|
|
1505
|
+
return TEVET$1;
|
|
1491
1506
|
}
|
|
1492
1507
|
|
|
1493
1508
|
break;
|
|
@@ -1499,10 +1514,10 @@ class HDate {
|
|
|
1499
1514
|
|
|
1500
1515
|
case 'd':
|
|
1501
1516
|
if (/(1|[^i]i|a|א)$/i.test(monthName)) {
|
|
1502
|
-
return ADAR_I;
|
|
1517
|
+
return ADAR_I$1;
|
|
1503
1518
|
}
|
|
1504
1519
|
|
|
1505
|
-
return ADAR_II;
|
|
1520
|
+
return ADAR_II$1;
|
|
1506
1521
|
// else assume sheini
|
|
1507
1522
|
}
|
|
1508
1523
|
|
|
@@ -1512,10 +1527,10 @@ class HDate {
|
|
|
1512
1527
|
return SIVAN;
|
|
1513
1528
|
|
|
1514
1529
|
case 'ט':
|
|
1515
|
-
return TEVET;
|
|
1530
|
+
return TEVET$1;
|
|
1516
1531
|
|
|
1517
1532
|
case 'ש':
|
|
1518
|
-
return SHVAT;
|
|
1533
|
+
return SHVAT$1;
|
|
1519
1534
|
|
|
1520
1535
|
case 'א':
|
|
1521
1536
|
switch (c[1]) {
|
|
@@ -1524,10 +1539,10 @@ class HDate {
|
|
|
1524
1539
|
|
|
1525
1540
|
case 'ד':
|
|
1526
1541
|
if (/(1|[^i]i|a|א)$/i.test(monthName)) {
|
|
1527
|
-
return ADAR_I;
|
|
1542
|
+
return ADAR_I$1;
|
|
1528
1543
|
}
|
|
1529
1544
|
|
|
1530
|
-
return ADAR_II;
|
|
1545
|
+
return ADAR_II$1;
|
|
1531
1546
|
// else assume sheini
|
|
1532
1547
|
|
|
1533
1548
|
case 'י':
|
|
@@ -1624,7 +1639,7 @@ function fixDate(date) {
|
|
|
1624
1639
|
|
|
1625
1640
|
|
|
1626
1641
|
function fixMonth(date) {
|
|
1627
|
-
if (date.month == ADAR_II && !date.isLeapYear()) {
|
|
1642
|
+
if (date.month == ADAR_II$1 && !date.isLeapYear()) {
|
|
1628
1643
|
date.month -= 1; // to Adar I
|
|
1629
1644
|
|
|
1630
1645
|
fix(date);
|
|
@@ -1653,7 +1668,100 @@ function onOrBefore(day, t, offset) {
|
|
|
1653
1668
|
return new HDate(HDate.dayOnOrBefore(day, t.abs() + offset));
|
|
1654
1669
|
}
|
|
1655
1670
|
|
|
1656
|
-
|
|
1671
|
+
const NISAN = months.NISAN;
|
|
1672
|
+
const CHESHVAN = months.CHESHVAN;
|
|
1673
|
+
const KISLEV = months.KISLEV;
|
|
1674
|
+
const TEVET = months.TEVET;
|
|
1675
|
+
const SHVAT = months.SHVAT;
|
|
1676
|
+
const ADAR_I = months.ADAR_I;
|
|
1677
|
+
const ADAR_II = months.ADAR_II;
|
|
1678
|
+
/**
|
|
1679
|
+
* @private
|
|
1680
|
+
* @param {number} hyear Hebrew year
|
|
1681
|
+
* @param {Date|HDate} gdate Gregorian or Hebrew date of death
|
|
1682
|
+
* @return {HDate} anniversary occurring in hyear
|
|
1683
|
+
*/
|
|
1684
|
+
|
|
1685
|
+
function getYahrzeit_(hyear, gdate) {
|
|
1686
|
+
const orig = HDate.isHDate(gdate) ? gdate : new HDate(gdate);
|
|
1687
|
+
let hDeath = {
|
|
1688
|
+
yy: orig.getFullYear(),
|
|
1689
|
+
mm: orig.getMonth(),
|
|
1690
|
+
dd: orig.getDate()
|
|
1691
|
+
};
|
|
1692
|
+
|
|
1693
|
+
if (hyear <= hDeath.yy) {
|
|
1694
|
+
// `Hebrew year ${hyear} occurs on or before original date in ${hDeath.yy}`
|
|
1695
|
+
return undefined;
|
|
1696
|
+
}
|
|
1697
|
+
|
|
1698
|
+
if (hDeath.mm == CHESHVAN && hDeath.dd == 30 && !HDate.longCheshvan(hDeath.yy + 1)) {
|
|
1699
|
+
// If it's Heshvan 30 it depends on the first anniversary;
|
|
1700
|
+
// if that was not Heshvan 30, use the day before Kislev 1.
|
|
1701
|
+
hDeath = HDate.abs2hebrew(HDate.hebrew2abs(hyear, KISLEV, 1) - 1);
|
|
1702
|
+
} else if (hDeath.mm == KISLEV && hDeath.dd == 30 && HDate.shortKislev(hDeath.yy + 1)) {
|
|
1703
|
+
// If it's Kislev 30 it depends on the first anniversary;
|
|
1704
|
+
// if that was not Kislev 30, use the day before Teveth 1.
|
|
1705
|
+
hDeath = HDate.abs2hebrew(HDate.hebrew2abs(hyear, TEVET, 1) - 1);
|
|
1706
|
+
} else if (hDeath.mm == ADAR_II) {
|
|
1707
|
+
// If it's Adar II, use the same day in last month of year (Adar or Adar II).
|
|
1708
|
+
hDeath.mm = HDate.monthsInYear(hyear);
|
|
1709
|
+
} else if (hDeath.mm == ADAR_I && hDeath.dd == 30 && !HDate.isLeapYear(hyear)) {
|
|
1710
|
+
// If it's the 30th in Adar I and year is not a leap year
|
|
1711
|
+
// (so Adar has only 29 days), use the last day in Shevat.
|
|
1712
|
+
hDeath.dd = 30;
|
|
1713
|
+
hDeath.mm = SHVAT;
|
|
1714
|
+
} // In all other cases, use the normal anniversary of the date of death.
|
|
1715
|
+
// advance day to rosh chodesh if needed
|
|
1716
|
+
|
|
1717
|
+
|
|
1718
|
+
if (hDeath.mm == CHESHVAN && hDeath.dd == 30 && !HDate.longCheshvan(hyear)) {
|
|
1719
|
+
hDeath.mm = KISLEV;
|
|
1720
|
+
hDeath.dd = 1;
|
|
1721
|
+
} else if (hDeath.mm == KISLEV && hDeath.dd == 30 && HDate.shortKislev(hyear)) {
|
|
1722
|
+
hDeath.mm = TEVET;
|
|
1723
|
+
hDeath.dd = 1;
|
|
1724
|
+
}
|
|
1725
|
+
|
|
1726
|
+
return new HDate(hDeath.dd, hDeath.mm, hyear);
|
|
1727
|
+
}
|
|
1728
|
+
/**
|
|
1729
|
+
* @private
|
|
1730
|
+
* @param {number} hyear Hebrew year
|
|
1731
|
+
* @param {Date|HDate} gdate Gregorian or Hebrew date of event
|
|
1732
|
+
* @return {HDate} anniversary occurring in `hyear`
|
|
1733
|
+
*/
|
|
1734
|
+
|
|
1735
|
+
function getBirthdayOrAnniversary_(hyear, gdate) {
|
|
1736
|
+
const orig = HDate.isHDate(gdate) ? gdate : new HDate(gdate);
|
|
1737
|
+
const origYear = orig.getFullYear();
|
|
1738
|
+
|
|
1739
|
+
if (hyear <= origYear) {
|
|
1740
|
+
// `Hebrew year ${hyear} occurs on or before original date in ${origYear}`
|
|
1741
|
+
return undefined;
|
|
1742
|
+
}
|
|
1743
|
+
|
|
1744
|
+
const isOrigLeap = HDate.isLeapYear(origYear);
|
|
1745
|
+
let month = orig.getMonth();
|
|
1746
|
+
let day = orig.getDate();
|
|
1747
|
+
|
|
1748
|
+
if (month == ADAR_I && !isOrigLeap || month == ADAR_II && isOrigLeap) {
|
|
1749
|
+
month = HDate.monthsInYear(hyear);
|
|
1750
|
+
} else if (month == CHESHVAN && day == 30 && !HDate.longCheshvan(hyear)) {
|
|
1751
|
+
month = KISLEV;
|
|
1752
|
+
day = 1;
|
|
1753
|
+
} else if (month == KISLEV && day == 30 && HDate.shortKislev(hyear)) {
|
|
1754
|
+
month = TEVET;
|
|
1755
|
+
day = 1;
|
|
1756
|
+
} else if (month == ADAR_I && day == 30 && isOrigLeap && !HDate.isLeapYear(hyear)) {
|
|
1757
|
+
month = NISAN;
|
|
1758
|
+
day = 1;
|
|
1759
|
+
}
|
|
1760
|
+
|
|
1761
|
+
return new HDate(day, month, hyear);
|
|
1762
|
+
}
|
|
1763
|
+
|
|
1764
|
+
var version="3.33.5";
|
|
1657
1765
|
|
|
1658
1766
|
var headers={"plural-forms":"nplurals=2; plural=(n > 1);",language:"he"};var contexts={"":{Adar:["אַדָר"],"Adar I":["אַדָר א׳"],"Adar II":["אַדָר ב׳"],Av:["אָב"],Cheshvan:["חֶשְׁוָן"],Elul:["אֱלוּל"],Iyyar:["אִיָיר"],Kislev:["כִּסְלֵו"],Nisan:["נִיסָן"],"Sh'vat":["שְׁבָט"],Sivan:["סִיוָן"],Tamuz:["תַּמּוּז"],Tevet:["טֵבֵת"],Tishrei:["תִשְׁרֵי"]}};var poHeMin = {headers:headers,contexts:contexts};
|
|
1659
1767
|
|
|
@@ -1663,6 +1771,8 @@ Locale.addLocale('h', poHeMin);
|
|
|
1663
1771
|
exports.HDate = HDate;
|
|
1664
1772
|
exports.Locale = Locale;
|
|
1665
1773
|
exports.gematriya = gematriya;
|
|
1774
|
+
exports.getBirthdayOrAnniversary = getBirthdayOrAnniversary_;
|
|
1775
|
+
exports.getYahrzeit = getYahrzeit_;
|
|
1666
1776
|
exports.greg = greg;
|
|
1667
1777
|
exports.months = months;
|
|
1668
1778
|
exports.version = version;
|