@hebcal/core 4.5.1 → 5.0.0-rc2
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 +1109 -457
- package/dist/bundle.js +5124 -1331
- package/dist/bundle.min.js +2 -2
- package/dist/index.js +2216 -1525
- package/dist/index.mjs +2215 -1524
- package/hebcal.d.ts +28 -95
- package/package.json +10 -8
- package/dist/greg0.mjs +0 -159
- package/dist/hdate-bundle.js +0 -1864
- package/dist/hdate-bundle.min.js +0 -2
- package/dist/hdate.js +0 -1853
- package/dist/hdate.mjs +0 -1909
- package/dist/hdate0-bundle.js +0 -444
- package/dist/hdate0-bundle.min.js +0 -2
- package/dist/hdate0.mjs +0 -465
- package/po/a.txt +0 -576
- package/po/b.txt +0 -264
package/dist/hdate-bundle.min.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
/*! @hebcal/core v4.5.1 */
|
|
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.1",t}({});
|