@hebcal/core 4.4.0 → 4.5.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 +59 -41
- package/dist/bundle.js +150 -106
- package/dist/bundle.min.js +2 -2
- package/dist/greg0.mjs +1 -1
- package/dist/hdate-bundle.js +11 -12
- package/dist/hdate-bundle.min.js +2 -2
- package/dist/hdate.js +11 -12
- package/dist/hdate.mjs +11 -10
- 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 +148 -104
- package/dist/index.mjs +148 -104
- package/hebcal.d.ts +29 -8
- package/package.json +11 -12
package/dist/hdate-bundle.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! @hebcal/core v4.
|
|
1
|
+
/*! @hebcal/core v4.5.0 */
|
|
2
2
|
var hebcal = (function (exports) {
|
|
3
3
|
'use strict';
|
|
4
4
|
|
|
@@ -83,8 +83,8 @@ function gematriya(number) {
|
|
|
83
83
|
const thousands = Math.floor(num / 1000);
|
|
84
84
|
if (thousands > 0 && thousands !== 5) {
|
|
85
85
|
const tdigits = num2digits(thousands);
|
|
86
|
-
for (
|
|
87
|
-
str += num2heb[
|
|
86
|
+
for (const tdig of tdigits) {
|
|
87
|
+
str += num2heb[tdig];
|
|
88
88
|
}
|
|
89
89
|
str += GERESH;
|
|
90
90
|
}
|
|
@@ -119,8 +119,8 @@ function gematriyaStrToNum(str) {
|
|
|
119
119
|
num += gematriyaStrToNum(thousands) * 1000;
|
|
120
120
|
str = str.substring(gereshIdx);
|
|
121
121
|
}
|
|
122
|
-
for (
|
|
123
|
-
const n = heb2num[
|
|
122
|
+
for (const ch of str) {
|
|
123
|
+
const n = heb2num[ch];
|
|
124
124
|
if (typeof n === 'number') {
|
|
125
125
|
num += n;
|
|
126
126
|
}
|
|
@@ -410,7 +410,7 @@ class Locale {
|
|
|
410
410
|
* @return {string}
|
|
411
411
|
*/
|
|
412
412
|
static lookupTranslation(id, locale) {
|
|
413
|
-
const locale0 = locale
|
|
413
|
+
const locale0 = locale === null || locale === void 0 ? void 0 : locale.toLowerCase();
|
|
414
414
|
const loc = typeof locale == 'string' && locales[locale0] || activeLocale;
|
|
415
415
|
const array = loc[id];
|
|
416
416
|
if (array && array.length && array[0].length) {
|
|
@@ -530,7 +530,7 @@ class Locale {
|
|
|
530
530
|
* @return {string[]}
|
|
531
531
|
*/
|
|
532
532
|
static getLocaleNames() {
|
|
533
|
-
return Object.keys(locales).sort();
|
|
533
|
+
return Object.keys(locales).sort((a, b) => a.localeCompare(b));
|
|
534
534
|
}
|
|
535
535
|
|
|
536
536
|
/**
|
|
@@ -539,7 +539,7 @@ class Locale {
|
|
|
539
539
|
* @return {string}
|
|
540
540
|
*/
|
|
541
541
|
static ordinal(n, locale) {
|
|
542
|
-
const locale1 = locale
|
|
542
|
+
const locale1 = locale === null || locale === void 0 ? void 0 : locale.toLowerCase();
|
|
543
543
|
const locale0 = locale1 || activeName;
|
|
544
544
|
if (!locale0) {
|
|
545
545
|
return this.getEnOrdinal(n);
|
|
@@ -1206,7 +1206,7 @@ class HDate {
|
|
|
1206
1206
|
if (ofStr) {
|
|
1207
1207
|
return ' ' + ofStr;
|
|
1208
1208
|
}
|
|
1209
|
-
if ('ashkenazi'
|
|
1209
|
+
if (locale.startsWith('ashkenazi')) {
|
|
1210
1210
|
return ' of';
|
|
1211
1211
|
}
|
|
1212
1212
|
return '';
|
|
@@ -1579,6 +1579,7 @@ class HDate {
|
|
|
1579
1579
|
case 'h':
|
|
1580
1580
|
return months.SHVAT;
|
|
1581
1581
|
}
|
|
1582
|
+
break;
|
|
1582
1583
|
case 't':
|
|
1583
1584
|
switch (c[1]) {
|
|
1584
1585
|
case 'a':
|
|
@@ -1598,9 +1599,7 @@ class HDate {
|
|
|
1598
1599
|
return months.ADAR_I;
|
|
1599
1600
|
}
|
|
1600
1601
|
return months.ADAR_II;
|
|
1601
|
-
// else assume sheini
|
|
1602
1602
|
}
|
|
1603
|
-
|
|
1604
1603
|
break;
|
|
1605
1604
|
case 'ס':
|
|
1606
1605
|
return months.SIVAN;
|
|
@@ -1833,7 +1832,7 @@ function getBirthdayOrAnniversary_(hyear, gdate) {
|
|
|
1833
1832
|
return new HDate(day, month, hyear);
|
|
1834
1833
|
}
|
|
1835
1834
|
|
|
1836
|
-
const version="4.
|
|
1835
|
+
const version="4.5.0";
|
|
1837
1836
|
|
|
1838
1837
|
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};
|
|
1839
1838
|
|
package/dist/hdate-bundle.min.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
/*! @hebcal/core v4.
|
|
2
|
-
var hebcal=function(t){"use strict";const e={"א":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(t){const e=[];for(;t>0;){if(15===t||16===t){e.push(9),e.push(t-9);break}let r,n=100;for(r=400;r>t;r-=n)r===n&&(n/=10);e.push(r),t-=r}return e}function a(t){const e=parseInt(t,10);if(!e)throw new TypeError(`invalid parameter to gematriya ${t}`);let a="";const o=Math.floor(e/1e3);if(o>0&&5!==o){const t=n(o);for(let e=0;e<t.length;e++)a+=r[t[e]];a+="׳"}const s=n(e%1e3);if(1==s.length)return a+r[s[0]]+"׳";for(let t=0;t<s.length;t++)t+1===s.length&&(a+="״"),a+=r[s[t]];return a}function o(t){let r=0;const n=t.indexOf("׳");if(-1!==n&&n!==t.length-1){r+=1e3*o(t.substring(0,n)),t=t.substring(n)}for(let n=0;n<t.length;n++){const a=e[t[n]];"number"==typeof a&&(r+=a)}return r}Object.keys(e).forEach((t=>{r[e[t]]=t}));const s=[0,31,28,31,30,31,30,31,31,30,31,30,31],i=[s,s.slice()];function h(t,e){return t-e*Math.floor(t/e)}function c(t,e){return Math.floor(t/e)}function u(t){return!(t%4||!(t%100)&&t%400)}function l(t){return"object"==typeof t&&Date.prototype===t.__proto__}function f(t){if(!l(t))throw new TypeError(`Argument not a Date: ${t}`);return d(t.getFullYear(),t.getMonth()+1,t.getDate())}function d(t,e,r){const n=t-1;return 365*n+c(n,4)-c(n,100)+c(n,400)+c(367*e-362,12)+(e<=2?0:u(t)?-1:-2)+r}function y(t){if("number"!=typeof t)throw new TypeError(`Argument not a Number: ${t}`);const e=function(t){const e=t-1,r=c(e,146097),n=h(e,146097),a=c(n,36524),o=h(n,36524),s=c(o,1461),i=c(h(o,1461),365),u=400*r+100*a+4*s+i;return 4!=a&&4!=i?u+1:u}(t=Math.trunc(t)),r=c(12*(t-d(e,1,1)+(t<d(e,3,1)?0:u(e)?1:2))+373,367),n=t-d(e,r,1)+1,a=new Date(e,r-1,n);return e<100&&e>=0&&a.setFullYear(e),a}i[1][2]=29;const m={monthNames:["","January","February","March","April","May","June","July","August","September","October","November","December"],isLeapYear:u,daysInMonth:function(t,e){return i[+u(e)][t]},isDate:l,dayOfYear:function(t){if(!l(t))throw new TypeError(`Argument not a Date: ${t}`);const e=t.getMonth();let r=t.getDate()+31*e;return e>1&&(r-=Math.floor((4*(e+1)+23)/10),u(t.getFullYear())&&r++),r},greg2abs:f,abs2greg:y},g={headers:{"plural-forms":"nplurals=2; plural=(n!=1);"},contexts:{"":{}}},w={h:"he",a:"ashkenazi",s:"en","":"en"},p=Object.create(null);let b=null,I=null;class A{static lookupTranslation(t,e){const r=e&&e.toLowerCase(),n=("string"==typeof e&&p[r]||b)[t];if(n&&n.length&&n[0].length)return n[0]}static gettext(t,e){const r=this.lookupTranslation(t,e);return void 0===r?t:r}static addLocale(t,e){if("string"!=typeof t)throw new TypeError(`Invalid locale name: ${t}`);if("object"!=typeof e.contexts||"object"!=typeof e.contexts[""])throw new TypeError(`Locale '${t}' invalid compact format`);p[t.toLowerCase()]=e.contexts[""]}static addTranslation(t,e,r){if("string"!=typeof t)throw new TypeError(`Invalid locale name: ${t}`);const n=t.toLowerCase(),a=p[n];if(!a)throw new TypeError(`Unknown locale: ${t}`);if("string"!=typeof e||0===e.length)throw new TypeError(`Invalid id: ${e}`);const o=Array.isArray(r);if(o){const t=r[0];if("string"!=typeof t||0===t.length)throw new TypeError(`Invalid translation array: ${r}`)}else if("string"!=typeof r)throw new TypeError(`Invalid translation: ${r}`);a[e]=o?r:[r]}static addTranslations(t,e){if("string"!=typeof t)throw new TypeError(`Invalid locale name: ${t}`);const r=t.toLowerCase(),n=p[r];if(!n)throw new TypeError(`Unknown locale: ${t}`);if("object"!=typeof e.contexts||"object"!=typeof e.contexts[""])throw new TypeError(`Locale '${t}' invalid compact format`);const a=e.contexts[""];Object.keys(a).forEach((t=>{n[t]=a[t]}))}static useLocale(t){const e=t.toLowerCase(),r=p[e];if(!r)throw new RangeError(`Locale '${t}' not found`);return I=w[e]||e,b=r,b}static getLocaleName(){return I}static getLocaleNames(){return Object.keys(p).sort()}static ordinal(t,e){const r=e&&e.toLowerCase()||I;if(!r)return this.getEnOrdinal(t);switch(r){case"en":case"s":case"a":case"ashkenazi":case"ashkenazi_litvish":case"ashkenazi_poylish":case"ashkenazi_standard":return this.getEnOrdinal(t);case"es":return t+"º";case"h":case"he":case"he-x-nonikud":return String(t);default:return t+"."}}static getEnOrdinal(t){const e=["th","st","nd","rd"],r=t%100;return t+(e[(r-20)%10]||e[r]||e[0])}static hebrewStripNikkud(t){return t.replace(/[\u0590-\u05bd]/g,"").replace(/[\u05bf-\u05c7]/g,"")}}A.addLocale("en",g),A.addLocale("s",g),A.addLocale("",g),A.useLocale("en");const E=1,T=2,N=4,v=6,D=7,M=8,L=9,$=10,k=12,S=13,Y={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},H=["","Nisan","Iyyar","Sivan","Tamuz","Av","Elul","Tishrei","Cheshvan","Kislev","Tevet","Sh'vat"],R=[H.concat(["Adar","Nisan"]),H.concat(["Adar I","Adar II","Nisan"])],O=Object.create(null),V=-1373428,x=365.24682220597794;function F(t,e){if("number"!=typeof t||isNaN(t))throw new TypeError(`invalid parameter '${e}' not a number: ${t}`)}function C(t,e,r){if(F(t,"year"),F(e,"month"),F(r,"day"),t<1)throw new RangeError(`hebrew2abs: invalid year ${t}`);let n=r;if(e<D){for(let e=D;e<=U(t);e++)n+=K(e,t);for(let r=E;r<e;r++)n+=K(r,t)}else for(let r=D;r<e;r++)n+=K(r,t);return V+J(t)+n-1}function _(t){return V+J(t)}function j(t){if(F(t,"abs"),(t=Math.trunc(t))<=V)throw new RangeError(`abs2hebrew: ${t} is before epoch`);let e=Math.floor((t-V)/x);for(;_(e)<=t;)++e;--e;let r=t<C(e,1,1)?7:1;for(;t>C(e,r,K(r,e));)++r;return{yy:e,mm:r,dd:1+t-C(e,r,1)}}function z(t){return(1+7*t)%19<7}function U(t){return 12+z(t)}function K(t,e){switch(t){case T:case N:case v:case $:case S:return 29}return t===k&&!z(e)||t===M&&!G(e)||t===L&&q(e)?29:30}function B(t,e){if(F(t,"month"),F(e,"year"),t<1||t>14)throw new TypeError(`bad month argument ${t}`);return R[+z(e)][t]}function J(t){const e=O[t]=O[t]||function(t){const e=t-1,r=235*Math.floor(e/19)+e%19*12+Math.floor((e%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,s=1+29*r+Math.floor(a/24),i=s+(o>=19440||2==s%7&&o>=9924&&!z(t)||1==s%7&&o>=16789&&z(e));return i+(i%7==0||i%7==3||i%7==5)}(t);return e}function Z(t){return J(t+1)-J(t)}function G(t){return Z(t)%10==5}function q(t){return Z(t)%10==3}function P(t){throw new TypeError(t)}const Q="day",W="week",X="month",tt="year",et={d:Q,w:W,M:X,y:tt},rt={day:Q,week:W,month:X,year:tt};class nt{constructor(t,e,r){if(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,r=parseInt(r,10),isNaN(r))throw new TypeError(`HDate called with bad year argument: ${r}`);if(this.year=r,this.setMonth(e),t=parseInt(t,10),isNaN(t))throw new TypeError(`HDate called with bad day argument: ${t}`);this.setDate(t)}else{void 0===t&&(t=new Date);const e="number"!=typeof t||isNaN(t)?l(t)?f(t):nt.isHDate(t)?{dd:t.day,mm:t.month,yy:t.year}:P(`HDate called with bad argument: ${t}`):t,r="number"==typeof e,n=r?j(e):e;this.day=n.dd,this.month=n.mm,this.year=n.yy,r&&(this.abs0=e)}}getFullYear(){return this.year}isLeapYear(){return z(this.year)}getMonth(){return this.month}getTishreiMonth(){const t=U(this.getFullYear());return(this.getMonth()+t-6)%t||t}daysInMonth(){return K(this.getMonth(),this.getFullYear())}getDate(){return this.day}getDay(){return h(this.abs(),7)}setFullYear(t){return this.year=t,at(this),this}setMonth(t){return this.month=nt.monthNum(t),at(this),this}setDate(t){return this.day=t,at(this),this}greg(){return y(this.abs())}abs(){return"number"!=typeof this.abs0&&(this.abs0=C(this.year,this.month,this.day)),this.abs0}static hebrew2abs(t,e,r){return C(t,e,r)}static abs2hebrew(t){return j(t)}getMonthName(){return B(this.getMonth(),this.getFullYear())}render(){let t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];const e=(arguments.length>0&&void 0!==arguments[0]?arguments[0]:null)||A.getLocaleName(),r=this.getDate(),n=A.gettext(this.getMonthName(),e),a=`${A.ordinal(r,e)}${nt.getDayOfTranslation(e)} ${n}`;if(t){return`${a}, ${this.getFullYear()}`}return a}static getDayOfTranslation(t){switch(t){case"en":case"s":case"a":case"ashkenazi":return" of"}const e=A.lookupTranslation("of",t);return e?" "+e:"ashkenazi"===t.substring(0,9)?" of":""}renderGematriya(){let t=arguments.length>0&&void 0!==arguments[0]&&arguments[0];const e=this.getDate(),r=t?"he-x-NoNikud":"he",n=A.gettext(this.getMonthName(),r),o=this.getFullYear();return a(e)+" "+n+" "+a(o)}before(t){return st(t,this,-1)}onOrBefore(t){return st(t,this,0)}nearest(t){return st(t,this,3)}onOrAfter(t){return st(t,this,6)}after(t){return st(t,this,7)}next(){return new nt(this.abs()+1)}prev(){return new nt(this.abs()-1)}add(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"d";if(!(t=parseInt(t,10)))return new nt(this);if(e=nt.standardizeUnits(e),e===Q)return new nt(this.abs()+t);if(e===W)return new nt(this.abs()+7*t);if(e===tt)return new nt(this.getDate(),this.getMonth(),this.getFullYear()+t);if(e===X){let e=new nt(this);const r=t>0?1:-1;t=Math.abs(t);for(let n=0;n<t;n++)e=new nt(e.abs()+r*e.daysInMonth());return e}}static standardizeUnits(t){const e=et[t]||String(t||"").toLowerCase().replace(/s$/,"");return rt[e]||P(`Invalid units '${t}'`)}subtract(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"d";return this.add(-1*t,e)}deltaDays(t){if(!nt.isHDate(t))throw new TypeError(`Bad argument: ${t}`);return this.abs()-t.abs()}isSameDate(t){return!!nt.isHDate(t)&&(this.year==t.year&&this.month==t.month&&this.day==t.day)}toString(){const t=this.getDate(),e=this.getFullYear();return`${t} ${this.getMonthName()} ${e}`}static isLeapYear(t){return z(t)}static monthsInYear(t){return U(t)}static daysInMonth(t,e){return K(t,e)}static getMonthName(t,e){return B(t,e)}static monthNum(t){if("number"==typeof t){if(isNaN(t)||t>14)throw new RangeError(`Invalid month number: ${t}`);return t}return t.charCodeAt(0)>=48&&t.charCodeAt(0)<=57?parseInt(t,10):nt.monthFromName(t)}static daysInYear(t){return Z(t)}static longCheshvan(t){return G(t)}static shortKislev(t){return q(t)}static monthFromName(t){if("number"==typeof t){if(isNaN(t)||t<1||t>14)throw new RangeError(`Invalid month name: ${t}`);return t}let e=A.hebrewStripNikkud(t).trim().toLowerCase();switch("ב"===e[0]&&(e=e.substring(1)),e[0]){case"n":case"נ":if("o"==e[1])break;return Y.NISAN;case"i":return Y.IYYAR;case"e":return Y.ELUL;case"c":case"ח":return Y.CHESHVAN;case"k":case"כ":return Y.KISLEV;case"s":switch(e[1]){case"i":return Y.SIVAN;case"h":return Y.SHVAT}case"t":switch(e[1]){case"a":return Y.TAMUZ;case"i":return Y.TISHREI;case"e":return Y.TEVET}break;case"a":switch(e[1]){case"v":return Y.AV;case"d":return/(1|[^i]i|a|א)$/i.test(t)?Y.ADAR_I:Y.ADAR_II}break;case"ס":return Y.SIVAN;case"ט":return Y.TEVET;case"ש":return Y.SHVAT;case"א":switch(e[1]){case"ב":return Y.AV;case"ד":return/(1|[^i]i|a|א)$/i.test(t)?Y.ADAR_I:Y.ADAR_II;case"י":return Y.IYYAR;case"ל":return Y.ELUL}break;case"ת":switch(e[1]){case"מ":return Y.TAMUZ;case"ש":return Y.TISHREI}}throw new RangeError(`Unable to parse month name: ${t}`)}static dayOnOrBefore(t,e){return e-(e-t)%7}static isHDate(t){return null!==t&&"object"==typeof t&&"number"==typeof t.year&&"number"==typeof t.month&&"number"==typeof t.day&&"function"==typeof t.greg&&"function"==typeof t.abs}static fromGematriyaString(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:5e3;const r=t.split(" "),n=o(r[0]),a=nt.monthFromName(r[1]);let s=o(r[2]);return s<1e3&&(s+=e),new nt(n,a,s)}}function at(t){ot(t),function(t){t.day<1&&(t.month==Y.TISHREI&&(t.year-=1),t.day+=K(t.month,t.year),t.month-=1,at(t));t.day>K(t.month,t.year)&&(t.month===Y.ELUL&&(t.year+=1),t.day-=K(t.month,t.year),t.month+=1,at(t));ot(t)}(t)}function ot(t){t.month!==Y.ADAR_II||t.isLeapYear()?t.month<1?(t.month+=U(t.year),t.year-=1,at(t)):t.month>U(t.year)&&(t.month-=U(t.year),t.year+=1,at(t)):(t.month-=1,at(t)),delete t.abs0}function st(t,e,r){return new nt(nt.dayOnOrBefore(t,e.abs()+r))}const it=Y.NISAN,ht=Y.CHESHVAN,ct=Y.KISLEV,ut=Y.TEVET,lt=Y.SHVAT,ft=Y.ADAR_I,dt=Y.ADAR_II;var yt={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:["תִּשְׁרֵי"]}}};A.addLocale("he",yt),A.addLocale("h",yt);const mt=yt.contexts[""],gt={};return Object.keys(mt).forEach((t=>{gt[t]=[A.hebrewStripNikkud(mt[t][0])]})),A.addLocale("he-x-NoNikud",{headers:yt.headers,contexts:{"":gt}}),t.HDate=nt,t.Locale=A,t.gematriya=a,t.getBirthdayOrAnniversary=function(t,e){const r=nt.isHDate(e)?e:new nt(e),n=r.getFullYear();if(t===n)return r;if(t<n)return;const a=z(n);let o=r.getMonth(),s=r.getDate();return o==ft&&!a||o==dt&&a?o=U(t):o!=ht||30!=s||G(t)?o==ct&&30==s&&q(t)?(o=ut,s=1):o==ft&&30==s&&a&&!z(t)&&(o=it,s=1):(o=ct,s=1),new nt(s,o,t)},t.getYahrzeit=function(t,e){const r=nt.isHDate(e)?e:new nt(e);let n={yy:r.getFullYear(),mm:r.getMonth(),dd:r.getDate()};if(!(t<=n.yy))return n.mm!=ht||30!=n.dd||G(n.yy+1)?n.mm==ct&&30==n.dd&&q(n.yy+1)?n=j(C(t,ut,1)-1):n.mm==dt?n.mm=U(t):n.mm!=ft||30!=n.dd||z(t)||(n.dd=30,n.mm=lt):n=j(C(t,ct,1)-1),n.mm!=ht||30!=n.dd||G(t)?n.mm==ct&&30==n.dd&&q(t)&&(n.mm=ut,n.dd=1):(n.mm=ct,n.dd=1),new nt(n.dd,n.mm,t)},t.greg=m,t.months=Y,t.version="4.4.0",t}({});
|
|
1
|
+
/*! @hebcal/core v4.5.0 */
|
|
2
|
+
var hebcal=function(t){"use strict";const e={"א":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(t){const e=[];for(;t>0;){if(15===t||16===t){e.push(9),e.push(t-9);break}let r,n=100;for(r=400;r>t;r-=n)r===n&&(n/=10);e.push(r),t-=r}return e}function a(t){const e=parseInt(t,10);if(!e)throw new TypeError(`invalid parameter to gematriya ${t}`);let a="";const o=Math.floor(e/1e3);if(o>0&&5!==o){const t=n(o);for(const e of t)a+=r[e];a+="׳"}const s=n(e%1e3);if(1==s.length)return a+r[s[0]]+"׳";for(let t=0;t<s.length;t++)t+1===s.length&&(a+="״"),a+=r[s[t]];return a}function o(t){let r=0;const n=t.indexOf("׳");if(-1!==n&&n!==t.length-1){r+=1e3*o(t.substring(0,n)),t=t.substring(n)}for(const n of t){const t=e[n];"number"==typeof t&&(r+=t)}return r}Object.keys(e).forEach((t=>{r[e[t]]=t}));const s=[0,31,28,31,30,31,30,31,31,30,31,30,31],i=[s,s.slice()];function h(t,e){return t-e*Math.floor(t/e)}function c(t,e){return Math.floor(t/e)}function u(t){return!(t%4||!(t%100)&&t%400)}function l(t){return"object"==typeof t&&Date.prototype===t.__proto__}function f(t){if(!l(t))throw new TypeError(`Argument not a Date: ${t}`);return d(t.getFullYear(),t.getMonth()+1,t.getDate())}function d(t,e,r){const n=t-1;return 365*n+c(n,4)-c(n,100)+c(n,400)+c(367*e-362,12)+(e<=2?0:u(t)?-1:-2)+r}function y(t){if("number"!=typeof t)throw new TypeError(`Argument not a Number: ${t}`);const e=function(t){const e=t-1,r=c(e,146097),n=h(e,146097),a=c(n,36524),o=h(n,36524),s=c(o,1461),i=c(h(o,1461),365),u=400*r+100*a+4*s+i;return 4!=a&&4!=i?u+1:u}(t=Math.trunc(t)),r=c(12*(t-d(e,1,1)+(t<d(e,3,1)?0:u(e)?1:2))+373,367),n=t-d(e,r,1)+1,a=new Date(e,r-1,n);return e<100&&e>=0&&a.setFullYear(e),a}i[1][2]=29;const m={monthNames:["","January","February","March","April","May","June","July","August","September","October","November","December"],isLeapYear:u,daysInMonth:function(t,e){return i[+u(e)][t]},isDate:l,dayOfYear:function(t){if(!l(t))throw new TypeError(`Argument not a Date: ${t}`);const e=t.getMonth();let r=t.getDate()+31*e;return e>1&&(r-=Math.floor((4*(e+1)+23)/10),u(t.getFullYear())&&r++),r},greg2abs:f,abs2greg:y},g={headers:{"plural-forms":"nplurals=2; plural=(n!=1);"},contexts:{"":{}}},w={h:"he",a:"ashkenazi",s:"en","":"en"},p=Object.create(null);let b=null,I=null;class A{static lookupTranslation(t,e){const r=null==e?void 0:e.toLowerCase(),n=("string"==typeof e&&p[r]||b)[t];if(n&&n.length&&n[0].length)return n[0]}static gettext(t,e){const r=this.lookupTranslation(t,e);return void 0===r?t:r}static addLocale(t,e){if("string"!=typeof t)throw new TypeError(`Invalid locale name: ${t}`);if("object"!=typeof e.contexts||"object"!=typeof e.contexts[""])throw new TypeError(`Locale '${t}' invalid compact format`);p[t.toLowerCase()]=e.contexts[""]}static addTranslation(t,e,r){if("string"!=typeof t)throw new TypeError(`Invalid locale name: ${t}`);const n=t.toLowerCase(),a=p[n];if(!a)throw new TypeError(`Unknown locale: ${t}`);if("string"!=typeof e||0===e.length)throw new TypeError(`Invalid id: ${e}`);const o=Array.isArray(r);if(o){const t=r[0];if("string"!=typeof t||0===t.length)throw new TypeError(`Invalid translation array: ${r}`)}else if("string"!=typeof r)throw new TypeError(`Invalid translation: ${r}`);a[e]=o?r:[r]}static addTranslations(t,e){if("string"!=typeof t)throw new TypeError(`Invalid locale name: ${t}`);const r=t.toLowerCase(),n=p[r];if(!n)throw new TypeError(`Unknown locale: ${t}`);if("object"!=typeof e.contexts||"object"!=typeof e.contexts[""])throw new TypeError(`Locale '${t}' invalid compact format`);const a=e.contexts[""];Object.keys(a).forEach((t=>{n[t]=a[t]}))}static useLocale(t){const e=t.toLowerCase(),r=p[e];if(!r)throw new RangeError(`Locale '${t}' not found`);return I=w[e]||e,b=r,b}static getLocaleName(){return I}static getLocaleNames(){return Object.keys(p).sort(((t,e)=>t.localeCompare(e)))}static ordinal(t,e){const r=(null==e?void 0:e.toLowerCase())||I;if(!r)return this.getEnOrdinal(t);switch(r){case"en":case"s":case"a":case"ashkenazi":case"ashkenazi_litvish":case"ashkenazi_poylish":case"ashkenazi_standard":return this.getEnOrdinal(t);case"es":return t+"º";case"h":case"he":case"he-x-nonikud":return String(t);default:return t+"."}}static getEnOrdinal(t){const e=["th","st","nd","rd"],r=t%100;return t+(e[(r-20)%10]||e[r]||e[0])}static hebrewStripNikkud(t){return t.replace(/[\u0590-\u05bd]/g,"").replace(/[\u05bf-\u05c7]/g,"")}}A.addLocale("en",g),A.addLocale("s",g),A.addLocale("",g),A.useLocale("en");const E=1,T=2,N=4,v=6,D=7,M=8,L=9,$=10,k=12,S=13,Y={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},H=["","Nisan","Iyyar","Sivan","Tamuz","Av","Elul","Tishrei","Cheshvan","Kislev","Tevet","Sh'vat"],R=[H.concat(["Adar","Nisan"]),H.concat(["Adar I","Adar II","Nisan"])],O=Object.create(null),V=-1373428,x=365.24682220597794;function F(t,e){if("number"!=typeof t||isNaN(t))throw new TypeError(`invalid parameter '${e}' not a number: ${t}`)}function C(t,e,r){if(F(t,"year"),F(e,"month"),F(r,"day"),t<1)throw new RangeError(`hebrew2abs: invalid year ${t}`);let n=r;if(e<D){for(let e=D;e<=U(t);e++)n+=K(e,t);for(let r=E;r<e;r++)n+=K(r,t)}else for(let r=D;r<e;r++)n+=K(r,t);return V+J(t)+n-1}function _(t){return V+J(t)}function j(t){if(F(t,"abs"),(t=Math.trunc(t))<=V)throw new RangeError(`abs2hebrew: ${t} is before epoch`);let e=Math.floor((t-V)/x);for(;_(e)<=t;)++e;--e;let r=t<C(e,1,1)?7:1;for(;t>C(e,r,K(r,e));)++r;return{yy:e,mm:r,dd:1+t-C(e,r,1)}}function z(t){return(1+7*t)%19<7}function U(t){return 12+z(t)}function K(t,e){switch(t){case T:case N:case v:case $:case S:return 29}return t===k&&!z(e)||t===M&&!G(e)||t===L&&q(e)?29:30}function B(t,e){if(F(t,"month"),F(e,"year"),t<1||t>14)throw new TypeError(`bad month argument ${t}`);return R[+z(e)][t]}function J(t){const e=O[t]=O[t]||function(t){const e=t-1,r=235*Math.floor(e/19)+e%19*12+Math.floor((e%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,s=1+29*r+Math.floor(a/24),i=s+(o>=19440||2==s%7&&o>=9924&&!z(t)||1==s%7&&o>=16789&&z(e));return i+(i%7==0||i%7==3||i%7==5)}(t);return e}function Z(t){return J(t+1)-J(t)}function G(t){return Z(t)%10==5}function q(t){return Z(t)%10==3}function W(t){throw new TypeError(t)}const P="day",Q="week",X="month",tt="year",et={d:P,w:Q,M:X,y:tt},rt={day:P,week:Q,month:X,year:tt};class nt{constructor(t,e,r){if(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,r=parseInt(r,10),isNaN(r))throw new TypeError(`HDate called with bad year argument: ${r}`);if(this.year=r,this.setMonth(e),t=parseInt(t,10),isNaN(t))throw new TypeError(`HDate called with bad day argument: ${t}`);this.setDate(t)}else{void 0===t&&(t=new Date);const e="number"!=typeof t||isNaN(t)?l(t)?f(t):nt.isHDate(t)?{dd:t.day,mm:t.month,yy:t.year}:W(`HDate called with bad argument: ${t}`):t,r="number"==typeof e,n=r?j(e):e;this.day=n.dd,this.month=n.mm,this.year=n.yy,r&&(this.abs0=e)}}getFullYear(){return this.year}isLeapYear(){return z(this.year)}getMonth(){return this.month}getTishreiMonth(){const t=U(this.getFullYear());return(this.getMonth()+t-6)%t||t}daysInMonth(){return K(this.getMonth(),this.getFullYear())}getDate(){return this.day}getDay(){return h(this.abs(),7)}setFullYear(t){return this.year=t,at(this),this}setMonth(t){return this.month=nt.monthNum(t),at(this),this}setDate(t){return this.day=t,at(this),this}greg(){return y(this.abs())}abs(){return"number"!=typeof this.abs0&&(this.abs0=C(this.year,this.month,this.day)),this.abs0}static hebrew2abs(t,e,r){return C(t,e,r)}static abs2hebrew(t){return j(t)}getMonthName(){return B(this.getMonth(),this.getFullYear())}render(){let t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];const e=(arguments.length>0&&void 0!==arguments[0]?arguments[0]:null)||A.getLocaleName(),r=this.getDate(),n=A.gettext(this.getMonthName(),e),a=`${A.ordinal(r,e)}${nt.getDayOfTranslation(e)} ${n}`;if(t){return`${a}, ${this.getFullYear()}`}return a}static getDayOfTranslation(t){switch(t){case"en":case"s":case"a":case"ashkenazi":return" of"}const e=A.lookupTranslation("of",t);return e?" "+e:t.startsWith("ashkenazi")?" of":""}renderGematriya(){let t=arguments.length>0&&void 0!==arguments[0]&&arguments[0];const e=this.getDate(),r=t?"he-x-NoNikud":"he",n=A.gettext(this.getMonthName(),r),o=this.getFullYear();return a(e)+" "+n+" "+a(o)}before(t){return st(t,this,-1)}onOrBefore(t){return st(t,this,0)}nearest(t){return st(t,this,3)}onOrAfter(t){return st(t,this,6)}after(t){return st(t,this,7)}next(){return new nt(this.abs()+1)}prev(){return new nt(this.abs()-1)}add(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"d";if(!(t=parseInt(t,10)))return new nt(this);if(e=nt.standardizeUnits(e),e===P)return new nt(this.abs()+t);if(e===Q)return new nt(this.abs()+7*t);if(e===tt)return new nt(this.getDate(),this.getMonth(),this.getFullYear()+t);if(e===X){let e=new nt(this);const r=t>0?1:-1;t=Math.abs(t);for(let n=0;n<t;n++)e=new nt(e.abs()+r*e.daysInMonth());return e}}static standardizeUnits(t){const e=et[t]||String(t||"").toLowerCase().replace(/s$/,"");return rt[e]||W(`Invalid units '${t}'`)}subtract(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"d";return this.add(-1*t,e)}deltaDays(t){if(!nt.isHDate(t))throw new TypeError(`Bad argument: ${t}`);return this.abs()-t.abs()}isSameDate(t){return!!nt.isHDate(t)&&(this.year==t.year&&this.month==t.month&&this.day==t.day)}toString(){const t=this.getDate(),e=this.getFullYear();return`${t} ${this.getMonthName()} ${e}`}static isLeapYear(t){return z(t)}static monthsInYear(t){return U(t)}static daysInMonth(t,e){return K(t,e)}static getMonthName(t,e){return B(t,e)}static monthNum(t){if("number"==typeof t){if(isNaN(t)||t>14)throw new RangeError(`Invalid month number: ${t}`);return t}return t.charCodeAt(0)>=48&&t.charCodeAt(0)<=57?parseInt(t,10):nt.monthFromName(t)}static daysInYear(t){return Z(t)}static longCheshvan(t){return G(t)}static shortKislev(t){return q(t)}static monthFromName(t){if("number"==typeof t){if(isNaN(t)||t<1||t>14)throw new RangeError(`Invalid month name: ${t}`);return t}let e=A.hebrewStripNikkud(t).trim().toLowerCase();switch("ב"===e[0]&&(e=e.substring(1)),e[0]){case"n":case"נ":if("o"==e[1])break;return Y.NISAN;case"i":return Y.IYYAR;case"e":return Y.ELUL;case"c":case"ח":return Y.CHESHVAN;case"k":case"כ":return Y.KISLEV;case"s":switch(e[1]){case"i":return Y.SIVAN;case"h":return Y.SHVAT}break;case"t":switch(e[1]){case"a":return Y.TAMUZ;case"i":return Y.TISHREI;case"e":return Y.TEVET}break;case"a":switch(e[1]){case"v":return Y.AV;case"d":return/(1|[^i]i|a|א)$/i.test(t)?Y.ADAR_I:Y.ADAR_II}break;case"ס":return Y.SIVAN;case"ט":return Y.TEVET;case"ש":return Y.SHVAT;case"א":switch(e[1]){case"ב":return Y.AV;case"ד":return/(1|[^i]i|a|א)$/i.test(t)?Y.ADAR_I:Y.ADAR_II;case"י":return Y.IYYAR;case"ל":return Y.ELUL}break;case"ת":switch(e[1]){case"מ":return Y.TAMUZ;case"ש":return Y.TISHREI}}throw new RangeError(`Unable to parse month name: ${t}`)}static dayOnOrBefore(t,e){return e-(e-t)%7}static isHDate(t){return null!==t&&"object"==typeof t&&"number"==typeof t.year&&"number"==typeof t.month&&"number"==typeof t.day&&"function"==typeof t.greg&&"function"==typeof t.abs}static fromGematriyaString(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:5e3;const r=t.split(" "),n=o(r[0]),a=nt.monthFromName(r[1]);let s=o(r[2]);return s<1e3&&(s+=e),new nt(n,a,s)}}function at(t){ot(t),function(t){t.day<1&&(t.month==Y.TISHREI&&(t.year-=1),t.day+=K(t.month,t.year),t.month-=1,at(t));t.day>K(t.month,t.year)&&(t.month===Y.ELUL&&(t.year+=1),t.day-=K(t.month,t.year),t.month+=1,at(t));ot(t)}(t)}function ot(t){t.month!==Y.ADAR_II||t.isLeapYear()?t.month<1?(t.month+=U(t.year),t.year-=1,at(t)):t.month>U(t.year)&&(t.month-=U(t.year),t.year+=1,at(t)):(t.month-=1,at(t)),delete t.abs0}function st(t,e,r){return new nt(nt.dayOnOrBefore(t,e.abs()+r))}const it=Y.NISAN,ht=Y.CHESHVAN,ct=Y.KISLEV,ut=Y.TEVET,lt=Y.SHVAT,ft=Y.ADAR_I,dt=Y.ADAR_II;var yt={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:["תִּשְׁרֵי"]}}};A.addLocale("he",yt),A.addLocale("h",yt);const mt=yt.contexts[""],gt={};return Object.keys(mt).forEach((t=>{gt[t]=[A.hebrewStripNikkud(mt[t][0])]})),A.addLocale("he-x-NoNikud",{headers:yt.headers,contexts:{"":gt}}),t.HDate=nt,t.Locale=A,t.gematriya=a,t.getBirthdayOrAnniversary=function(t,e){const r=nt.isHDate(e)?e:new nt(e),n=r.getFullYear();if(t===n)return r;if(t<n)return;const a=z(n);let o=r.getMonth(),s=r.getDate();return o==ft&&!a||o==dt&&a?o=U(t):o!=ht||30!=s||G(t)?o==ct&&30==s&&q(t)?(o=ut,s=1):o==ft&&30==s&&a&&!z(t)&&(o=it,s=1):(o=ct,s=1),new nt(s,o,t)},t.getYahrzeit=function(t,e){const r=nt.isHDate(e)?e:new nt(e);let n={yy:r.getFullYear(),mm:r.getMonth(),dd:r.getDate()};if(!(t<=n.yy))return n.mm!=ht||30!=n.dd||G(n.yy+1)?n.mm==ct&&30==n.dd&&q(n.yy+1)?n=j(C(t,ut,1)-1):n.mm==dt?n.mm=U(t):n.mm!=ft||30!=n.dd||z(t)||(n.dd=30,n.mm=lt):n=j(C(t,ct,1)-1),n.mm!=ht||30!=n.dd||G(t)?n.mm==ct&&30==n.dd&&q(t)&&(n.mm=ut,n.dd=1):(n.mm=ct,n.dd=1),new nt(n.dd,n.mm,t)},t.greg=m,t.months=Y,t.version="4.5.0",t}({});
|
package/dist/hdate.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! @hebcal/core v4.
|
|
1
|
+
/*! @hebcal/core v4.5.0 */
|
|
2
2
|
'use strict';
|
|
3
3
|
|
|
4
4
|
const GERESH = '׳';
|
|
@@ -82,8 +82,8 @@ function gematriya(number) {
|
|
|
82
82
|
const thousands = Math.floor(num / 1000);
|
|
83
83
|
if (thousands > 0 && thousands !== 5) {
|
|
84
84
|
const tdigits = num2digits(thousands);
|
|
85
|
-
for (
|
|
86
|
-
str += num2heb[
|
|
85
|
+
for (const tdig of tdigits) {
|
|
86
|
+
str += num2heb[tdig];
|
|
87
87
|
}
|
|
88
88
|
str += GERESH;
|
|
89
89
|
}
|
|
@@ -118,8 +118,8 @@ function gematriyaStrToNum(str) {
|
|
|
118
118
|
num += gematriyaStrToNum(thousands) * 1000;
|
|
119
119
|
str = str.substring(gereshIdx);
|
|
120
120
|
}
|
|
121
|
-
for (
|
|
122
|
-
const n = heb2num[
|
|
121
|
+
for (const ch of str) {
|
|
122
|
+
const n = heb2num[ch];
|
|
123
123
|
if (typeof n === 'number') {
|
|
124
124
|
num += n;
|
|
125
125
|
}
|
|
@@ -409,7 +409,7 @@ class Locale {
|
|
|
409
409
|
* @return {string}
|
|
410
410
|
*/
|
|
411
411
|
static lookupTranslation(id, locale) {
|
|
412
|
-
const locale0 = locale
|
|
412
|
+
const locale0 = locale === null || locale === void 0 ? void 0 : locale.toLowerCase();
|
|
413
413
|
const loc = typeof locale == 'string' && locales[locale0] || activeLocale;
|
|
414
414
|
const array = loc[id];
|
|
415
415
|
if (array && array.length && array[0].length) {
|
|
@@ -529,7 +529,7 @@ class Locale {
|
|
|
529
529
|
* @return {string[]}
|
|
530
530
|
*/
|
|
531
531
|
static getLocaleNames() {
|
|
532
|
-
return Object.keys(locales).sort();
|
|
532
|
+
return Object.keys(locales).sort((a, b) => a.localeCompare(b));
|
|
533
533
|
}
|
|
534
534
|
|
|
535
535
|
/**
|
|
@@ -538,7 +538,7 @@ class Locale {
|
|
|
538
538
|
* @return {string}
|
|
539
539
|
*/
|
|
540
540
|
static ordinal(n, locale) {
|
|
541
|
-
const locale1 = locale
|
|
541
|
+
const locale1 = locale === null || locale === void 0 ? void 0 : locale.toLowerCase();
|
|
542
542
|
const locale0 = locale1 || activeName;
|
|
543
543
|
if (!locale0) {
|
|
544
544
|
return this.getEnOrdinal(n);
|
|
@@ -1203,7 +1203,7 @@ class HDate {
|
|
|
1203
1203
|
if (ofStr) {
|
|
1204
1204
|
return ' ' + ofStr;
|
|
1205
1205
|
}
|
|
1206
|
-
if ('ashkenazi'
|
|
1206
|
+
if (locale.startsWith('ashkenazi')) {
|
|
1207
1207
|
return ' of';
|
|
1208
1208
|
}
|
|
1209
1209
|
return '';
|
|
@@ -1573,6 +1573,7 @@ class HDate {
|
|
|
1573
1573
|
case 'h':
|
|
1574
1574
|
return months.SHVAT;
|
|
1575
1575
|
}
|
|
1576
|
+
break;
|
|
1576
1577
|
case 't':
|
|
1577
1578
|
switch (c[1]) {
|
|
1578
1579
|
case 'a':
|
|
@@ -1592,9 +1593,7 @@ class HDate {
|
|
|
1592
1593
|
return months.ADAR_I;
|
|
1593
1594
|
}
|
|
1594
1595
|
return months.ADAR_II;
|
|
1595
|
-
// else assume sheini
|
|
1596
1596
|
}
|
|
1597
|
-
|
|
1598
1597
|
break;
|
|
1599
1598
|
case 'ס':
|
|
1600
1599
|
return months.SIVAN;
|
|
@@ -1826,7 +1825,7 @@ function getBirthdayOrAnniversary_(hyear, gdate) {
|
|
|
1826
1825
|
return new HDate(day, month, hyear);
|
|
1827
1826
|
}
|
|
1828
1827
|
|
|
1829
|
-
const version="4.
|
|
1828
|
+
const version="4.5.0";
|
|
1830
1829
|
|
|
1831
1830
|
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};
|
|
1832
1831
|
|
package/dist/hdate.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! @hebcal/core v4.
|
|
1
|
+
/*! @hebcal/core v4.5.0 */
|
|
2
2
|
const GERESH = '׳';
|
|
3
3
|
const GERSHAYIM = '״';
|
|
4
4
|
|
|
@@ -81,8 +81,8 @@ function gematriya(number) {
|
|
|
81
81
|
const thousands = Math.floor(num / 1000);
|
|
82
82
|
if (thousands > 0 && thousands !== 5) {
|
|
83
83
|
const tdigits = num2digits(thousands);
|
|
84
|
-
for (
|
|
85
|
-
str += num2heb[
|
|
84
|
+
for (const tdig of tdigits) {
|
|
85
|
+
str += num2heb[tdig];
|
|
86
86
|
}
|
|
87
87
|
str += GERESH;
|
|
88
88
|
}
|
|
@@ -117,8 +117,8 @@ function gematriyaStrToNum(str) {
|
|
|
117
117
|
num += gematriyaStrToNum(thousands) * 1000;
|
|
118
118
|
str = str.substring(gereshIdx);
|
|
119
119
|
}
|
|
120
|
-
for (
|
|
121
|
-
const n = heb2num[
|
|
120
|
+
for (const ch of str) {
|
|
121
|
+
const n = heb2num[ch];
|
|
122
122
|
if (typeof n === 'number') {
|
|
123
123
|
num += n;
|
|
124
124
|
}
|
|
@@ -433,7 +433,7 @@ class Locale {
|
|
|
433
433
|
* @return {string}
|
|
434
434
|
*/
|
|
435
435
|
static lookupTranslation(id, locale) {
|
|
436
|
-
const locale0 = locale
|
|
436
|
+
const locale0 = locale?.toLowerCase();
|
|
437
437
|
const loc = (typeof locale == 'string' && locales[locale0]) || activeLocale;
|
|
438
438
|
const array = loc[id];
|
|
439
439
|
if (array && array.length && array[0].length) {
|
|
@@ -553,7 +553,7 @@ class Locale {
|
|
|
553
553
|
* @return {string[]}
|
|
554
554
|
*/
|
|
555
555
|
static getLocaleNames() {
|
|
556
|
-
return Object.keys(locales).sort();
|
|
556
|
+
return Object.keys(locales).sort((a, b) => a.localeCompare(b));
|
|
557
557
|
}
|
|
558
558
|
|
|
559
559
|
/**
|
|
@@ -562,7 +562,7 @@ class Locale {
|
|
|
562
562
|
* @return {string}
|
|
563
563
|
*/
|
|
564
564
|
static ordinal(n, locale) {
|
|
565
|
-
const locale1 = locale
|
|
565
|
+
const locale1 = locale?.toLowerCase();
|
|
566
566
|
const locale0 = locale1 || activeName;
|
|
567
567
|
if (!locale0) {
|
|
568
568
|
return this.getEnOrdinal(n);
|
|
@@ -1256,7 +1256,7 @@ class HDate {
|
|
|
1256
1256
|
if (ofStr) {
|
|
1257
1257
|
return ' ' + ofStr;
|
|
1258
1258
|
}
|
|
1259
|
-
if ('ashkenazi'
|
|
1259
|
+
if (locale.startsWith('ashkenazi')) {
|
|
1260
1260
|
return ' of';
|
|
1261
1261
|
}
|
|
1262
1262
|
return '';
|
|
@@ -1629,6 +1629,7 @@ class HDate {
|
|
|
1629
1629
|
case 'h':
|
|
1630
1630
|
return months.SHVAT;
|
|
1631
1631
|
}
|
|
1632
|
+
break;
|
|
1632
1633
|
case 't':
|
|
1633
1634
|
switch (c[1]) {
|
|
1634
1635
|
case 'a':
|
|
@@ -1888,7 +1889,7 @@ function getBirthdayOrAnniversary_(hyear, gdate) {
|
|
|
1888
1889
|
return new HDate(day, month, hyear);
|
|
1889
1890
|
}
|
|
1890
1891
|
|
|
1891
|
-
const version="4.
|
|
1892
|
+
const version="4.5.0";
|
|
1892
1893
|
|
|
1893
1894
|
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};
|
|
1894
1895
|
|
package/dist/hdate0-bundle.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
/*! @hebcal/core v4.
|
|
1
|
+
/*! @hebcal/core v4.5.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