@hebcal/core 4.2.0 → 4.3.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 +19 -0
- package/dist/bundle.js +33 -2
- package/dist/bundle.min.js +2 -2
- package/dist/greg0.mjs +1 -1
- package/dist/hdate-bundle.js +54 -2
- package/dist/hdate-bundle.min.js +2 -2
- package/dist/hdate.js +51 -2
- package/dist/hdate.mjs +51 -2
- package/dist/hdate0-bundle.js +1 -1
- package/dist/hdate0-bundle.min.js +1 -1
- package/dist/hdate0.mjs +1 -1
- package/dist/index.js +30 -2
- package/dist/index.mjs +30 -2
- package/hebcal.d.ts +10 -1
- package/package.json +1 -1
package/dist/greg0.mjs
CHANGED
package/dist/hdate-bundle.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! @hebcal/core v4.
|
|
1
|
+
/*! @hebcal/core v4.3.0 */
|
|
2
2
|
var hebcal = (function (exports) {
|
|
3
3
|
'use strict';
|
|
4
4
|
|
|
@@ -101,6 +101,33 @@ function gematriya(number) {
|
|
|
101
101
|
return str;
|
|
102
102
|
}
|
|
103
103
|
|
|
104
|
+
/**
|
|
105
|
+
* Converts a string of Hebrew letters to a numerical value.
|
|
106
|
+
*
|
|
107
|
+
* Only considers the value of Hebrew letters `א` through `ת`.
|
|
108
|
+
* Ignores final Hebrew letters such as `ך` (kaf sofit) or `ם` (mem sofit)
|
|
109
|
+
* and vowels (nekudot).
|
|
110
|
+
*
|
|
111
|
+
* @param {string} str
|
|
112
|
+
* @return {number}
|
|
113
|
+
*/
|
|
114
|
+
function gematriyaStrToNum(str) {
|
|
115
|
+
var num = 0;
|
|
116
|
+
var gereshIdx = str.indexOf(GERESH);
|
|
117
|
+
if (gereshIdx !== -1 && gereshIdx !== str.length - 1) {
|
|
118
|
+
var thousands = str.substring(0, gereshIdx);
|
|
119
|
+
num += gematriyaStrToNum(thousands) * 1000;
|
|
120
|
+
str = str.substring(gereshIdx);
|
|
121
|
+
}
|
|
122
|
+
for (var i = 0; i < str.length; i++) {
|
|
123
|
+
var n = heb2num[str[i]];
|
|
124
|
+
if (typeof n === 'number') {
|
|
125
|
+
num += n;
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
return num;
|
|
129
|
+
}
|
|
130
|
+
|
|
104
131
|
function _typeof(obj) {
|
|
105
132
|
"@babel/helpers - typeof";
|
|
106
133
|
|
|
@@ -1637,6 +1664,7 @@ var HDate = /*#__PURE__*/function () {
|
|
|
1637
1664
|
return monthName;
|
|
1638
1665
|
}
|
|
1639
1666
|
var c = Locale.hebrewStripNikkud(monthName).trim().toLowerCase();
|
|
1667
|
+
// If Hebrew month starts with a bet (for example `בתמוז`) then ignore it
|
|
1640
1668
|
if (c[0] === 'ב') {
|
|
1641
1669
|
c = c.substring(1);
|
|
1642
1670
|
}
|
|
@@ -1768,6 +1796,30 @@ var HDate = /*#__PURE__*/function () {
|
|
|
1768
1796
|
value: function isHDate(obj) {
|
|
1769
1797
|
return obj !== null && _typeof(obj) === 'object' && typeof obj.year === 'number' && typeof obj.month === 'number' && typeof obj.day === 'number' && typeof obj.greg === 'function' && typeof obj.abs === 'function';
|
|
1770
1798
|
}
|
|
1799
|
+
|
|
1800
|
+
/**
|
|
1801
|
+
* Construct a new instance of `HDate` from a Gematriya-formatted string
|
|
1802
|
+
* @example
|
|
1803
|
+
* HDate.fromGematriyaString('כ״ז בְּתַמּוּז תשפ״ג') // 27 Tamuz 5783
|
|
1804
|
+
* HDate.fromGematriyaString('כ׳ סיון תש״ד') // 20 Sivan 5704
|
|
1805
|
+
* HDate.fromGematriyaString('ה׳ אִיָיר תש״ח') // 5 Iyyar 5708
|
|
1806
|
+
* @param {string} str
|
|
1807
|
+
* @param {number} currentThousands
|
|
1808
|
+
* @return {HDate}
|
|
1809
|
+
*/
|
|
1810
|
+
}, {
|
|
1811
|
+
key: "fromGematriyaString",
|
|
1812
|
+
value: function fromGematriyaString(str) {
|
|
1813
|
+
var currentThousands = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 5000;
|
|
1814
|
+
var parts = str.split(' ');
|
|
1815
|
+
var day = gematriyaStrToNum(parts[0]);
|
|
1816
|
+
var month = HDate.monthFromName(parts[1]);
|
|
1817
|
+
var year = gematriyaStrToNum(parts[2]);
|
|
1818
|
+
if (year < 1000) {
|
|
1819
|
+
year += currentThousands;
|
|
1820
|
+
}
|
|
1821
|
+
return new HDate(day, month, year);
|
|
1822
|
+
}
|
|
1771
1823
|
}]);
|
|
1772
1824
|
return HDate;
|
|
1773
1825
|
}();
|
|
@@ -1924,7 +1976,7 @@ function getBirthdayOrAnniversary_(hyear, gdate) {
|
|
|
1924
1976
|
return new HDate(day, month, hyear);
|
|
1925
1977
|
}
|
|
1926
1978
|
|
|
1927
|
-
var version="4.
|
|
1979
|
+
var version="4.3.0";
|
|
1928
1980
|
|
|
1929
1981
|
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};
|
|
1930
1982
|
|
package/dist/hdate-bundle.min.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
/*! @hebcal/core v4.
|
|
2
|
-
var hebcal=function(e){"use strict";var t={"א":1,"ב":2,"ג":3,"ד":4,"ה":5,"ו":6,"ז":7,"ח":8,"ט":9,"י":10,"כ":20,"ל":30,"מ":40,"נ":50,"ס":60,"ע":70,"פ":80,"צ":90,"ק":100,"ר":200,"ש":300,"ת":400},r={};function n(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 a(e){var t=parseInt(e,10);if(!t)throw new TypeError("invalid parameter to gematriya ".concat(e));var a="",o=Math.floor(t/1e3);if(o>0&&5!==o){for(var i=n(o),u=0;u<i.length;u++)a+=r[i[u]];a+="׳"}var c=n(t%1e3);if(1==c.length)return a+r[c[0]]+"׳";for(var s=0;s<c.length;s++)s+1===c.length&&(a+="״"),a+=r[c[s]];return a}function o(e){return o="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},o(e)}function i(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 c(e,t,r){return t&&u(e.prototype,t),r&&u(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}Object.keys(t).forEach((function(e){r[t[e]]=e}));var s=[0,31,28,31,30,31,30,31,31,30,31,30,31],h=[s,s.slice()];function l(e,t){return e-t*Math.floor(e/t)}function f(e,t){return Math.floor(e/t)}function y(e){return!(e%4||!(e%100)&&e%400)}function v(e){return"object"===o(e)&&Date.prototype===e.__proto__}function d(e){if(!v(e))throw new TypeError("Argument not a Date: ".concat(e));return m(e.getFullYear(),e.getMonth()+1,e.getDate())}function m(e,t,r){var n=e-1;return 365*n+f(n,4)-f(n,100)+f(n,400)+f(367*t-362,12)+(t<=2?0:y(e)?-1:-2)+r}function g(e){if("number"!=typeof e)throw new TypeError("Argument not a Number: ".concat(e));var t=function(e){var t=e-1,r=f(t,146097),n=l(t,146097),a=f(n,36524),o=l(n,36524),i=f(o,1461),u=f(l(o,1461),365),c=400*r+100*a+4*i+u;return 4!=a&&4!=u?c+1:c}(e=Math.trunc(e)),r=f(12*(e-m(t,1,1)+(e<m(t,3,1)?0:y(t)?1:2))+373,367),n=e-m(t,r,1)+1,a=new Date(t,r-1,n);return t<100&&t>=0&&a.setFullYear(t),a}h[1][2]=29;var w={monthNames:["","January","February","March","April","May","June","July","August","September","October","November","December"],isLeapYear:y,daysInMonth:function(e,t){return h[+y(t)][e]},isDate:v,dayOfYear:function(e){if(!v(e))throw new TypeError("Argument not a Date: ".concat(e));var t=e.getMonth(),r=e.getDate()+31*t;return t>1&&(r-=Math.floor((4*(t+1)+23)/10),y(e.getFullYear())&&r++),r},greg2abs:d,abs2greg:g},b={headers:{"plural-forms":"nplurals=2; plural=(n!=1);"},contexts:{"":{}}},p={h:"he",a:"ashkenazi",s:"en","":"en"},k=Object.create(null),I=null,A=null,E=function(){function e(){i(this,e)}return c(e,null,[{key:"lookupTranslation",value:function(e,t){var r=t&&t.toLowerCase(),n=("string"==typeof t&&k[r]||I)[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("string"!=typeof e)throw new TypeError("Invalid locale name: ".concat(e));if("object"!==o(t.contexts)||"object"!==o(t.contexts[""]))throw new TypeError("Locale '".concat(e,"' invalid compact format"));k[e.toLowerCase()]=t.contexts[""]}},{key:"addTranslation",value:function(e,t,r){if("string"!=typeof e)throw new TypeError("Invalid locale name: ".concat(e));var n=e.toLowerCase(),a=k[n];if(!a)throw new TypeError("Unknown locale: ".concat(e));if("string"!=typeof t||0===t.length)throw new TypeError("Invalid id: ".concat(t));var o=Array.isArray(r);if(o){var i=r[0];if("string"!=typeof i||0===i.length)throw new TypeError("Invalid translation array: ".concat(r))}else if("string"!=typeof r)throw new TypeError("Invalid translation: ".concat(r));a[t]=o?r:[r]}},{key:"addTranslations",value:function(e,t){if("string"!=typeof e)throw new TypeError("Invalid locale name: ".concat(e));var r=e.toLowerCase(),n=k[r];if(!n)throw new TypeError("Unknown locale: ".concat(e));if("object"!==o(t.contexts)||"object"!==o(t.contexts[""]))throw new TypeError("Locale '".concat(e,"' invalid compact format"));var a=t.contexts[""];Object.keys(a).forEach((function(e){n[e]=a[e]}))}},{key:"useLocale",value:function(e){var t=e.toLowerCase(),r=k[t];if(!r)throw new RangeError("Locale '".concat(e,"' not found"));return A=p[t]||t,I=r}},{key:"getLocaleName",value:function(){return A}},{key:"getLocaleNames",value:function(){return Object.keys(k).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}();E.addLocale("en",b),E.addLocale("s",b),E.addLocale("",b),E.useLocale("en");var T=1,N=2,D=4,M=6,S=7,L=8,Y=9,H=10,O=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},x=["","Nisan","Iyyar","Sivan","Tamuz","Av","Elul","Tishrei","Cheshvan","Kislev","Tevet","Sh'vat"],C=[x.concat(["Adar","Nisan"]),x.concat(["Adar I","Adar II","Nisan"])],F=Object.create(null),j=-1373428,_=365.24682220597794;function z(e,t){if("number"!=typeof e||isNaN(e))throw new TypeError("invalid parameter '".concat(t,"' not a number: ").concat(e))}function U(e,t,r){if(z(e,"year"),z(t,"month"),z(r,"day"),e<1)throw new RangeError("hebrew2abs: invalid year ".concat(e));var n=r;if(t<S){for(var a=S;a<=J(e);a++)n+=Z(a,e);for(var o=T;o<t;o++)n+=Z(o,e)}else for(var i=S;i<t;i++)n+=Z(i,e);return j+q(e)+n-1}function K(e){return j+q(e)}function B(e){if(z(e,"abs"),(e=Math.trunc(e))<=j)throw new RangeError("abs2hebrew: ".concat(e," is before epoch"));for(var t=Math.floor((e-j)/_);K(t)<=e;)++t;for(var r=e<U(--t,1,1)?7:1;e>U(t,r,Z(r,t));)++r;return{yy:t,mm:r,dd:1+e-U(t,r,1)}}function P(e){return(1+7*e)%19<7}function J(e){return 12+P(e)}function Z(e,t){switch(e){case N:case D:case M:case H:case R:return 29}return e===O&&!P(t)||e===L&&!Q(t)||e===Y&&W(t)?29:30}function $(e,t){if(z(e,"month"),z(t,"year"),e<1||e>14)throw new TypeError("bad month argument ".concat(e));return C[+P(t)][e]}function q(e){var t=F[e]=F[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,i=1+29*r+Math.floor(a/24),u=i+(o>=19440||2==i%7&&o>=9924&&!P(e)||1==i%7&&o>=16789&&P(t));return u+(u%7==0||u%7==3||u%7==5)}(e);return t}function G(e){return q(e+1)-q(e)}function Q(e){return G(e)%10==5}function W(e){return G(e)%10==3}function X(e){throw new TypeError(e)}var ee="day",te="week",re="month",ne="year",ae={d:ee,w:te,M:re,y:ne},oe={day:ee,week:te,month:re,year:ne},ie=function(){function e(t,r,n){if(i(this,e),2==arguments.length||arguments.length>3)throw new TypeError("HDate constructor requires 0, 1 or 3 arguments");if(3==arguments.length){if(this.day=this.month=1,n=parseInt(n,10),isNaN(n))throw new TypeError("HDate called with bad year argument: ".concat(n));if(this.year=n,this.setMonth(r),t=parseInt(t,10),isNaN(t))throw new TypeError("HDate called with bad day argument: ".concat(t));this.setDate(t)}else{void 0===t&&(t=new Date);var a="number"!=typeof t||isNaN(t)?v(t)?d(t):e.isHDate(t)?{dd:t.day,mm:t.month,yy:t.year}:X("HDate called with bad argument: ".concat(t)):t,o="number"==typeof a,u=o?B(a):a;this.day=u.dd,this.month=u.mm,this.year=u.yy,o&&(this.abs0=a)}}return c(e,[{key:"getFullYear",value:function(){return this.year}},{key:"isLeapYear",value:function(){return P(this.year)}},{key:"getMonth",value:function(){return this.month}},{key:"getTishreiMonth",value:function(){var e=J(this.getFullYear());return(this.getMonth()+e-6)%e||e}},{key:"daysInMonth",value:function(){return Z(this.getMonth(),this.getFullYear())}},{key:"getDate",value:function(){return this.day}},{key:"getDay",value:function(){return l(this.abs(),7)}},{key:"setFullYear",value:function(e){return this.year=e,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 g(this.abs())}},{key:"abs",value:function(){return"number"!=typeof this.abs0&&(this.abs0=U(this.year,this.month,this.day)),this.abs0}},{key:"getMonthName",value:function(){return $(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)||E.getLocaleName(),n=this.getDate(),a=E.gettext(this.getMonthName(),r),o=E.ordinal(n,r),i=e.getDayOfTranslation(r),u="".concat(o).concat(i," ").concat(a);if(t){var c=this.getFullYear();return"".concat(u,", ").concat(c)}return u}},{key:"renderGematriya",value:function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0],t=this.getDate(),r=e?"he-x-NoNikud":"he",n=E.gettext(this.getMonthName(),r),o=this.getFullYear();return a(t)+" "+n+" "+a(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))===ee)return new e(this.abs()+t);if(r===te)return new e(this.abs()+7*t);if(r===ne)return new e(this.getDate(),this.getMonth(),this.getFullYear()+t);if(r===re){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 U(e,t,r)}},{key:"abs2hebrew",value:function(e){return B(e)}},{key:"getDayOfTranslation",value:function(e){switch(e){case"en":case"s":case"a":case"ashkenazi":return" of"}var t=E.lookupTranslation("of",e);return t?" "+t:"ashkenazi"===e.substring(0,9)?" of":""}},{key:"standardizeUnits",value:function(e){var t=ae[e]||String(e||"").toLowerCase().replace(/s$/,"");return oe[t]||X("Invalid units '".concat(e,"'"))}},{key:"isLeapYear",value:function(e){return P(e)}},{key:"monthsInYear",value:function(e){return J(e)}},{key:"daysInMonth",value:function(e,t){return Z(e,t)}},{key:"getMonthName",value:function(e,t){return $(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 G(e)}},{key:"longCheshvan",value:function(e){return Q(e)}},{key:"shortKislev",value:function(e){return W(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.hebrewStripNikkud(e).trim().toLowerCase();switch("ב"===t[0]&&(t=t.substring(1)),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"===o(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){ce(e),function(e){e.day<1&&(e.month==V.TISHREI&&(e.year-=1),e.day+=Z(e.month,e.year),e.month-=1,ue(e));e.day>Z(e.month,e.year)&&(e.month===V.ELUL&&(e.year+=1),e.day-=Z(e.month,e.year),e.month+=1,ue(e));ce(e)}(e)}function ce(e){e.month!==V.ADAR_II||e.isLeapYear()?e.month<1?(e.month+=J(e.year),e.year-=1,ue(e)):e.month>J(e.year)&&(e.month-=J(e.year),e.year+=1,ue(e)):(e.month-=1,ue(e)),delete e.abs0}function se(e,t,r){return new ie(ie.dayOnOrBefore(e,t.abs()+r))}var he=V.NISAN,le=V.CHESHVAN,fe=V.KISLEV,ye=V.TEVET,ve=V.SHVAT,de=V.ADAR_I,me=V.ADAR_II;var ge={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:["תִשְׁרֵי"]}}};E.addLocale("he",ge),E.addLocale("h",ge);var we=ge.contexts[""],be={};return Object.keys(we).forEach((function(e){be[e]=[E.hebrewStripNikkud(we[e][0])]})),E.addLocale("he-x-NoNikud",{headers:ge.headers,contexts:{"":be}}),e.HDate=ie,e.Locale=E,e.gematriya=a,e.getBirthdayOrAnniversary=function(e,t){var r=ie.isHDate(t)?t:new ie(t),n=r.getFullYear();if(e===n)return r;if(!(e<n)){var a=P(n),o=r.getMonth(),i=r.getDate();return o==de&&!a||o==me&&a?o=J(e):o!=le||30!=i||Q(e)?o==fe&&30==i&&W(e)?(o=ye,i=1):o==de&&30==i&&a&&!P(e)&&(o=he,i=1):(o=fe,i=1),new ie(i,o,e)}},e.getYahrzeit=function(e,t){var r=ie.isHDate(t)?t:new ie(t),n={yy:r.getFullYear(),mm:r.getMonth(),dd:r.getDate()};if(!(e<=n.yy))return n.mm!=le||30!=n.dd||Q(n.yy+1)?n.mm==fe&&30==n.dd&&W(n.yy+1)?n=B(U(e,ye,1)-1):n.mm==me?n.mm=J(e):n.mm!=de||30!=n.dd||P(e)||(n.dd=30,n.mm=ve):n=B(U(e,fe,1)-1),n.mm!=le||30!=n.dd||Q(e)?n.mm==fe&&30==n.dd&&W(e)&&(n.mm=ye,n.dd=1):(n.mm=fe,n.dd=1),new ie(n.dd,n.mm,e)},e.greg=w,e.months=V,e.version="4.2.0",e}({});
|
|
1
|
+
/*! @hebcal/core v4.3.0 */
|
|
2
|
+
var hebcal=function(e){"use strict";var t={"א":1,"ב":2,"ג":3,"ד":4,"ה":5,"ו":6,"ז":7,"ח":8,"ט":9,"י":10,"כ":20,"ל":30,"מ":40,"נ":50,"ס":60,"ע":70,"פ":80,"צ":90,"ק":100,"ר":200,"ש":300,"ת":400},r={};function n(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 a(e){var t=parseInt(e,10);if(!t)throw new TypeError("invalid parameter to gematriya ".concat(e));var a="",o=Math.floor(t/1e3);if(o>0&&5!==o){for(var i=n(o),u=0;u<i.length;u++)a+=r[i[u]];a+="׳"}var c=n(t%1e3);if(1==c.length)return a+r[c[0]]+"׳";for(var s=0;s<c.length;s++)s+1===c.length&&(a+="״"),a+=r[c[s]];return a}function o(e){var r=0,n=e.indexOf("׳");-1!==n&&n!==e.length-1&&(r+=1e3*o(e.substring(0,n)),e=e.substring(n));for(var a=0;a<e.length;a++){var i=t[e[a]];"number"==typeof i&&(r+=i)}return r}function i(e){return i="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},i(e)}function u(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function c(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 s(e,t,r){return t&&c(e.prototype,t),r&&c(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}Object.keys(t).forEach((function(e){r[t[e]]=e}));var h=[0,31,28,31,30,31,30,31,31,30,31,30,31],l=[h,h.slice()];function f(e,t){return e-t*Math.floor(e/t)}function y(e,t){return Math.floor(e/t)}function v(e){return!(e%4||!(e%100)&&e%400)}function d(e){return"object"===i(e)&&Date.prototype===e.__proto__}function m(e){if(!d(e))throw new TypeError("Argument not a Date: ".concat(e));return g(e.getFullYear(),e.getMonth()+1,e.getDate())}function g(e,t,r){var n=e-1;return 365*n+y(n,4)-y(n,100)+y(n,400)+y(367*t-362,12)+(t<=2?0:v(e)?-1:-2)+r}function w(e){if("number"!=typeof e)throw new TypeError("Argument not a Number: ".concat(e));var t=function(e){var t=e-1,r=y(t,146097),n=f(t,146097),a=y(n,36524),o=f(n,36524),i=y(o,1461),u=y(f(o,1461),365),c=400*r+100*a+4*i+u;return 4!=a&&4!=u?c+1:c}(e=Math.trunc(e)),r=y(12*(e-g(t,1,1)+(e<g(t,3,1)?0:v(t)?1:2))+373,367),n=e-g(t,r,1)+1,a=new Date(t,r-1,n);return t<100&&t>=0&&a.setFullYear(t),a}l[1][2]=29;var b={monthNames:["","January","February","March","April","May","June","July","August","September","October","November","December"],isLeapYear:v,daysInMonth:function(e,t){return l[+v(t)][e]},isDate:d,dayOfYear:function(e){if(!d(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),v(e.getFullYear())&&r++),r},greg2abs:m,abs2greg:w},p={headers:{"plural-forms":"nplurals=2; plural=(n!=1);"},contexts:{"":{}}},k={h:"he",a:"ashkenazi",s:"en","":"en"},I=Object.create(null),A=null,E=null,T=function(){function e(){u(this,e)}return s(e,null,[{key:"lookupTranslation",value:function(e,t){var r=t&&t.toLowerCase(),n=("string"==typeof t&&I[r]||A)[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("string"!=typeof e)throw new TypeError("Invalid locale name: ".concat(e));if("object"!==i(t.contexts)||"object"!==i(t.contexts[""]))throw new TypeError("Locale '".concat(e,"' invalid compact format"));I[e.toLowerCase()]=t.contexts[""]}},{key:"addTranslation",value:function(e,t,r){if("string"!=typeof e)throw new TypeError("Invalid locale name: ".concat(e));var n=e.toLowerCase(),a=I[n];if(!a)throw new TypeError("Unknown locale: ".concat(e));if("string"!=typeof t||0===t.length)throw new TypeError("Invalid id: ".concat(t));var o=Array.isArray(r);if(o){var i=r[0];if("string"!=typeof i||0===i.length)throw new TypeError("Invalid translation array: ".concat(r))}else if("string"!=typeof r)throw new TypeError("Invalid translation: ".concat(r));a[t]=o?r:[r]}},{key:"addTranslations",value:function(e,t){if("string"!=typeof e)throw new TypeError("Invalid locale name: ".concat(e));var r=e.toLowerCase(),n=I[r];if(!n)throw new TypeError("Unknown locale: ".concat(e));if("object"!==i(t.contexts)||"object"!==i(t.contexts[""]))throw new TypeError("Locale '".concat(e,"' invalid compact format"));var a=t.contexts[""];Object.keys(a).forEach((function(e){n[e]=a[e]}))}},{key:"useLocale",value:function(e){var t=e.toLowerCase(),r=I[t];if(!r)throw new RangeError("Locale '".concat(e,"' not found"));return E=k[t]||t,A=r}},{key:"getLocaleName",value:function(){return E}},{key:"getLocaleNames",value:function(){return Object.keys(I).sort()}},{key:"ordinal",value:function(e,t){var r=t&&t.toLowerCase()||E;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}();T.addLocale("en",p),T.addLocale("s",p),T.addLocale("",p),T.useLocale("en");var N=1,D=2,S=4,M=6,L=7,Y=8,H=9,O=10,R=12,V=13,x={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},F=["","Nisan","Iyyar","Sivan","Tamuz","Av","Elul","Tishrei","Cheshvan","Kislev","Tevet","Sh'vat"],C=[F.concat(["Adar","Nisan"]),F.concat(["Adar I","Adar II","Nisan"])],j=Object.create(null),_=-1373428,z=365.24682220597794;function U(e,t){if("number"!=typeof e||isNaN(e))throw new TypeError("invalid parameter '".concat(t,"' not a number: ").concat(e))}function K(e,t,r){if(U(e,"year"),U(t,"month"),U(r,"day"),e<1)throw new RangeError("hebrew2abs: invalid year ".concat(e));var n=r;if(t<L){for(var a=L;a<=Z(e);a++)n+=$(a,e);for(var o=N;o<t;o++)n+=$(o,e)}else for(var i=L;i<t;i++)n+=$(i,e);return _+q(e)+n-1}function B(e){return _+q(e)}function P(e){if(U(e,"abs"),(e=Math.trunc(e))<=_)throw new RangeError("abs2hebrew: ".concat(e," is before epoch"));for(var t=Math.floor((e-_)/z);B(t)<=e;)++t;for(var r=e<K(--t,1,1)?7:1;e>K(t,r,$(r,t));)++r;return{yy:t,mm:r,dd:1+e-K(t,r,1)}}function J(e){return(1+7*e)%19<7}function Z(e){return 12+J(e)}function $(e,t){switch(e){case D:case S:case M:case O:case V:return 29}return e===R&&!J(t)||e===Y&&!W(t)||e===H&&X(t)?29:30}function G(e,t){if(U(e,"month"),U(t,"year"),e<1||e>14)throw new TypeError("bad month argument ".concat(e));return C[+J(t)][e]}function q(e){var t=j[e]=j[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,i=1+29*r+Math.floor(a/24),u=i+(o>=19440||2==i%7&&o>=9924&&!J(e)||1==i%7&&o>=16789&&J(t));return u+(u%7==0||u%7==3||u%7==5)}(e);return t}function Q(e){return q(e+1)-q(e)}function W(e){return Q(e)%10==5}function X(e){return Q(e)%10==3}function ee(e){throw new TypeError(e)}var te="day",re="week",ne="month",ae="year",oe={d:te,w:re,M:ne,y:ae},ie={day:te,week:re,month:ne,year:ae},ue=function(){function e(t,r,n){if(u(this,e),2==arguments.length||arguments.length>3)throw new TypeError("HDate constructor requires 0, 1 or 3 arguments");if(3==arguments.length){if(this.day=this.month=1,n=parseInt(n,10),isNaN(n))throw new TypeError("HDate called with bad year argument: ".concat(n));if(this.year=n,this.setMonth(r),t=parseInt(t,10),isNaN(t))throw new TypeError("HDate called with bad day argument: ".concat(t));this.setDate(t)}else{void 0===t&&(t=new Date);var a="number"!=typeof t||isNaN(t)?d(t)?m(t):e.isHDate(t)?{dd:t.day,mm:t.month,yy:t.year}:ee("HDate called with bad argument: ".concat(t)):t,o="number"==typeof a,i=o?P(a):a;this.day=i.dd,this.month=i.mm,this.year=i.yy,o&&(this.abs0=a)}}return s(e,[{key:"getFullYear",value:function(){return this.year}},{key:"isLeapYear",value:function(){return J(this.year)}},{key:"getMonth",value:function(){return this.month}},{key:"getTishreiMonth",value:function(){var e=Z(this.getFullYear());return(this.getMonth()+e-6)%e||e}},{key:"daysInMonth",value:function(){return $(this.getMonth(),this.getFullYear())}},{key:"getDate",value:function(){return this.day}},{key:"getDay",value:function(){return f(this.abs(),7)}},{key:"setFullYear",value:function(e){return this.year=e,ce(this),this}},{key:"setMonth",value:function(t){return this.month=e.monthNum(t),ce(this),this}},{key:"setDate",value:function(e){return this.day=e,ce(this),this}},{key:"greg",value:function(){return w(this.abs())}},{key:"abs",value:function(){return"number"!=typeof this.abs0&&(this.abs0=K(this.year,this.month,this.day)),this.abs0}},{key:"getMonthName",value:function(){return G(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)||T.getLocaleName(),n=this.getDate(),a=T.gettext(this.getMonthName(),r),o=T.ordinal(n,r),i=e.getDayOfTranslation(r),u="".concat(o).concat(i," ").concat(a);if(t){var c=this.getFullYear();return"".concat(u,", ").concat(c)}return u}},{key:"renderGematriya",value:function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0],t=this.getDate(),r=e?"he-x-NoNikud":"he",n=T.gettext(this.getMonthName(),r),o=this.getFullYear();return a(t)+" "+n+" "+a(o)}},{key:"before",value:function(e){return he(e,this,-1)}},{key:"onOrBefore",value:function(e){return he(e,this,0)}},{key:"nearest",value:function(e){return he(e,this,3)}},{key:"onOrAfter",value:function(e){return he(e,this,6)}},{key:"after",value:function(e){return he(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))===te)return new e(this.abs()+t);if(r===re)return new e(this.abs()+7*t);if(r===ae)return new e(this.getDate(),this.getMonth(),this.getFullYear()+t);if(r===ne){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 K(e,t,r)}},{key:"abs2hebrew",value:function(e){return P(e)}},{key:"getDayOfTranslation",value:function(e){switch(e){case"en":case"s":case"a":case"ashkenazi":return" of"}var t=T.lookupTranslation("of",e);return t?" "+t:"ashkenazi"===e.substring(0,9)?" of":""}},{key:"standardizeUnits",value:function(e){var t=oe[e]||String(e||"").toLowerCase().replace(/s$/,"");return ie[t]||ee("Invalid units '".concat(e,"'"))}},{key:"isLeapYear",value:function(e){return J(e)}},{key:"monthsInYear",value:function(e){return Z(e)}},{key:"daysInMonth",value:function(e,t){return $(e,t)}},{key:"getMonthName",value:function(e,t){return G(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 W(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=T.hebrewStripNikkud(e).trim().toLowerCase();switch("ב"===t[0]&&(t=t.substring(1)),t[0]){case"n":case"נ":if("o"==t[1])break;return x.NISAN;case"i":return x.IYYAR;case"e":return x.ELUL;case"c":case"ח":return x.CHESHVAN;case"k":case"כ":return x.KISLEV;case"s":switch(t[1]){case"i":return x.SIVAN;case"h":return x.SHVAT}case"t":switch(t[1]){case"a":return x.TAMUZ;case"i":return x.TISHREI;case"e":return x.TEVET}break;case"a":switch(t[1]){case"v":return x.AV;case"d":return/(1|[^i]i|a|א)$/i.test(e)?x.ADAR_I:x.ADAR_II}break;case"ס":return x.SIVAN;case"ט":return x.TEVET;case"ש":return x.SHVAT;case"א":switch(t[1]){case"ב":return x.AV;case"ד":return/(1|[^i]i|a|א)$/i.test(e)?x.ADAR_I:x.ADAR_II;case"י":return x.IYYAR;case"ל":return x.ELUL}break;case"ת":switch(t[1]){case"מ":return x.TAMUZ;case"ש":return x.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"===i(e)&&"number"==typeof e.year&&"number"==typeof e.month&&"number"==typeof e.day&&"function"==typeof e.greg&&"function"==typeof e.abs}},{key:"fromGematriyaString",value:function(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:5e3,n=t.split(" "),a=o(n[0]),i=e.monthFromName(n[1]),u=o(n[2]);return u<1e3&&(u+=r),new e(a,i,u)}}]),e}();function ce(e){se(e),function(e){e.day<1&&(e.month==x.TISHREI&&(e.year-=1),e.day+=$(e.month,e.year),e.month-=1,ce(e));e.day>$(e.month,e.year)&&(e.month===x.ELUL&&(e.year+=1),e.day-=$(e.month,e.year),e.month+=1,ce(e));se(e)}(e)}function se(e){e.month!==x.ADAR_II||e.isLeapYear()?e.month<1?(e.month+=Z(e.year),e.year-=1,ce(e)):e.month>Z(e.year)&&(e.month-=Z(e.year),e.year+=1,ce(e)):(e.month-=1,ce(e)),delete e.abs0}function he(e,t,r){return new ue(ue.dayOnOrBefore(e,t.abs()+r))}var le=x.NISAN,fe=x.CHESHVAN,ye=x.KISLEV,ve=x.TEVET,de=x.SHVAT,me=x.ADAR_I,ge=x.ADAR_II;var we={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:["תִשְׁרֵי"]}}};T.addLocale("he",we),T.addLocale("h",we);var be=we.contexts[""],pe={};return Object.keys(be).forEach((function(e){pe[e]=[T.hebrewStripNikkud(be[e][0])]})),T.addLocale("he-x-NoNikud",{headers:we.headers,contexts:{"":pe}}),e.HDate=ue,e.Locale=T,e.gematriya=a,e.getBirthdayOrAnniversary=function(e,t){var r=ue.isHDate(t)?t:new ue(t),n=r.getFullYear();if(e===n)return r;if(!(e<n)){var a=J(n),o=r.getMonth(),i=r.getDate();return o==me&&!a||o==ge&&a?o=Z(e):o!=fe||30!=i||W(e)?o==ye&&30==i&&X(e)?(o=ve,i=1):o==me&&30==i&&a&&!J(e)&&(o=le,i=1):(o=ye,i=1),new ue(i,o,e)}},e.getYahrzeit=function(e,t){var r=ue.isHDate(t)?t:new ue(t),n={yy:r.getFullYear(),mm:r.getMonth(),dd:r.getDate()};if(!(e<=n.yy))return n.mm!=fe||30!=n.dd||W(n.yy+1)?n.mm==ye&&30==n.dd&&X(n.yy+1)?n=P(K(e,ve,1)-1):n.mm==ge?n.mm=Z(e):n.mm!=me||30!=n.dd||J(e)||(n.dd=30,n.mm=de):n=P(K(e,ye,1)-1),n.mm!=fe||30!=n.dd||W(e)?n.mm==ye&&30==n.dd&&X(e)&&(n.mm=ve,n.dd=1):(n.mm=ye,n.dd=1),new ue(n.dd,n.mm,e)},e.greg=b,e.months=x,e.version="4.3.0",e}({});
|
package/dist/hdate.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! @hebcal/core v4.
|
|
1
|
+
/*! @hebcal/core v4.3.0 */
|
|
2
2
|
'use strict';
|
|
3
3
|
|
|
4
4
|
const GERESH = '׳';
|
|
@@ -100,6 +100,33 @@ function gematriya(number) {
|
|
|
100
100
|
return str;
|
|
101
101
|
}
|
|
102
102
|
|
|
103
|
+
/**
|
|
104
|
+
* Converts a string of Hebrew letters to a numerical value.
|
|
105
|
+
*
|
|
106
|
+
* Only considers the value of Hebrew letters `א` through `ת`.
|
|
107
|
+
* Ignores final Hebrew letters such as `ך` (kaf sofit) or `ם` (mem sofit)
|
|
108
|
+
* and vowels (nekudot).
|
|
109
|
+
*
|
|
110
|
+
* @param {string} str
|
|
111
|
+
* @return {number}
|
|
112
|
+
*/
|
|
113
|
+
function gematriyaStrToNum(str) {
|
|
114
|
+
let num = 0;
|
|
115
|
+
const gereshIdx = str.indexOf(GERESH);
|
|
116
|
+
if (gereshIdx !== -1 && gereshIdx !== str.length - 1) {
|
|
117
|
+
const thousands = str.substring(0, gereshIdx);
|
|
118
|
+
num += gematriyaStrToNum(thousands) * 1000;
|
|
119
|
+
str = str.substring(gereshIdx);
|
|
120
|
+
}
|
|
121
|
+
for (let i = 0; i < str.length; i++) {
|
|
122
|
+
const n = heb2num[str[i]];
|
|
123
|
+
if (typeof n === 'number') {
|
|
124
|
+
num += n;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
return num;
|
|
128
|
+
}
|
|
129
|
+
|
|
103
130
|
/*
|
|
104
131
|
* More minimal greg routines
|
|
105
132
|
*/
|
|
@@ -1496,6 +1523,7 @@ class HDate {
|
|
|
1496
1523
|
return monthName;
|
|
1497
1524
|
}
|
|
1498
1525
|
let c = Locale.hebrewStripNikkud(monthName).trim().toLowerCase();
|
|
1526
|
+
// If Hebrew month starts with a bet (for example `בתמוז`) then ignore it
|
|
1499
1527
|
if (c[0] === 'ב') {
|
|
1500
1528
|
c = c.substring(1);
|
|
1501
1529
|
}
|
|
@@ -1623,6 +1651,27 @@ class HDate {
|
|
|
1623
1651
|
static isHDate(obj) {
|
|
1624
1652
|
return obj !== null && typeof obj === 'object' && typeof obj.year === 'number' && typeof obj.month === 'number' && typeof obj.day === 'number' && typeof obj.greg === 'function' && typeof obj.abs === 'function';
|
|
1625
1653
|
}
|
|
1654
|
+
|
|
1655
|
+
/**
|
|
1656
|
+
* Construct a new instance of `HDate` from a Gematriya-formatted string
|
|
1657
|
+
* @example
|
|
1658
|
+
* HDate.fromGematriyaString('כ״ז בְּתַמּוּז תשפ״ג') // 27 Tamuz 5783
|
|
1659
|
+
* HDate.fromGematriyaString('כ׳ סיון תש״ד') // 20 Sivan 5704
|
|
1660
|
+
* HDate.fromGematriyaString('ה׳ אִיָיר תש״ח') // 5 Iyyar 5708
|
|
1661
|
+
* @param {string} str
|
|
1662
|
+
* @param {number} currentThousands
|
|
1663
|
+
* @return {HDate}
|
|
1664
|
+
*/
|
|
1665
|
+
static fromGematriyaString(str, currentThousands = 5000) {
|
|
1666
|
+
const parts = str.split(' ');
|
|
1667
|
+
const day = gematriyaStrToNum(parts[0]);
|
|
1668
|
+
const month = HDate.monthFromName(parts[1]);
|
|
1669
|
+
let year = gematriyaStrToNum(parts[2]);
|
|
1670
|
+
if (year < 1000) {
|
|
1671
|
+
year += currentThousands;
|
|
1672
|
+
}
|
|
1673
|
+
return new HDate(day, month, year);
|
|
1674
|
+
}
|
|
1626
1675
|
}
|
|
1627
1676
|
|
|
1628
1677
|
/**
|
|
@@ -1777,7 +1826,7 @@ function getBirthdayOrAnniversary_(hyear, gdate) {
|
|
|
1777
1826
|
return new HDate(day, month, hyear);
|
|
1778
1827
|
}
|
|
1779
1828
|
|
|
1780
|
-
const version="4.
|
|
1829
|
+
const version="4.3.0";
|
|
1781
1830
|
|
|
1782
1831
|
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};
|
|
1783
1832
|
|
package/dist/hdate.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! @hebcal/core v4.
|
|
1
|
+
/*! @hebcal/core v4.3.0 */
|
|
2
2
|
const GERESH = '׳';
|
|
3
3
|
const GERSHAYIM = '״';
|
|
4
4
|
|
|
@@ -99,6 +99,33 @@ function gematriya(number) {
|
|
|
99
99
|
return str;
|
|
100
100
|
}
|
|
101
101
|
|
|
102
|
+
/**
|
|
103
|
+
* Converts a string of Hebrew letters to a numerical value.
|
|
104
|
+
*
|
|
105
|
+
* Only considers the value of Hebrew letters `א` through `ת`.
|
|
106
|
+
* Ignores final Hebrew letters such as `ך` (kaf sofit) or `ם` (mem sofit)
|
|
107
|
+
* and vowels (nekudot).
|
|
108
|
+
*
|
|
109
|
+
* @param {string} str
|
|
110
|
+
* @return {number}
|
|
111
|
+
*/
|
|
112
|
+
function gematriyaStrToNum(str) {
|
|
113
|
+
let num = 0;
|
|
114
|
+
const gereshIdx = str.indexOf(GERESH);
|
|
115
|
+
if (gereshIdx !== -1 && gereshIdx !== str.length - 1) {
|
|
116
|
+
const thousands = str.substring(0, gereshIdx);
|
|
117
|
+
num += gematriyaStrToNum(thousands) * 1000;
|
|
118
|
+
str = str.substring(gereshIdx);
|
|
119
|
+
}
|
|
120
|
+
for (let i = 0; i < str.length; i++) {
|
|
121
|
+
const n = heb2num[str[i]];
|
|
122
|
+
if (typeof n === 'number') {
|
|
123
|
+
num += n;
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
return num;
|
|
127
|
+
}
|
|
128
|
+
|
|
102
129
|
/*
|
|
103
130
|
* More minimal greg routines
|
|
104
131
|
*/
|
|
@@ -1552,6 +1579,7 @@ class HDate {
|
|
|
1552
1579
|
return monthName;
|
|
1553
1580
|
}
|
|
1554
1581
|
let c = Locale.hebrewStripNikkud(monthName).trim().toLowerCase();
|
|
1582
|
+
// If Hebrew month starts with a bet (for example `בתמוז`) then ignore it
|
|
1555
1583
|
if (c[0] === 'ב') {
|
|
1556
1584
|
c = c.substring(1);
|
|
1557
1585
|
}
|
|
@@ -1681,6 +1709,27 @@ class HDate {
|
|
|
1681
1709
|
typeof obj.greg === 'function' &&
|
|
1682
1710
|
typeof obj.abs === 'function';
|
|
1683
1711
|
}
|
|
1712
|
+
|
|
1713
|
+
/**
|
|
1714
|
+
* Construct a new instance of `HDate` from a Gematriya-formatted string
|
|
1715
|
+
* @example
|
|
1716
|
+
* HDate.fromGematriyaString('כ״ז בְּתַמּוּז תשפ״ג') // 27 Tamuz 5783
|
|
1717
|
+
* HDate.fromGematriyaString('כ׳ סיון תש״ד') // 20 Sivan 5704
|
|
1718
|
+
* HDate.fromGematriyaString('ה׳ אִיָיר תש״ח') // 5 Iyyar 5708
|
|
1719
|
+
* @param {string} str
|
|
1720
|
+
* @param {number} currentThousands
|
|
1721
|
+
* @return {HDate}
|
|
1722
|
+
*/
|
|
1723
|
+
static fromGematriyaString(str, currentThousands=5000) {
|
|
1724
|
+
const parts = str.split(' ');
|
|
1725
|
+
const day = gematriyaStrToNum(parts[0]);
|
|
1726
|
+
const month = HDate.monthFromName(parts[1]);
|
|
1727
|
+
let year = gematriyaStrToNum(parts[2]);
|
|
1728
|
+
if (year < 1000) {
|
|
1729
|
+
year += currentThousands;
|
|
1730
|
+
}
|
|
1731
|
+
return new HDate(day, month, year);
|
|
1732
|
+
}
|
|
1684
1733
|
}
|
|
1685
1734
|
|
|
1686
1735
|
/**
|
|
@@ -1839,7 +1888,7 @@ function getBirthdayOrAnniversary_(hyear, gdate) {
|
|
|
1839
1888
|
return new HDate(day, month, hyear);
|
|
1840
1889
|
}
|
|
1841
1890
|
|
|
1842
|
-
const version="4.
|
|
1891
|
+
const version="4.3.0";
|
|
1843
1892
|
|
|
1844
1893
|
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};
|
|
1845
1894
|
|
package/dist/hdate0-bundle.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
/*! @hebcal/core v4.
|
|
1
|
+
/*! @hebcal/core v4.3.0 */
|
|
2
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
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! @hebcal/core v4.
|
|
1
|
+
/*! @hebcal/core v4.3.0 */
|
|
2
2
|
'use strict';
|
|
3
3
|
|
|
4
4
|
/*
|
|
@@ -355,6 +355,12 @@ function gematriya(number) {
|
|
|
355
355
|
*/
|
|
356
356
|
function gematriyaStrToNum(str) {
|
|
357
357
|
let num = 0;
|
|
358
|
+
const gereshIdx = str.indexOf(GERESH);
|
|
359
|
+
if (gereshIdx !== -1 && gereshIdx !== str.length - 1) {
|
|
360
|
+
const thousands = str.substring(0, gereshIdx);
|
|
361
|
+
num += gematriyaStrToNum(thousands) * 1000;
|
|
362
|
+
str = str.substring(gereshIdx);
|
|
363
|
+
}
|
|
358
364
|
for (let i = 0; i < str.length; i++) {
|
|
359
365
|
const n = heb2num[str[i]];
|
|
360
366
|
if (typeof n === 'number') {
|
|
@@ -1517,6 +1523,7 @@ class HDate {
|
|
|
1517
1523
|
return monthName;
|
|
1518
1524
|
}
|
|
1519
1525
|
let c = Locale.hebrewStripNikkud(monthName).trim().toLowerCase();
|
|
1526
|
+
// If Hebrew month starts with a bet (for example `בתמוז`) then ignore it
|
|
1520
1527
|
if (c[0] === 'ב') {
|
|
1521
1528
|
c = c.substring(1);
|
|
1522
1529
|
}
|
|
@@ -1644,6 +1651,27 @@ class HDate {
|
|
|
1644
1651
|
static isHDate(obj) {
|
|
1645
1652
|
return obj !== null && typeof obj === 'object' && typeof obj.year === 'number' && typeof obj.month === 'number' && typeof obj.day === 'number' && typeof obj.greg === 'function' && typeof obj.abs === 'function';
|
|
1646
1653
|
}
|
|
1654
|
+
|
|
1655
|
+
/**
|
|
1656
|
+
* Construct a new instance of `HDate` from a Gematriya-formatted string
|
|
1657
|
+
* @example
|
|
1658
|
+
* HDate.fromGematriyaString('כ״ז בְּתַמּוּז תשפ״ג') // 27 Tamuz 5783
|
|
1659
|
+
* HDate.fromGematriyaString('כ׳ סיון תש״ד') // 20 Sivan 5704
|
|
1660
|
+
* HDate.fromGematriyaString('ה׳ אִיָיר תש״ח') // 5 Iyyar 5708
|
|
1661
|
+
* @param {string} str
|
|
1662
|
+
* @param {number} currentThousands
|
|
1663
|
+
* @return {HDate}
|
|
1664
|
+
*/
|
|
1665
|
+
static fromGematriyaString(str, currentThousands = 5000) {
|
|
1666
|
+
const parts = str.split(' ');
|
|
1667
|
+
const day = gematriyaStrToNum(parts[0]);
|
|
1668
|
+
const month = HDate.monthFromName(parts[1]);
|
|
1669
|
+
let year = gematriyaStrToNum(parts[2]);
|
|
1670
|
+
if (year < 1000) {
|
|
1671
|
+
year += currentThousands;
|
|
1672
|
+
}
|
|
1673
|
+
return new HDate(day, month, year);
|
|
1674
|
+
}
|
|
1647
1675
|
}
|
|
1648
1676
|
|
|
1649
1677
|
/**
|
|
@@ -5213,7 +5241,7 @@ function getBirthdayOrAnniversary_(hyear, gdate) {
|
|
|
5213
5241
|
return new HDate(day, month, hyear);
|
|
5214
5242
|
}
|
|
5215
5243
|
|
|
5216
|
-
var version="4.
|
|
5244
|
+
var version="4.3.0";
|
|
5217
5245
|
|
|
5218
5246
|
var headers$1={"plural-forms":"nplurals=2; plural=(n > 1);"};var contexts$1={"":{Shabbat:["Shabbos"],"Achrei Mot":["Achrei Mos"],Bechukotai:["Bechukosai"],"Beha'alotcha":["Beha'aloscha"],Bereshit:["Bereshis"],Chukat:["Chukas"],"Erev Shavuot":["Erev Shavuos"],"Erev Sukkot":["Erev Sukkos"],"Ki Tavo":["Ki Savo"],"Ki Teitzei":["Ki Seitzei"],"Ki Tisa":["Ki Sisa"],Matot:["Matos"],"Purim Katan":["Purim Koton"],Tazria:["Sazria"],"Shabbat Chazon":["Shabbos Chazon"],"Shabbat HaChodesh":["Shabbos HaChodesh"],"Shabbat HaGadol":["Shabbos HaGadol"],"Shabbat Nachamu":["Shabbos Nachamu"],"Shabbat Parah":["Shabbos Parah"],"Shabbat Shekalim":["Shabbos Shekalim"],"Shabbat Shuva":["Shabbos Shuvah"],"Shabbat Zachor":["Shabbos Zachor"],Shavuot:["Shavuos"],"Shavuot I":["Shavuos I"],"Shavuot II":["Shavuos II"],Shemot:["Shemos"],"Shmini Atzeret":["Shmini Atzeres"],"Simchat Torah":["Simchas Torah"],Sukkot:["Sukkos"],"Sukkot I":["Sukkos I"],"Sukkot II":["Sukkos II"],"Sukkot II (CH''M)":["Sukkos II (CH''M)"],"Sukkot III (CH''M)":["Sukkos III (CH''M)"],"Sukkot IV (CH''M)":["Sukkos IV (CH''M)"],"Sukkot V (CH''M)":["Sukkos V (CH''M)"],"Sukkot VI (CH''M)":["Sukkos VI (CH''M)"],"Sukkot VII (Hoshana Raba)":["Sukkos VII (Hoshana Raba)"],"Ta'anit Bechorot":["Ta'anis Bechoros"],"Ta'anit Esther":["Ta'anis Esther"],Toldot:["Toldos"],Vaetchanan:["Vaeschanan"],Yitro:["Yisro"],"Vezot Haberakhah":["Vezos Haberakhah"],Parashat:["Parshas"],"Leil Selichot":["Leil Selichos"],"Shabbat Mevarchim Chodesh":["Shabbos Mevorchim Chodesh"],"Shabbat Shirah":["Shabbos Shirah"],Tevet:["Teves"],"Asara B'Tevet":["Asara B'Teves"],"Alot HaShachar":["Alos HaShachar"],"Kriat Shema, sof zeman":["Krias Shema, sof zman"],"Tefilah, sof zeman":["Tefilah, sof zman"],"Kriat Shema, sof zeman (MGA)":["Krias Shema, sof zman (MGA)"],"Tefilah, sof zeman (MGA)":["Tefilah, sof zman (MGA)"],"Chatzot HaLailah":["Chatzos HaLailah"],"Chatzot hayom":["Chatzos"],"Tzeit HaKochavim":["Tzeis HaKochavim"],"Birkat Hachamah":["Birkas Hachamah"],"Shushan Purim Katan":["Shushan Purim Koton"]}};var poAshkenazi = {headers:headers$1,contexts:contexts$1};
|
|
5219
5247
|
|
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! @hebcal/core v4.
|
|
1
|
+
/*! @hebcal/core v4.3.0 */
|
|
2
2
|
/*
|
|
3
3
|
* More minimal greg routines
|
|
4
4
|
*/
|
|
@@ -353,6 +353,12 @@ function gematriya(number) {
|
|
|
353
353
|
*/
|
|
354
354
|
function gematriyaStrToNum(str) {
|
|
355
355
|
let num = 0;
|
|
356
|
+
const gereshIdx = str.indexOf(GERESH);
|
|
357
|
+
if (gereshIdx !== -1 && gereshIdx !== str.length - 1) {
|
|
358
|
+
const thousands = str.substring(0, gereshIdx);
|
|
359
|
+
num += gematriyaStrToNum(thousands) * 1000;
|
|
360
|
+
str = str.substring(gereshIdx);
|
|
361
|
+
}
|
|
356
362
|
for (let i = 0; i < str.length; i++) {
|
|
357
363
|
const n = heb2num[str[i]];
|
|
358
364
|
if (typeof n === 'number') {
|
|
@@ -1515,6 +1521,7 @@ class HDate {
|
|
|
1515
1521
|
return monthName;
|
|
1516
1522
|
}
|
|
1517
1523
|
let c = Locale.hebrewStripNikkud(monthName).trim().toLowerCase();
|
|
1524
|
+
// If Hebrew month starts with a bet (for example `בתמוז`) then ignore it
|
|
1518
1525
|
if (c[0] === 'ב') {
|
|
1519
1526
|
c = c.substring(1);
|
|
1520
1527
|
}
|
|
@@ -1642,6 +1649,27 @@ class HDate {
|
|
|
1642
1649
|
static isHDate(obj) {
|
|
1643
1650
|
return obj !== null && typeof obj === 'object' && typeof obj.year === 'number' && typeof obj.month === 'number' && typeof obj.day === 'number' && typeof obj.greg === 'function' && typeof obj.abs === 'function';
|
|
1644
1651
|
}
|
|
1652
|
+
|
|
1653
|
+
/**
|
|
1654
|
+
* Construct a new instance of `HDate` from a Gematriya-formatted string
|
|
1655
|
+
* @example
|
|
1656
|
+
* HDate.fromGematriyaString('כ״ז בְּתַמּוּז תשפ״ג') // 27 Tamuz 5783
|
|
1657
|
+
* HDate.fromGematriyaString('כ׳ סיון תש״ד') // 20 Sivan 5704
|
|
1658
|
+
* HDate.fromGematriyaString('ה׳ אִיָיר תש״ח') // 5 Iyyar 5708
|
|
1659
|
+
* @param {string} str
|
|
1660
|
+
* @param {number} currentThousands
|
|
1661
|
+
* @return {HDate}
|
|
1662
|
+
*/
|
|
1663
|
+
static fromGematriyaString(str, currentThousands = 5000) {
|
|
1664
|
+
const parts = str.split(' ');
|
|
1665
|
+
const day = gematriyaStrToNum(parts[0]);
|
|
1666
|
+
const month = HDate.monthFromName(parts[1]);
|
|
1667
|
+
let year = gematriyaStrToNum(parts[2]);
|
|
1668
|
+
if (year < 1000) {
|
|
1669
|
+
year += currentThousands;
|
|
1670
|
+
}
|
|
1671
|
+
return new HDate(day, month, year);
|
|
1672
|
+
}
|
|
1645
1673
|
}
|
|
1646
1674
|
|
|
1647
1675
|
/**
|
|
@@ -5211,7 +5239,7 @@ function getBirthdayOrAnniversary_(hyear, gdate) {
|
|
|
5211
5239
|
return new HDate(day, month, hyear);
|
|
5212
5240
|
}
|
|
5213
5241
|
|
|
5214
|
-
const version="4.
|
|
5242
|
+
const version="4.3.0";
|
|
5215
5243
|
|
|
5216
5244
|
const headers$1={"plural-forms":"nplurals=2; plural=(n > 1);"};const contexts$1={"":{Shabbat:["Shabbos"],"Achrei Mot":["Achrei Mos"],Bechukotai:["Bechukosai"],"Beha'alotcha":["Beha'aloscha"],Bereshit:["Bereshis"],Chukat:["Chukas"],"Erev Shavuot":["Erev Shavuos"],"Erev Sukkot":["Erev Sukkos"],"Ki Tavo":["Ki Savo"],"Ki Teitzei":["Ki Seitzei"],"Ki Tisa":["Ki Sisa"],Matot:["Matos"],"Purim Katan":["Purim Koton"],Tazria:["Sazria"],"Shabbat Chazon":["Shabbos Chazon"],"Shabbat HaChodesh":["Shabbos HaChodesh"],"Shabbat HaGadol":["Shabbos HaGadol"],"Shabbat Nachamu":["Shabbos Nachamu"],"Shabbat Parah":["Shabbos Parah"],"Shabbat Shekalim":["Shabbos Shekalim"],"Shabbat Shuva":["Shabbos Shuvah"],"Shabbat Zachor":["Shabbos Zachor"],Shavuot:["Shavuos"],"Shavuot I":["Shavuos I"],"Shavuot II":["Shavuos II"],Shemot:["Shemos"],"Shmini Atzeret":["Shmini Atzeres"],"Simchat Torah":["Simchas Torah"],Sukkot:["Sukkos"],"Sukkot I":["Sukkos I"],"Sukkot II":["Sukkos II"],"Sukkot II (CH''M)":["Sukkos II (CH''M)"],"Sukkot III (CH''M)":["Sukkos III (CH''M)"],"Sukkot IV (CH''M)":["Sukkos IV (CH''M)"],"Sukkot V (CH''M)":["Sukkos V (CH''M)"],"Sukkot VI (CH''M)":["Sukkos VI (CH''M)"],"Sukkot VII (Hoshana Raba)":["Sukkos VII (Hoshana Raba)"],"Ta'anit Bechorot":["Ta'anis Bechoros"],"Ta'anit Esther":["Ta'anis Esther"],Toldot:["Toldos"],Vaetchanan:["Vaeschanan"],Yitro:["Yisro"],"Vezot Haberakhah":["Vezos Haberakhah"],Parashat:["Parshas"],"Leil Selichot":["Leil Selichos"],"Shabbat Mevarchim Chodesh":["Shabbos Mevorchim Chodesh"],"Shabbat Shirah":["Shabbos Shirah"],Tevet:["Teves"],"Asara B'Tevet":["Asara B'Teves"],"Alot HaShachar":["Alos HaShachar"],"Kriat Shema, sof zeman":["Krias Shema, sof zman"],"Tefilah, sof zeman":["Tefilah, sof zman"],"Kriat Shema, sof zeman (MGA)":["Krias Shema, sof zman (MGA)"],"Tefilah, sof zeman (MGA)":["Tefilah, sof zman (MGA)"],"Chatzot HaLailah":["Chatzos HaLailah"],"Chatzot hayom":["Chatzos"],"Tzeit HaKochavim":["Tzeis HaKochavim"],"Birkat Hachamah":["Birkas Hachamah"],"Shushan Purim Katan":["Shushan Purim Koton"]}};var poAshkenazi = {headers:headers$1,contexts:contexts$1};
|
|
5217
5245
|
|
package/hebcal.d.ts
CHANGED
|
@@ -168,7 +168,7 @@ declare module '@hebcal/core' {
|
|
|
168
168
|
/**
|
|
169
169
|
* Tests if the object is an instance of `HDate`
|
|
170
170
|
*/
|
|
171
|
-
isHDate(obj: any): boolean;
|
|
171
|
+
static isHDate(obj: any): boolean;
|
|
172
172
|
|
|
173
173
|
/**
|
|
174
174
|
* Converts Hebrew date to R.D. (Rata Die) fixed days.
|
|
@@ -242,6 +242,15 @@ declare module '@hebcal/core' {
|
|
|
242
242
|
* @param c - monthName
|
|
243
243
|
*/
|
|
244
244
|
static monthFromName(c: string): number;
|
|
245
|
+
|
|
246
|
+
/**
|
|
247
|
+
* Construct a new instance of `HDate` from a Gematriya-formatted string
|
|
248
|
+
* @example
|
|
249
|
+
* HDate.fromGematriyaString('כ״ז בְּתַמּוּז תשפ״ג') // 27 Tamuz 5783
|
|
250
|
+
* HDate.fromGematriyaString('כ׳ סיון תש״ד') // 20 Sivan 5704
|
|
251
|
+
* HDate.fromGematriyaString('ה׳ אִיָיר תש״ח') // 5 Iyyar 5708
|
|
252
|
+
*/
|
|
253
|
+
static fromGematriyaString(str: string, currentThousands?: number): HDate;
|
|
245
254
|
}
|
|
246
255
|
|
|
247
256
|
/**
|