@hebcal/core 3.26.2 → 3.26.6
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 +122 -65
- package/dist/bundle.js +993 -77
- package/dist/bundle.min.js +2 -2
- package/dist/hdate-bundle.js +959 -52
- package/dist/hdate-bundle.min.js +2 -2
- package/dist/hdate.js +35 -31
- package/dist/hdate.mjs +35 -31
- package/dist/index.js +69 -36
- package/dist/index.mjs +69 -36
- package/hebcal.d.ts +66 -35
- package/package.json +9 -9
package/dist/hdate-bundle.min.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
/*! @hebcal/core v3.26.
|
|
2
|
-
var hebcal=function(e){"use strict";function t(e){switch(e){case 1:return"א";case 2:return"ב";case 3:return"ג";case 4:return"ד";case 5:return"ה";case 6:return"ו";case 7:return"ז";case 8:return"ח";case 9:return"ט";case 10:return"י";case 20:return"כ";case 30:return"ל";case 40:return"מ";case 50:return"נ";case 60:return"ס";case 70:return"ע";case 80:return"פ";case 90:return"צ";case 100:return"ק";case 200:return"ר";case 300:return"ש";case 400:return"ת";default:return"*INVALID*"}}function r(e){let r=parseInt(e,10);if(!r)throw new TypeError("invalid parameter to gematriya ".concat(e));const a=[];for(r%=1e3;r>0;){if(15===r||16===r){a.push(9),a.push(r-9);break}let e,t=100;for(e=400;e>r;e-=t)e===t&&(t/=10);a.push(e),r-=e}if(1==a.length)return t(a[0])+"׳";let n="";for(let e=0;e<a.length;e++)e+1===a.length&&(n+="״"),n+=t(a[e]);return n}const a=[[0,31,28,31,30,31,30,31,31,30,31,30,31],[0,31,29,31,30,31,30,31,31,30,31,30,31]];function n(e,t){return e-t*Math.floor(e/t)}function s(e,t){return Math.floor(e/t)}const o={monthNames:["","January","February","March","April","May","June","July","August","September","October","November","December"],isLeapYear:function(e){return!(e%4||!(e%100)&&e%400)},daysInMonth:function(e,t){return a[+this.isLeapYear(t)][e]},isDate:function(e){return"object"==typeof e&&Date.prototype===e.__proto__},dayOfYear:function(e){if(!this.isDate(e))throw new TypeError("Argument to greg.dayOfYear not a Date");let t=e.getDate()+31*e.getMonth();return e.getMonth()>1&&(t-=Math.floor((4*(e.getMonth()+1)+23)/10),this.isLeapYear(e.getFullYear())&&t++),t},greg2abs:function(e){if(!this.isDate(e))throw new TypeError("Argument to greg.greg2abs not a Date");const t=e.getFullYear()-1;return this.dayOfYear(e)+365*t+(Math.floor(t/4)-Math.floor(t/100)+Math.floor(t/400))},yearFromFixed:function(e){const t=e-1,r=s(t,146097),a=n(t,146097),o=s(a,36524),i=n(a,36524),h=s(i,1461),c=s(n(i,1461),365),u=400*r+100*o+4*h+c;return 4!=o&&4!=c?u+1:u},toFixed:function(e,t,r){const a=e-1;return 0+365*a+s(a,4)-s(a,100)+s(a,400)+s(367*t-362,12)+Math.floor(t<=2?0:this.isLeapYear(e)?-1:-2)+r},abs2greg:function(e){if("number"!=typeof e)throw new TypeError("Argument to greg.abs2greg not a Number");const t=this.yearFromFixed(e),r=s(12*(e-this.toFixed(t,1,1)+(e<this.toFixed(t,3,1)?0:this.isLeapYear(t)?1:2))+373,367),a=e-this.toFixed(t,r,1)+1,n=new Date(t,r-1,a);return t<100&&t>=0&&n.setFullYear(t),n}},i={headers:{"plural-forms":"nplurals=2; plural=(n!=1);"},contexts:{"":{}}},h={h:"he",a:"ashkenazi",s:"en","":"en"},c={locales:Object.create(null),activeLocale:null,activeName:null,lookupTranslation:function(e,t){const r=("string"==typeof t&&this.locales[t]||this.activeLocale)[e];if(r&&r.length&&r[0].length)return r[0]},gettext:function(e,t){const r=this.lookupTranslation(e,t);return void 0===r?e:r},addLocale:function(e,t){if("object"!=typeof t.contexts||"object"!=typeof t.contexts[""])throw new Error("Locale '".concat(e,"' invalid compact format"));this.locales[e.toLowerCase()]=t.contexts[""]},useLocale:function(e){const t=e.toLowerCase(),r=this.locales[t];if(!r)throw new Error("Locale '".concat(e,"' not found"));return this.activeName=h[t]||t,this.activeLocale=r,this.activeLocale},getLocaleName:function(){return this.activeName},ordinal:function(e,t){const r=t||this.activeName;return r&&"en"!==r&&"ashkenazi"!==r.substring(0,9)?"es"==r?e+"º":e+".":this.getEnOrdinal(e)},getEnOrdinal:function(e){const t=["th","st","nd","rd"],r=e%100;return e+(t[(r-20)%10]||t[r]||t[0])},hebrewStripNikkud:function(e){return e.replace(/[\u0590-\u05bd]/g,"").replace(/[\u05bf-\u05c7]/g,"")}};c.addLocale("en",i),c.addLocale("s",i),c.addLocale("",i),c.useLocale("en");const u=["","Nisan","Iyyar","Sivan","Tamuz","Av","Elul","Tishrei","Cheshvan","Kislev","Tevet","Sh'vat"],l=[u.concat(["Adar","Nisan"]),u.concat(["Adar I","Adar II","Nisan"])];function y(e){throw new TypeError(e)}const d=Object.create(null),f=-1373428,m="day",g="week",p="month",b="year",w={d:m,w:g,M:p,y:b},M={day:m,week:g,month:p,year:b};class D{constructor(e,t,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,this.year=+r,isNaN(this.year))throw new TypeError("HDate called with bad year argument: ".concat(r));if(this.setMonth(t),this.setDate(+e),isNaN(this.day))throw new TypeError("HDate called with bad day argument: ".concat(e))}else{void 0===e&&(e=new Date);const t="number"!=typeof e||isNaN(e)?o.isDate(e)?o.greg2abs(e):D.isHDate(e)?{dd:e.day,mm:e.month,yy:e.year}:y("HDate called with bad argument: ".concat(e)):e,r="number"==typeof t,a=r?D.abs2hebrew(t):t;this.day=a.dd,this.month=a.mm,this.year=a.yy,r&&(this.abs0=t)}}getFullYear(){return this.year}isLeapYear(){return D.isLeapYear(this.year)}getMonth(){return this.month}getTishreiMonth(){const e=D.monthsInYear(this.getFullYear());return(this.getMonth()+e-6)%e||e}daysInMonth(){return D.daysInMonth(this.getMonth(),this.getFullYear())}getDate(){return this.day}getDay(){return(e=this.abs())-(t=7)*Math.floor(e/t);var e,t}setFullYear(e){return this.year=e,I(this),this}setMonth(e){return this.month=D.monthNum(e),I(this),this}setDate(e){return this.day=e,I(this),this}greg(){return o.abs2greg(this.abs())}abs(){return"number"!=typeof this.abs0&&(this.abs0=D.hebrew2abs(this.year,this.month,this.day)),this.abs0}static hebrew2abs(e,t,r){let a=r;if(t<7){for(let t=7;t<=D.monthsInYear(e);t++)a+=D.daysInMonth(t,e);for(let r=1;r<t;r++)a+=D.daysInMonth(r,e)}else for(let r=7;r<t;r++)a+=D.daysInMonth(r,e);return f+D.elapsedDays(e)+a-1}static newYear(e){return f+D.elapsedDays(e)+D.newYearDelay(e)}static newYearDelay(e){const t=D.elapsedDays(e);if(D.elapsedDays(e+1)-t==356)return 2;return t-D.elapsedDays(e-1)==382?1:0}static abs2hebrew(e){if("number"!=typeof e||isNaN(e))throw new TypeError("invalid parameter to abs2hebrew ".concat(e));let t=1+Math.floor((e-f)/365.24682220597794)-1;for(;D.newYear(t)<=e;)++t;--t;let r=e<D.hebrew2abs(t,1,1)?7:1;for(;e>D.hebrew2abs(t,r,D.daysInMonth(r,t));)++r;return{yy:t,mm:r,dd:Math.floor(1+e-D.hebrew2abs(t,r,1))}}getMonthName(){return D.getMonthName(this.getMonth(),this.getFullYear())}render(e){const t=e||c.getLocaleName(),r=this.getDate(),a=this.getFullYear(),n=c.gettext(this.getMonthName(),e),s=c.ordinal(r,t);let o="";if("en"==t||"ashkenazi"==t.substring(0,9))o=" of";else{const e=c.lookupTranslation("of",t);e&&(o=" "+e)}return"".concat(s).concat(o," ").concat(n,", ").concat(a)}renderGematriya(){const e=this.getDate(),t=c.gettext(this.getMonthName(),"he"),a=this.getFullYear();return r(e)+" "+t+" "+r(a)}before(e){return v(e,this,-1)}onOrBefore(e){return v(e,this,0)}nearest(e){return v(e,this,3)}onOrAfter(e){return v(e,this,6)}after(e){return v(e,this,7)}next(){return new D(this.abs()+1)}prev(){return new D(this.abs()-1)}add(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"d";if(!(e=parseInt(e,10)))return new D(this);if(t=D.standardizeUnits(t),t===m)return new D(this.abs()+e);if(t===g)return new D(this.abs()+7*e);if(t===b)return new D(this.getDate(),this.getMonth(),this.getFullYear()+e);if(t===p){let t=new D(this);const r=e>0?1:-1;e=Math.abs(e);for(let a=0;a<e;a++)t=new D(t.abs()+r*t.daysInMonth());return t}}static standardizeUnits(e){const t=w[e]||String(e||"").toLowerCase().replace(/s$/,"");return M[t]||y("Invalid units '".concat(e,"'"))}subtract(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"d";return this.add(-1*e,t)}deltaDays(e){if(!D.isHDate(e))throw new TypeError("Bad argument: ".concat(e));return this.abs()-e.abs()}isSameDate(e){return!!D.isHDate(e)&&(this.year==e.year&&this.month==e.month&&this.day==e.day)}toString(){const e=this.getDate(),t=this.getFullYear(),r=this.getMonthName();return"".concat(e," ").concat(r," ").concat(t)}static isLeapYear(e){return(1+7*e)%19<7}static monthsInYear(e){return 12+D.isLeapYear(e)}static daysInMonth(e,t){return 2==e||4==e||6==e||10==e||13==e||12==e&&!D.isLeapYear(t)||8==e&&!D.longCheshvan(t)||9==e&&D.shortKislev(t)?29:30}static getMonthName(e,t){if("number"!=typeof e||e<1||e>14)throw new TypeError("bad month argument ".concat(e));return l[+D.isLeapYear(t)][e]}static monthNum(e){return"number"==typeof e?e:e.charCodeAt(0)>=48&&e.charCodeAt(0)<=57?parseInt(e,10):D.monthFromName(e)}static elapsedDays(e){return d[e]=d[e]||D.elapsedDays0(e)}static elapsedDays0(e){const t=e-1,r=235*Math.floor(t/19)+t%19*12+Math.floor((t%19*7+1)/19),a=204+r%1080*793,n=5+12*r+793*Math.floor(r/1080)+Math.floor(a/1080),s=a%1080+n%24*1080,o=1+29*r+Math.floor(n/24),i=o+(s>=19440||2==o%7&&s>=9924&&!D.isLeapYear(e)||1==o%7&&s>=16789&&D.isLeapYear(t));return i+(i%7==0||i%7==3||i%7==5)}static daysInYear(e){return D.elapsedDays(e+1)-D.elapsedDays(e)}static longCheshvan(e){return D.daysInYear(e)%10==5}static shortKislev(e){return D.daysInYear(e)%10==3}static monthFromName(e){if("number"==typeof e)return e;const t=e.toLowerCase();switch(t[0]){case"n":case"נ":if("o"==t[1])break;return 1;case"i":return 2;case"e":return 6;case"c":case"ח":return 8;case"k":case"כ":return 9;case"s":switch(t[1]){case"i":return 3;case"h":return 11}case"t":switch(t[1]){case"a":return 4;case"i":return 7;case"e":return 10}break;case"a":switch(t[1]){case"v":return 5;case"d":return/(1|[^i]i|a|א)$/i.test(e)?12:13}break;case"ס":return 3;case"ט":return 10;case"ש":return 11;case"א":switch(t[1]){case"ב":return 5;case"ד":return/(1|[^i]i|a|א)$/i.test(e)?12:13;case"י":return 2;case"ל":return 6}break;case"ת":switch(t[1]){case"מ":return 4;case"ש":return 7}}throw new RangeError("Unable to parse month name: ".concat(e))}static dayOnOrBefore(e,t){return t-(t-e)%7}static isHDate(e){return null!==e&&"object"==typeof e&&"number"==typeof e.year&&"number"==typeof e.month&&"number"==typeof e.day&&"function"==typeof e.greg&&"function"==typeof e.abs}}function I(e){Y(e),function(e){e.day<1&&(7==e.month&&(e.year-=1),e.day+=D.daysInMonth(e.month,e.year),e.month-=1,I(e));e.day>D.daysInMonth(e.month,e.year)&&(6==e.month&&(e.year+=1),e.day-=D.daysInMonth(e.month,e.year),e.month+=1,I(e));Y(e)}(e)}function Y(e){13!=e.month||e.isLeapYear()?e.month<1?(e.month+=D.monthsInYear(e.year),e.year-=1,I(e)):e.month>D.monthsInYear(e.year)&&(e.month-=D.monthsInYear(e.year),e.year+=1,I(e)):(e.month-=1,I(e)),delete e.abs0}function v(e,t,r){return new D(D.dayOnOrBefore(e,t.abs()+r))}var L={headers:{"plural-forms":"nplurals=2; plural=(n > 1);",language:"he"},contexts:{"":{Adar:["אַדָר"],"Adar I":["אַדָר א׳"],"Adar II":["אַדָר ב׳"],Av:["אָב"],Cheshvan:["חֶשְׁוָן"],Elul:["אֱלוּל"],Iyyar:["אִיָיר"],Kislev:["כִּסְלֵו"],Nisan:["נִיסָן"],"Sh'vat":["שְׁבָט"],Sivan:["סִיוָן"],Tamuz:["תַּמּוּז"],Tevet:["טֵבֵת"],Tishrei:["תִשְׁרֵי"]}}};return c.addLocale("he",L),c.addLocale("h",L),e.HDate=D,e.Locale=c,e.gematriya=r,e.greg=o,e.months={NISAN:1,IYYAR:2,SIVAN:3,TAMUZ:4,AV:5,ELUL:6,TISHREI:7,CHESHVAN:8,KISLEV:9,TEVET:10,SHVAT:11,ADAR_I:12,ADAR_II:13},e.version="3.26.2",Object.defineProperty(e,"__esModule",{value:!0}),e}({});
|
|
1
|
+
/*! @hebcal/core v3.26.6 */
|
|
2
|
+
var hebcal=function(t){"use strict";var e="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},r=function(t){return t&&t.Math==Math&&t},n=r("object"==typeof globalThis&&globalThis)||r("object"==typeof window&&window)||r("object"==typeof self&&self)||r("object"==typeof e&&e)||function(){return this}()||Function("return this")(),a={},o=function(t){try{return!!t()}catch(t){return!0}},i=!o((function(){return 7!=Object.defineProperty({},1,{get:function(){return 7}})[1]})),s={},u={}.propertyIsEnumerable,c=Object.getOwnPropertyDescriptor,h=c&&!u.call({1:2},1);s.f=h?function(t){var e=c(this,t);return!!e&&e.enumerable}:u;var l,f,y=function(t,e){return{enumerable:!(1&t),configurable:!(2&t),writable:!(4&t),value:e}},d={}.toString,p=function(t){return d.call(t).slice(8,-1)},g=p,m="".split,b=function(t){if(null==t)throw TypeError("Can't call method on "+t);return t},v=o((function(){return!Object("z").propertyIsEnumerable(0)}))?function(t){return"String"==g(t)?m.call(t,""):Object(t)}:Object,w=b,S=function(t){return v(w(t))},M=function(t){return"function"==typeof t},I=M,O=function(t){return"object"==typeof t?null!==t:I(t)},D=n,E=M,L=function(t){return E(t)?t:void 0},T=function(t,e){return arguments.length<2?L(D[t]):D[t]&&D[t][e]},Y=n,N=T("navigator","userAgent")||"",j=Y.process,A=Y.Deno,F=j&&j.versions||A&&A.version,x=F&&F.v8;x?f=(l=x.split("."))[0]<4?1:l[0]+l[1]:N&&(!(l=N.match(/Edge\/(\d+)/))||l[1]>=74)&&(l=N.match(/Chrome\/(\d+)/))&&(f=l[1]);var k=f&&+f,P=o,C=!!Object.getOwnPropertySymbols&&!P((function(){var t=Symbol();return!String(t)||!(Object(t)instanceof Symbol)||!Symbol.sham&&k&&k<41})),_=C&&!Symbol.sham&&"symbol"==typeof Symbol.iterator,z=M,H=T,R=_?function(t){return"symbol"==typeof t}:function(t){var e=H("Symbol");return z(e)&&Object(t)instanceof e},U=M,V=function(t){try{return String(t)}catch(t){return"Object"}},B=function(t){if(U(t))return t;throw TypeError(V(t)+" is not a function")},K=M,G=O,$={exports:{}},J=n,q=function(t,e){try{Object.defineProperty(J,t,{value:e,configurable:!0,writable:!0})}catch(r){J[t]=e}return e},W=q,X="__core-js_shared__",Z=n[X]||W(X,{}),Q=Z;($.exports=function(t,e){return Q[t]||(Q[t]=void 0!==e?e:{})})("versions",[]).push({version:"3.18.3",mode:"global",copyright:"© 2021 Denis Pushkarev (zloirock.ru)"});var tt=b,et=function(t){return Object(tt(t))},rt={}.hasOwnProperty,nt=Object.hasOwn||function(t,e){return rt.call(et(t),e)},at=0,ot=Math.random(),it=function(t){return"Symbol("+String(void 0===t?"":t)+")_"+(++at+ot).toString(36)},st=n,ut=$.exports,ct=nt,ht=it,lt=C,ft=_,yt=ut("wks"),dt=st.Symbol,pt=ft?dt:dt&&dt.withoutSetter||ht,gt=function(t){return ct(yt,t)&&(lt||"string"==typeof yt[t])||(lt&&ct(dt,t)?yt[t]=dt[t]:yt[t]=pt("Symbol."+t)),yt[t]},mt=O,bt=R,vt=function(t,e){var r=t[e];return null==r?void 0:B(r)},wt=function(t,e){var r,n;if("string"===e&&K(r=t.toString)&&!G(n=r.call(t)))return n;if(K(r=t.valueOf)&&!G(n=r.call(t)))return n;if("string"!==e&&K(r=t.toString)&&!G(n=r.call(t)))return n;throw TypeError("Can't convert object to primitive value")},St=gt("toPrimitive"),Mt=function(t,e){if(!mt(t)||bt(t))return t;var r,n=vt(t,St);if(n){if(void 0===e&&(e="default"),r=n.call(t,e),!mt(r)||bt(r))return r;throw TypeError("Can't convert object to primitive value")}return void 0===e&&(e="number"),wt(t,e)},It=R,Ot=function(t){var e=Mt(t,"string");return It(e)?e:String(e)},Dt=O,Et=n.document,Lt=Dt(Et)&&Dt(Et.createElement),Tt=function(t){return Lt?Et.createElement(t):{}},Yt=!i&&!o((function(){return 7!=Object.defineProperty(Tt("div"),"a",{get:function(){return 7}}).a})),Nt=i,jt=s,At=y,Ft=S,xt=Ot,kt=nt,Pt=Yt,Ct=Object.getOwnPropertyDescriptor;a.f=Nt?Ct:function(t,e){if(t=Ft(t),e=xt(e),Pt)try{return Ct(t,e)}catch(t){}if(kt(t,e))return At(!jt.f.call(t,e),t[e])};var _t={},zt=O,Ht=function(t){if(zt(t))return t;throw TypeError(String(t)+" is not an object")},Rt=i,Ut=Yt,Vt=Ht,Bt=Ot,Kt=Object.defineProperty;_t.f=Rt?Kt:function(t,e,r){if(Vt(t),e=Bt(e),Vt(r),Ut)try{return Kt(t,e,r)}catch(t){}if("get"in r||"set"in r)throw TypeError("Accessors not supported");return"value"in r&&(t[e]=r.value),t};var Gt=_t,$t=y,Jt=i?function(t,e,r){return Gt.f(t,e,$t(1,r))}:function(t,e,r){return t[e]=r,t},qt={exports:{}},Wt=M,Xt=Z,Zt=Function.toString;Wt(Xt.inspectSource)||(Xt.inspectSource=function(t){return Zt.call(t)});var Qt,te,ee,re=Xt.inspectSource,ne=M,ae=re,oe=n.WeakMap,ie=ne(oe)&&/native code/.test(ae(oe)),se=$.exports,ue=it,ce=se("keys"),he={},le=ie,fe=O,ye=Jt,de=nt,pe=Z,ge=function(t){return ce[t]||(ce[t]=ue(t))},me=he,be="Object already initialized",ve=n.WeakMap;if(le||pe.state){var we=pe.state||(pe.state=new ve),Se=we.get,Me=we.has,Ie=we.set;Qt=function(t,e){if(Me.call(we,t))throw new TypeError(be);return e.facade=t,Ie.call(we,t,e),e},te=function(t){return Se.call(we,t)||{}},ee=function(t){return Me.call(we,t)}}else{var Oe=ge("state");me[Oe]=!0,Qt=function(t,e){if(de(t,Oe))throw new TypeError(be);return e.facade=t,ye(t,Oe,e),e},te=function(t){return de(t,Oe)?t[Oe]:{}},ee=function(t){return de(t,Oe)}}var De={set:Qt,get:te,has:ee,enforce:function(t){return ee(t)?te(t):Qt(t,{})},getterFor:function(t){return function(e){var r;if(!fe(e)||(r=te(e)).type!==t)throw TypeError("Incompatible receiver, "+t+" required");return r}}},Ee=i,Le=nt,Te=Function.prototype,Ye=Ee&&Object.getOwnPropertyDescriptor,Ne=Le(Te,"name"),je=Ne&&"something"===function(){}.name,Ae=Ne&&(!Ee||Ee&&Ye(Te,"name").configurable),Fe=n,xe=M,ke=nt,Pe=Jt,Ce=q,_e=re,ze={EXISTS:Ne,PROPER:je,CONFIGURABLE:Ae}.CONFIGURABLE,He=De.get,Re=De.enforce,Ue=String(String).split("String");(qt.exports=function(t,e,r,n){var a,o=!!n&&!!n.unsafe,i=!!n&&!!n.enumerable,s=!!n&&!!n.noTargetGet,u=n&&void 0!==n.name?n.name:e;xe(r)&&("Symbol("===String(u).slice(0,7)&&(u="["+String(u).replace(/^Symbol\(([^)]*)\)/,"$1")+"]"),(!ke(r,"name")||ze&&r.name!==u)&&Pe(r,"name",u),(a=Re(r)).source||(a.source=Ue.join("string"==typeof u?u:""))),t!==Fe?(o?!s&&t[e]&&(i=!0):delete t[e],i?t[e]=r:Pe(t,e,r)):i?t[e]=r:Ce(e,r)})(Function.prototype,"toString",(function(){return xe(this)&&He(this).source||_e(this)}));var Ve={},Be=Math.ceil,Ke=Math.floor,Ge=function(t){var e=+t;return e!=e||0===e?0:(e>0?Ke:Be)(e)},$e=Ge,Je=Math.max,qe=Math.min,We=Ge,Xe=Math.min,Ze=function(t){return t>0?Xe(We(t),9007199254740991):0},Qe=S,tr=function(t,e){var r=$e(t);return r<0?Je(r+e,0):qe(r,e)},er=function(t){return Ze(t.length)},rr=function(t){return function(e,r,n){var a,o=Qe(e),i=er(o),s=tr(n,i);if(t&&r!=r){for(;i>s;)if((a=o[s++])!=a)return!0}else for(;i>s;s++)if((t||s in o)&&o[s]===r)return t||s||0;return!t&&-1}},nr={includes:rr(!0),indexOf:rr(!1)},ar=nt,or=S,ir=nr.indexOf,sr=he,ur=function(t,e){var r,n=or(t),a=0,o=[];for(r in n)!ar(sr,r)&&ar(n,r)&&o.push(r);for(;e.length>a;)ar(n,r=e[a++])&&(~ir(o,r)||o.push(r));return o},cr=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"].concat("length","prototype");Ve.f=Object.getOwnPropertyNames||function(t){return ur(t,cr)};var hr={};hr.f=Object.getOwnPropertySymbols;var lr=Ve,fr=hr,yr=Ht,dr=T("Reflect","ownKeys")||function(t){var e=lr.f(yr(t)),r=fr.f;return r?e.concat(r(t)):e},pr=nt,gr=dr,mr=a,br=_t,vr=o,wr=M,Sr=/#|\.prototype\./,Mr=function(t,e){var r=Or[Ir(t)];return r==Er||r!=Dr&&(wr(e)?vr(e):!!e)},Ir=Mr.normalize=function(t){return String(t).replace(Sr,".").toLowerCase()},Or=Mr.data={},Dr=Mr.NATIVE="N",Er=Mr.POLYFILL="P",Lr=Mr,Tr=n,Yr=a.f,Nr=Jt,jr=qt.exports,Ar=q,Fr=function(t,e){for(var r=gr(e),n=br.f,a=mr.f,o=0;o<r.length;o++){var i=r[o];pr(t,i)||n(t,i,a(e,i))}},xr=Lr,kr={};kr[gt("toStringTag")]="z";var Pr="[object z]"===String(kr),Cr=M,_r=p,zr=gt("toStringTag"),Hr="Arguments"==_r(function(){return arguments}()),Rr=Pr?_r:function(t){var e,r,n;return void 0===t?"Undefined":null===t?"Null":"string"==typeof(r=function(t,e){try{return t[e]}catch(t){}}(e=Object(t),zr))?r:Hr?_r(e):"Object"==(n=_r(e))&&Cr(e.callee)?"Arguments":n},Ur=function(t){if("Symbol"===Rr(t))throw TypeError("Cannot convert a Symbol value to a string");return String(t)},Vr="\t\n\v\f\r \u2028\u2029\ufeff",Br=b,Kr=Ur,Gr="[\t\n\v\f\r \u2028\u2029\ufeff]",$r=RegExp("^"+Gr+Gr+"*"),Jr=RegExp(Gr+Gr+"*$"),qr=function(t){return function(e){var r=Kr(Br(e));return 1&t&&(r=r.replace($r,"")),2&t&&(r=r.replace(Jr,"")),r}},Wr={start:qr(1),end:qr(2),trim:qr(3)},Xr=n,Zr=o,Qr=Ur,tn=Wr.trim,en=Vr,rn=Xr.parseInt,nn=Xr.Symbol,an=nn&&nn.iterator,on=/^[+-]?0x/i,sn=8!==rn(en+"08")||22!==rn(en+"0x16")||an&&!Zr((function(){rn(Object(an))}))?function(t,e){var r=tn(Qr(t));return rn(r,e>>>0||(on.test(r)?16:10))}:rn;(function(t,e){var r,n,a,o,i,s=t.target,u=t.global,c=t.stat;if(r=u?Tr:c?Tr[s]||Ar(s,{}):(Tr[s]||{}).prototype)for(n in e){if(o=e[n],a=t.noTargetGet?(i=Yr(r,n))&&i.value:r[n],!xr(u?n:s+(c?".":"#")+n,t.forced)&&void 0!==a){if(typeof o==typeof a)continue;Fr(o,a)}(t.sham||a&&a.sham)&&Nr(o,"sham",!0),jr(r,n,o,t)}})({global:!0,forced:parseInt!=sn},{parseInt:sn});function un(t){switch(t){case 1:return"א";case 2:return"ב";case 3:return"ג";case 4:return"ד";case 5:return"ה";case 6:return"ו";case 7:return"ז";case 8:return"ח";case 9:return"ט";case 10:return"י";case 20:return"כ";case 30:return"ל";case 40:return"מ";case 50:return"נ";case 60:return"ס";case 70:return"ע";case 80:return"פ";case 90:return"צ";case 100:return"ק";case 200:return"ר";case 300:return"ש";case 400:return"ת";default:return"*INVALID*"}}function cn(t){let e=parseInt(t,10);if(!e)throw new TypeError("invalid parameter to gematriya ".concat(t));const r=[];for(e%=1e3;e>0;){if(15===e||16===e){r.push(9),r.push(e-9);break}let t,n=100;for(t=400;t>e;t-=n)t===n&&(n/=10);r.push(t),e-=t}if(1==r.length)return un(r[0])+"׳";let n="";for(let t=0;t<r.length;t++)t+1===r.length&&(n+="״"),n+=un(r[t]);return n}const hn=[[0,31,28,31,30,31,30,31,31,30,31,30,31],[0,31,29,31,30,31,30,31,31,30,31,30,31]];function ln(t,e){return t-e*Math.floor(t/e)}function fn(t,e){return Math.floor(t/e)}const yn={monthNames:["","January","February","March","April","May","June","July","August","September","October","November","December"],isLeapYear:function(t){return!(t%4||!(t%100)&&t%400)},daysInMonth:function(t,e){return hn[+this.isLeapYear(e)][t]},isDate:function(t){return"object"==typeof t&&Date.prototype===t.__proto__},dayOfYear:function(t){if(!this.isDate(t))throw new TypeError("Argument to greg.dayOfYear not a Date");let e=t.getDate()+31*t.getMonth();return t.getMonth()>1&&(e-=Math.floor((4*(t.getMonth()+1)+23)/10),this.isLeapYear(t.getFullYear())&&e++),e},greg2abs:function(t){if(!this.isDate(t))throw new TypeError("Argument to greg.greg2abs not a Date");const e=t.getFullYear()-1;return this.dayOfYear(t)+365*e+(Math.floor(e/4)-Math.floor(e/100)+Math.floor(e/400))},yearFromFixed:function(t){const e=t-1,r=fn(e,146097),n=ln(e,146097),a=fn(n,36524),o=ln(n,36524),i=fn(o,1461),s=fn(ln(o,1461),365),u=400*r+100*a+4*i+s;return 4!=a&&4!=s?u+1:u},toFixed:function(t,e,r){const n=t-1;return 0+365*n+fn(n,4)-fn(n,100)+fn(n,400)+fn(367*e-362,12)+Math.floor(e<=2?0:this.isLeapYear(t)?-1:-2)+r},abs2greg:function(t){if("number"!=typeof t)throw new TypeError("Argument to greg.abs2greg not a Number");t=Math.trunc(t);const e=this.yearFromFixed(t),r=fn(12*(t-this.toFixed(e,1,1)+(t<this.toFixed(e,3,1)?0:this.isLeapYear(e)?1:2))+373,367),n=t-this.toFixed(e,r,1)+1,a=new Date(e,r-1,n);return e<100&&e>=0&&a.setFullYear(e),a}},dn={headers:{"plural-forms":"nplurals=2; plural=(n!=1);"},contexts:{"":{}}},pn={h:"he",a:"ashkenazi",s:"en","":"en"},gn={locales:Object.create(null),activeLocale:null,activeName:null,lookupTranslation:function(t,e){const r=("string"==typeof e&&this.locales[e]||this.activeLocale)[t];if(r&&r.length&&r[0].length)return r[0]},gettext:function(t,e){const r=this.lookupTranslation(t,e);return void 0===r?t:r},addLocale:function(t,e){if("object"!=typeof e.contexts||"object"!=typeof e.contexts[""])throw new Error("Locale '".concat(t,"' invalid compact format"));this.locales[t.toLowerCase()]=e.contexts[""]},useLocale:function(t){const e=t.toLowerCase(),r=this.locales[e];if(!r)throw new Error("Locale '".concat(t,"' not found"));return this.activeName=pn[e]||e,this.activeLocale=r,this.activeLocale},getLocaleName:function(){return this.activeName},ordinal:function(t,e){const r=e||this.activeName;return r&&"en"!==r&&"s"!==r&&"ashkenazi"!==r.substring(0,9)?"es"==r?t+"º":"he"==r?String(t):t+".":this.getEnOrdinal(t)},getEnOrdinal:function(t){const e=["th","st","nd","rd"],r=t%100;return t+(e[(r-20)%10]||e[r]||e[0])},hebrewStripNikkud:function(t){return t.replace(/[\u0590-\u05bd]/g,"").replace(/[\u05bf-\u05c7]/g,"")}};gn.addLocale("en",dn),gn.addLocale("s",dn),gn.addLocale("",dn),gn.useLocale("en");const mn=["","Nisan","Iyyar","Sivan","Tamuz","Av","Elul","Tishrei","Cheshvan","Kislev","Tevet","Sh'vat"],bn=[mn.concat(["Adar","Nisan"]),mn.concat(["Adar I","Adar II","Nisan"])];function vn(t){throw new TypeError(t)}const wn=Object.create(null),Sn=-1373428,Mn="day",In="week",On="month",Dn="year",En={d:Mn,w:In,M:On,y:Dn},Ln={day:Mn,week:In,month:On,year:Dn};class Tn{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,this.year=+r,isNaN(this.year))throw new TypeError("HDate called with bad year argument: ".concat(r));if(this.setMonth(e),this.setDate(+t),isNaN(this.day))throw new TypeError("HDate called with bad day argument: ".concat(t))}else{void 0===t&&(t=new Date);const e="number"!=typeof t||isNaN(t)?yn.isDate(t)?yn.greg2abs(t):Tn.isHDate(t)?{dd:t.day,mm:t.month,yy:t.year}:vn("HDate called with bad argument: ".concat(t)):t,r="number"==typeof e,n=r?Tn.abs2hebrew(e):e;this.day=n.dd,this.month=n.mm,this.year=n.yy,r&&(this.abs0=e)}}getFullYear(){return this.year}isLeapYear(){return Tn.isLeapYear(this.year)}getMonth(){return this.month}getTishreiMonth(){const t=Tn.monthsInYear(this.getFullYear());return(this.getMonth()+t-6)%t||t}daysInMonth(){return Tn.daysInMonth(this.getMonth(),this.getFullYear())}getDate(){return this.day}getDay(){return ln(this.abs(),7)}setFullYear(t){return this.year=t,Yn(this),this}setMonth(t){return this.month=Tn.monthNum(t),Yn(this),this}setDate(t){return this.day=t,Yn(this),this}greg(){return yn.abs2greg(this.abs())}abs(){return"number"!=typeof this.abs0&&(this.abs0=Tn.hebrew2abs(this.year,this.month,this.day)),this.abs0}static hebrew2abs(t,e,r){let n=r;if(e<7){for(let e=7;e<=Tn.monthsInYear(t);e++)n+=Tn.daysInMonth(e,t);for(let r=1;r<e;r++)n+=Tn.daysInMonth(r,t)}else for(let r=7;r<e;r++)n+=Tn.daysInMonth(r,t);return Sn+Tn.elapsedDays(t)+n-1}static newYear(t){return Sn+Tn.elapsedDays(t)+Tn.newYearDelay(t)}static newYearDelay(t){const e=Tn.elapsedDays(t);if(Tn.elapsedDays(t+1)-e==356)return 2;return e-Tn.elapsedDays(t-1)==382?1:0}static abs2hebrew(t){if("number"!=typeof t||isNaN(t))throw new TypeError("invalid parameter to abs2hebrew ".concat(t));t=Math.trunc(t);let e=Math.floor((t-Sn)/365.24682220597794);for(;Tn.newYear(e)<=t;)++e;--e;let r=t<Tn.hebrew2abs(e,1,1)?7:1;for(;t>Tn.hebrew2abs(e,r,Tn.daysInMonth(r,e));)++r;return{yy:e,mm:r,dd:1+t-Tn.hebrew2abs(e,r,1)}}getMonthName(){return Tn.getMonthName(this.getMonth(),this.getFullYear())}render(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null,e=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];const r=t||gn.getLocaleName(),n=this.getDate(),a=gn.gettext(this.getMonthName(),t),o=gn.ordinal(n,r);let i="";if("en"===r||"s"===r||"ashkenazi"==r.substring(0,9))i=" of";else{const t=gn.lookupTranslation("of",r);t&&(i=" "+t)}const s="".concat(o).concat(i," ").concat(a);if(e){const t=this.getFullYear();return"".concat(s,", ").concat(t)}return s}renderGematriya(){const t=this.getDate(),e=gn.gettext(this.getMonthName(),"he"),r=this.getFullYear();return cn(t)+" "+e+" "+cn(r)}before(t){return jn(t,this,-1)}onOrBefore(t){return jn(t,this,0)}nearest(t){return jn(t,this,3)}onOrAfter(t){return jn(t,this,6)}after(t){return jn(t,this,7)}next(){return new Tn(this.abs()+1)}prev(){return new Tn(this.abs()-1)}add(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"d";if(!(t=parseInt(t,10)))return new Tn(this);if(e=Tn.standardizeUnits(e),e===Mn)return new Tn(this.abs()+t);if(e===In)return new Tn(this.abs()+7*t);if(e===Dn)return new Tn(this.getDate(),this.getMonth(),this.getFullYear()+t);if(e===On){let e=new Tn(this);const r=t>0?1:-1;t=Math.abs(t);for(let n=0;n<t;n++)e=new Tn(e.abs()+r*e.daysInMonth());return e}}static standardizeUnits(t){const e=En[t]||String(t||"").toLowerCase().replace(/s$/,"");return Ln[e]||vn("Invalid units '".concat(t,"'"))}subtract(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"d";return this.add(-1*t,e)}deltaDays(t){if(!Tn.isHDate(t))throw new TypeError("Bad argument: ".concat(t));return this.abs()-t.abs()}isSameDate(t){return!!Tn.isHDate(t)&&(this.year==t.year&&this.month==t.month&&this.day==t.day)}toString(){const t=this.getDate(),e=this.getFullYear(),r=this.getMonthName();return"".concat(t," ").concat(r," ").concat(e)}static isLeapYear(t){return(1+7*t)%19<7}static monthsInYear(t){return 12+Tn.isLeapYear(t)}static daysInMonth(t,e){return 2==t||4==t||6==t||10==t||13==t||12==t&&!Tn.isLeapYear(e)||8==t&&!Tn.longCheshvan(e)||9==t&&Tn.shortKislev(e)?29:30}static getMonthName(t,e){if("number"!=typeof t||t<1||t>14)throw new TypeError("bad month argument ".concat(t));return bn[+Tn.isLeapYear(e)][t]}static monthNum(t){return"number"==typeof t?t:t.charCodeAt(0)>=48&&t.charCodeAt(0)<=57?parseInt(t,10):Tn.monthFromName(t)}static elapsedDays(t){return wn[t]=wn[t]||Tn.elapsedDays0(t)}static elapsedDays0(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,i=1+29*r+Math.floor(a/24),s=i+(o>=19440||2==i%7&&o>=9924&&!Tn.isLeapYear(t)||1==i%7&&o>=16789&&Tn.isLeapYear(e));return s+(s%7==0||s%7==3||s%7==5)}static daysInYear(t){return Tn.elapsedDays(t+1)-Tn.elapsedDays(t)}static longCheshvan(t){return Tn.daysInYear(t)%10==5}static shortKislev(t){return Tn.daysInYear(t)%10==3}static monthFromName(t){if("number"==typeof t)return t;const e=t.toLowerCase();switch(e[0]){case"n":case"נ":if("o"==e[1])break;return 1;case"i":return 2;case"e":return 6;case"c":case"ח":return 8;case"k":case"כ":return 9;case"s":switch(e[1]){case"i":return 3;case"h":return 11}case"t":switch(e[1]){case"a":return 4;case"i":return 7;case"e":return 10}break;case"a":switch(e[1]){case"v":return 5;case"d":return/(1|[^i]i|a|א)$/i.test(t)?12:13}break;case"ס":return 3;case"ט":return 10;case"ש":return 11;case"א":switch(e[1]){case"ב":return 5;case"ד":return/(1|[^i]i|a|א)$/i.test(t)?12:13;case"י":return 2;case"ל":return 6}break;case"ת":switch(e[1]){case"מ":return 4;case"ש":return 7}}throw new RangeError("Unable to parse month name: ".concat(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}}function Yn(t){Nn(t),function(t){t.day<1&&(7==t.month&&(t.year-=1),t.day+=Tn.daysInMonth(t.month,t.year),t.month-=1,Yn(t));t.day>Tn.daysInMonth(t.month,t.year)&&(6==t.month&&(t.year+=1),t.day-=Tn.daysInMonth(t.month,t.year),t.month+=1,Yn(t));Nn(t)}(t)}function Nn(t){13!=t.month||t.isLeapYear()?t.month<1?(t.month+=Tn.monthsInYear(t.year),t.year-=1,Yn(t)):t.month>Tn.monthsInYear(t.year)&&(t.month-=Tn.monthsInYear(t.year),t.year+=1,Yn(t)):(t.month-=1,Yn(t)),delete t.abs0}function jn(t,e,r){return new Tn(Tn.dayOnOrBefore(t,e.abs()+r))}var An={headers:{"plural-forms":"nplurals=2; plural=(n > 1);",language:"he"},contexts:{"":{Adar:["אַדָר"],"Adar I":["אַדָר א׳"],"Adar II":["אַדָר ב׳"],Av:["אָב"],Cheshvan:["חֶשְׁוָן"],Elul:["אֱלוּל"],Iyyar:["אִיָיר"],Kislev:["כִּסְלֵו"],Nisan:["נִיסָן"],"Sh'vat":["שְׁבָט"],Sivan:["סִיוָן"],Tamuz:["תַּמּוּז"],Tevet:["טֵבֵת"],Tishrei:["תִשְׁרֵי"]}}};return gn.addLocale("he",An),gn.addLocale("h",An),t.HDate=Tn,t.Locale=gn,t.gematriya=cn,t.greg=yn,t.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},t.version="3.26.6",Object.defineProperty(t,"__esModule",{value:!0}),t}({});
|
package/dist/hdate.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! @hebcal/core v3.26.
|
|
1
|
+
/*! @hebcal/core v3.26.6 */
|
|
2
2
|
'use strict';
|
|
3
3
|
|
|
4
4
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
@@ -84,7 +84,9 @@ function num2heb(num) {
|
|
|
84
84
|
}
|
|
85
85
|
}
|
|
86
86
|
/**
|
|
87
|
-
*
|
|
87
|
+
* Converts a numerical value to a string of Hebrew letters
|
|
88
|
+
* @example
|
|
89
|
+
* gematriya(5774) // תשע״ד - cropped to 774
|
|
88
90
|
* @param {number} number
|
|
89
91
|
* @return {string}
|
|
90
92
|
*/
|
|
@@ -165,7 +167,7 @@ const monthLengths = [[0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31], [0, 3
|
|
|
165
167
|
* @return {number}
|
|
166
168
|
*/
|
|
167
169
|
|
|
168
|
-
function mod
|
|
170
|
+
function mod(x, y) {
|
|
169
171
|
return x - y * Math.floor(x / y);
|
|
170
172
|
}
|
|
171
173
|
/**
|
|
@@ -175,7 +177,6 @@ function mod$1(x, y) {
|
|
|
175
177
|
* @return {number}
|
|
176
178
|
*/
|
|
177
179
|
|
|
178
|
-
|
|
179
180
|
function quotient(x, y) {
|
|
180
181
|
return Math.floor(x / y);
|
|
181
182
|
}
|
|
@@ -258,7 +259,8 @@ const greg = {
|
|
|
258
259
|
|
|
259
260
|
const year = date.getFullYear() - 1;
|
|
260
261
|
return this.dayOfYear(date) + // days this year
|
|
261
|
-
365 * year + (
|
|
262
|
+
365 * year + ( // + days in prior years
|
|
263
|
+
Math.floor(year / 4) - // + Julian Leap years
|
|
262
264
|
Math.floor(year / 100) + // - century years
|
|
263
265
|
Math.floor(year / 400)); // + Gregorian leap years
|
|
264
266
|
},
|
|
@@ -271,11 +273,11 @@ const greg = {
|
|
|
271
273
|
yearFromFixed: function (theDate) {
|
|
272
274
|
const l0 = theDate - 1;
|
|
273
275
|
const n400 = quotient(l0, 146097);
|
|
274
|
-
const d1 = mod
|
|
276
|
+
const d1 = mod(l0, 146097);
|
|
275
277
|
const n100 = quotient(d1, 36524);
|
|
276
|
-
const d2 = mod
|
|
278
|
+
const d2 = mod(d1, 36524);
|
|
277
279
|
const n4 = quotient(d2, 1461);
|
|
278
|
-
const d3 = mod
|
|
280
|
+
const d3 = mod(d2, 1461);
|
|
279
281
|
const n1 = quotient(d3, 365);
|
|
280
282
|
const year = 400 * n400 + 100 * n100 + 4 * n4 + n1;
|
|
281
283
|
return n100 != 4 && n1 != 4 ? year + 1 : year;
|
|
@@ -307,6 +309,7 @@ const greg = {
|
|
|
307
309
|
throw new TypeError('Argument to greg.abs2greg not a Number');
|
|
308
310
|
}
|
|
309
311
|
|
|
312
|
+
theDate = Math.trunc(theDate);
|
|
310
313
|
const year = this.yearFromFixed(theDate);
|
|
311
314
|
const priorDays = theDate - this.toFixed(year, 1, 1);
|
|
312
315
|
const correction = theDate < this.toFixed(year, 3, 1) ? 0 : this.isLeapYear(year) ? 1 : 2;
|
|
@@ -438,10 +441,12 @@ const Locale = {
|
|
|
438
441
|
ordinal: function (n, locale) {
|
|
439
442
|
const locale0 = locale || this.activeName;
|
|
440
443
|
|
|
441
|
-
if (!locale0 || locale0 === 'en' || 'ashkenazi' === locale0.substring(0, 9)) {
|
|
444
|
+
if (!locale0 || locale0 === 'en' || locale0 === 's' || 'ashkenazi' === locale0.substring(0, 9)) {
|
|
442
445
|
return this.getEnOrdinal(n);
|
|
443
446
|
} else if (locale0 == 'es') {
|
|
444
447
|
return n + 'º';
|
|
448
|
+
} else if (locale0 == 'he') {
|
|
449
|
+
return String(n);
|
|
445
450
|
} else {
|
|
446
451
|
return n + '.';
|
|
447
452
|
}
|
|
@@ -565,7 +570,9 @@ function throwTypeError(msg) {
|
|
|
565
570
|
}
|
|
566
571
|
|
|
567
572
|
const edCache = Object.create(null);
|
|
568
|
-
const EPOCH = -1373428;
|
|
573
|
+
const EPOCH = -1373428; // Avg year length in the cycle (19 solar years with 235 lunar months)
|
|
574
|
+
|
|
575
|
+
const AVG_HEBYEAR_DAYS = 365.24682220597794;
|
|
569
576
|
const UNITS_DAY = 'day';
|
|
570
577
|
const UNITS_WEEK = 'week';
|
|
571
578
|
const UNITS_MONTH = 'month';
|
|
@@ -896,8 +903,9 @@ class HDate {
|
|
|
896
903
|
throw new TypeError(`invalid parameter to abs2hebrew ${abs}`);
|
|
897
904
|
}
|
|
898
905
|
|
|
899
|
-
|
|
900
|
-
|
|
906
|
+
abs = Math.trunc(abs); // first, quickly approximate year
|
|
907
|
+
|
|
908
|
+
let year = Math.floor((abs - EPOCH) / AVG_HEBYEAR_DAYS);
|
|
901
909
|
|
|
902
910
|
while (HDate.newYear(year) <= abs) {
|
|
903
911
|
++year;
|
|
@@ -910,7 +918,7 @@ class HDate {
|
|
|
910
918
|
++month;
|
|
911
919
|
}
|
|
912
920
|
|
|
913
|
-
const day =
|
|
921
|
+
const day = 1 + abs - HDate.hebrew2abs(year, month, 1);
|
|
914
922
|
return {
|
|
915
923
|
yy: year,
|
|
916
924
|
mm: month,
|
|
@@ -934,21 +942,21 @@ class HDate {
|
|
|
934
942
|
*
|
|
935
943
|
* const hd = new HDate(15, months.CHESHVAN, 5769);
|
|
936
944
|
* console.log(hd.render()); // '15th of Cheshvan, 5769'
|
|
937
|
-
* console.log(hd.render('he')); // '15
|
|
945
|
+
* console.log(hd.render('he')); // '15 חֶשְׁוָן, 5769'
|
|
938
946
|
* @param {string} [locale] Optional locale name (defaults to active locale).
|
|
947
|
+
* @param {boolean} [showYear=true] Display year (defaults to true).
|
|
939
948
|
* @return {string}
|
|
940
949
|
*/
|
|
941
950
|
|
|
942
951
|
|
|
943
|
-
render(locale) {
|
|
952
|
+
render(locale = null, showYear = true) {
|
|
944
953
|
const locale0 = locale || Locale.getLocaleName();
|
|
945
954
|
const day = this.getDate();
|
|
946
|
-
const fullYear = this.getFullYear();
|
|
947
955
|
const monthName = Locale.gettext(this.getMonthName(), locale);
|
|
948
956
|
const nth = Locale.ordinal(day, locale0);
|
|
949
957
|
let dayOf = '';
|
|
950
958
|
|
|
951
|
-
if (locale0
|
|
959
|
+
if (locale0 === 'en' || locale0 === 's' || 'ashkenazi' == locale0.substring(0, 9)) {
|
|
952
960
|
dayOf = ' of';
|
|
953
961
|
} else {
|
|
954
962
|
const ofStr = Locale.lookupTranslation('of', locale0);
|
|
@@ -958,7 +966,14 @@ class HDate {
|
|
|
958
966
|
}
|
|
959
967
|
}
|
|
960
968
|
|
|
961
|
-
|
|
969
|
+
const dateStr = `${nth}${dayOf} ${monthName}`;
|
|
970
|
+
|
|
971
|
+
if (showYear) {
|
|
972
|
+
const fullYear = this.getFullYear();
|
|
973
|
+
return `${dateStr}, ${fullYear}`;
|
|
974
|
+
} else {
|
|
975
|
+
return dateStr;
|
|
976
|
+
}
|
|
962
977
|
}
|
|
963
978
|
/**
|
|
964
979
|
* Renders this Hebrew date in Hebrew gematriya, regardless of locale.
|
|
@@ -1491,22 +1506,11 @@ class HDate {
|
|
|
1491
1506
|
}
|
|
1492
1507
|
|
|
1493
1508
|
}
|
|
1494
|
-
/**
|
|
1495
|
-
* @private
|
|
1496
|
-
* @param {number} x
|
|
1497
|
-
* @param {number} y
|
|
1498
|
-
* @return {number}
|
|
1499
|
-
*/
|
|
1500
|
-
|
|
1501
|
-
function mod(x, y) {
|
|
1502
|
-
return x - y * Math.floor(x / y);
|
|
1503
|
-
}
|
|
1504
1509
|
/**
|
|
1505
1510
|
* @private
|
|
1506
1511
|
* @param {HDate} date
|
|
1507
1512
|
*/
|
|
1508
1513
|
|
|
1509
|
-
|
|
1510
1514
|
function fix(date) {
|
|
1511
1515
|
fixMonth(date);
|
|
1512
1516
|
fixDate(date);
|
|
@@ -1576,9 +1580,9 @@ function onOrBefore(day, t, offset) {
|
|
|
1576
1580
|
return new HDate(HDate.dayOnOrBefore(day, t.abs() + offset));
|
|
1577
1581
|
}
|
|
1578
1582
|
|
|
1579
|
-
var version="3.26.
|
|
1583
|
+
var version="3.26.6";
|
|
1580
1584
|
|
|
1581
|
-
var headers={"plural-forms":"nplurals=2; plural=(n > 1);",language:"he"};var contexts={"":{Adar:["אַדָר"],"Adar I":["אַדָר א׳"],"Adar II":["אַדָר ב׳"],Av:["אָב"],Cheshvan:["חֶשְׁוָן"],Elul:["אֱלוּל"],Iyyar:["אִיָיר"],Kislev:["כִּסְלֵו"],Nisan:["נִיסָן"],"Sh'vat":["שְׁבָט"],Sivan:["סִיוָן"],Tamuz:["תַּמּוּז"],Tevet:["טֵבֵת"],Tishrei:["
|
|
1585
|
+
var headers={"plural-forms":"nplurals=2; plural=(n > 1);",language:"he"};var contexts={"":{Adar:["אַדָר"],"Adar I":["אַדָר א׳"],"Adar II":["אַדָר ב׳"],Av:["אָב"],Cheshvan:["חֶשְׁוָן"],Elul:["אֱלוּל"],Iyyar:["אִיָיר"],Kislev:["כִּסְלֵו"],Nisan:["נִיסָן"],"Sh'vat":["שְׁבָט"],Sivan:["סִיוָן"],Tamuz:["תַּמּוּז"],Tevet:["טֵבֵת"],Tishrei:["תִשְׁרֵי"]}};var poHeMin = {headers:headers,contexts:contexts};
|
|
1582
1586
|
|
|
1583
1587
|
Locale.addLocale('he', poHeMin);
|
|
1584
1588
|
Locale.addLocale('h', poHeMin);
|
package/dist/hdate.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! @hebcal/core v3.26.
|
|
1
|
+
/*! @hebcal/core v3.26.6 */
|
|
2
2
|
const GERESH = '׳';
|
|
3
3
|
const GERSHAYIM = '״';
|
|
4
4
|
/**
|
|
@@ -80,7 +80,9 @@ function num2heb(num) {
|
|
|
80
80
|
}
|
|
81
81
|
}
|
|
82
82
|
/**
|
|
83
|
-
*
|
|
83
|
+
* Converts a numerical value to a string of Hebrew letters
|
|
84
|
+
* @example
|
|
85
|
+
* gematriya(5774) // תשע״ד - cropped to 774
|
|
84
86
|
* @param {number} number
|
|
85
87
|
* @return {string}
|
|
86
88
|
*/
|
|
@@ -161,7 +163,7 @@ const monthLengths = [[0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31], [0, 3
|
|
|
161
163
|
* @return {number}
|
|
162
164
|
*/
|
|
163
165
|
|
|
164
|
-
function mod
|
|
166
|
+
function mod(x, y) {
|
|
165
167
|
return x - y * Math.floor(x / y);
|
|
166
168
|
}
|
|
167
169
|
/**
|
|
@@ -171,7 +173,6 @@ function mod$1(x, y) {
|
|
|
171
173
|
* @return {number}
|
|
172
174
|
*/
|
|
173
175
|
|
|
174
|
-
|
|
175
176
|
function quotient(x, y) {
|
|
176
177
|
return Math.floor(x / y);
|
|
177
178
|
}
|
|
@@ -254,7 +255,8 @@ const greg = {
|
|
|
254
255
|
|
|
255
256
|
const year = date.getFullYear() - 1;
|
|
256
257
|
return this.dayOfYear(date) + // days this year
|
|
257
|
-
365 * year + (
|
|
258
|
+
365 * year + ( // + days in prior years
|
|
259
|
+
Math.floor(year / 4) - // + Julian Leap years
|
|
258
260
|
Math.floor(year / 100) + // - century years
|
|
259
261
|
Math.floor(year / 400)); // + Gregorian leap years
|
|
260
262
|
},
|
|
@@ -267,11 +269,11 @@ const greg = {
|
|
|
267
269
|
yearFromFixed: function (theDate) {
|
|
268
270
|
const l0 = theDate - 1;
|
|
269
271
|
const n400 = quotient(l0, 146097);
|
|
270
|
-
const d1 = mod
|
|
272
|
+
const d1 = mod(l0, 146097);
|
|
271
273
|
const n100 = quotient(d1, 36524);
|
|
272
|
-
const d2 = mod
|
|
274
|
+
const d2 = mod(d1, 36524);
|
|
273
275
|
const n4 = quotient(d2, 1461);
|
|
274
|
-
const d3 = mod
|
|
276
|
+
const d3 = mod(d2, 1461);
|
|
275
277
|
const n1 = quotient(d3, 365);
|
|
276
278
|
const year = 400 * n400 + 100 * n100 + 4 * n4 + n1;
|
|
277
279
|
return n100 != 4 && n1 != 4 ? year + 1 : year;
|
|
@@ -303,6 +305,7 @@ const greg = {
|
|
|
303
305
|
throw new TypeError('Argument to greg.abs2greg not a Number');
|
|
304
306
|
}
|
|
305
307
|
|
|
308
|
+
theDate = Math.trunc(theDate);
|
|
306
309
|
const year = this.yearFromFixed(theDate);
|
|
307
310
|
const priorDays = theDate - this.toFixed(year, 1, 1);
|
|
308
311
|
const correction = theDate < this.toFixed(year, 3, 1) ? 0 : this.isLeapYear(year) ? 1 : 2;
|
|
@@ -434,10 +437,12 @@ const Locale = {
|
|
|
434
437
|
ordinal: function (n, locale) {
|
|
435
438
|
const locale0 = locale || this.activeName;
|
|
436
439
|
|
|
437
|
-
if (!locale0 || locale0 === 'en' || 'ashkenazi' === locale0.substring(0, 9)) {
|
|
440
|
+
if (!locale0 || locale0 === 'en' || locale0 === 's' || 'ashkenazi' === locale0.substring(0, 9)) {
|
|
438
441
|
return this.getEnOrdinal(n);
|
|
439
442
|
} else if (locale0 == 'es') {
|
|
440
443
|
return n + 'º';
|
|
444
|
+
} else if (locale0 == 'he') {
|
|
445
|
+
return String(n);
|
|
441
446
|
} else {
|
|
442
447
|
return n + '.';
|
|
443
448
|
}
|
|
@@ -561,7 +566,9 @@ function throwTypeError(msg) {
|
|
|
561
566
|
}
|
|
562
567
|
|
|
563
568
|
const edCache = Object.create(null);
|
|
564
|
-
const EPOCH = -1373428;
|
|
569
|
+
const EPOCH = -1373428; // Avg year length in the cycle (19 solar years with 235 lunar months)
|
|
570
|
+
|
|
571
|
+
const AVG_HEBYEAR_DAYS = 365.24682220597794;
|
|
565
572
|
const UNITS_DAY = 'day';
|
|
566
573
|
const UNITS_WEEK = 'week';
|
|
567
574
|
const UNITS_MONTH = 'month';
|
|
@@ -892,8 +899,9 @@ class HDate {
|
|
|
892
899
|
throw new TypeError(`invalid parameter to abs2hebrew ${abs}`);
|
|
893
900
|
}
|
|
894
901
|
|
|
895
|
-
|
|
896
|
-
|
|
902
|
+
abs = Math.trunc(abs); // first, quickly approximate year
|
|
903
|
+
|
|
904
|
+
let year = Math.floor((abs - EPOCH) / AVG_HEBYEAR_DAYS);
|
|
897
905
|
|
|
898
906
|
while (HDate.newYear(year) <= abs) {
|
|
899
907
|
++year;
|
|
@@ -906,7 +914,7 @@ class HDate {
|
|
|
906
914
|
++month;
|
|
907
915
|
}
|
|
908
916
|
|
|
909
|
-
const day =
|
|
917
|
+
const day = 1 + abs - HDate.hebrew2abs(year, month, 1);
|
|
910
918
|
return {
|
|
911
919
|
yy: year,
|
|
912
920
|
mm: month,
|
|
@@ -930,21 +938,21 @@ class HDate {
|
|
|
930
938
|
*
|
|
931
939
|
* const hd = new HDate(15, months.CHESHVAN, 5769);
|
|
932
940
|
* console.log(hd.render()); // '15th of Cheshvan, 5769'
|
|
933
|
-
* console.log(hd.render('he')); // '15
|
|
941
|
+
* console.log(hd.render('he')); // '15 חֶשְׁוָן, 5769'
|
|
934
942
|
* @param {string} [locale] Optional locale name (defaults to active locale).
|
|
943
|
+
* @param {boolean} [showYear=true] Display year (defaults to true).
|
|
935
944
|
* @return {string}
|
|
936
945
|
*/
|
|
937
946
|
|
|
938
947
|
|
|
939
|
-
render(locale) {
|
|
948
|
+
render(locale = null, showYear = true) {
|
|
940
949
|
const locale0 = locale || Locale.getLocaleName();
|
|
941
950
|
const day = this.getDate();
|
|
942
|
-
const fullYear = this.getFullYear();
|
|
943
951
|
const monthName = Locale.gettext(this.getMonthName(), locale);
|
|
944
952
|
const nth = Locale.ordinal(day, locale0);
|
|
945
953
|
let dayOf = '';
|
|
946
954
|
|
|
947
|
-
if (locale0
|
|
955
|
+
if (locale0 === 'en' || locale0 === 's' || 'ashkenazi' == locale0.substring(0, 9)) {
|
|
948
956
|
dayOf = ' of';
|
|
949
957
|
} else {
|
|
950
958
|
const ofStr = Locale.lookupTranslation('of', locale0);
|
|
@@ -954,7 +962,14 @@ class HDate {
|
|
|
954
962
|
}
|
|
955
963
|
}
|
|
956
964
|
|
|
957
|
-
|
|
965
|
+
const dateStr = `${nth}${dayOf} ${monthName}`;
|
|
966
|
+
|
|
967
|
+
if (showYear) {
|
|
968
|
+
const fullYear = this.getFullYear();
|
|
969
|
+
return `${dateStr}, ${fullYear}`;
|
|
970
|
+
} else {
|
|
971
|
+
return dateStr;
|
|
972
|
+
}
|
|
958
973
|
}
|
|
959
974
|
/**
|
|
960
975
|
* Renders this Hebrew date in Hebrew gematriya, regardless of locale.
|
|
@@ -1487,22 +1502,11 @@ class HDate {
|
|
|
1487
1502
|
}
|
|
1488
1503
|
|
|
1489
1504
|
}
|
|
1490
|
-
/**
|
|
1491
|
-
* @private
|
|
1492
|
-
* @param {number} x
|
|
1493
|
-
* @param {number} y
|
|
1494
|
-
* @return {number}
|
|
1495
|
-
*/
|
|
1496
|
-
|
|
1497
|
-
function mod(x, y) {
|
|
1498
|
-
return x - y * Math.floor(x / y);
|
|
1499
|
-
}
|
|
1500
1505
|
/**
|
|
1501
1506
|
* @private
|
|
1502
1507
|
* @param {HDate} date
|
|
1503
1508
|
*/
|
|
1504
1509
|
|
|
1505
|
-
|
|
1506
1510
|
function fix(date) {
|
|
1507
1511
|
fixMonth(date);
|
|
1508
1512
|
fixDate(date);
|
|
@@ -1572,9 +1576,9 @@ function onOrBefore(day, t, offset) {
|
|
|
1572
1576
|
return new HDate(HDate.dayOnOrBefore(day, t.abs() + offset));
|
|
1573
1577
|
}
|
|
1574
1578
|
|
|
1575
|
-
var version="3.26.
|
|
1579
|
+
var version="3.26.6";
|
|
1576
1580
|
|
|
1577
|
-
var headers={"plural-forms":"nplurals=2; plural=(n > 1);",language:"he"};var contexts={"":{Adar:["אַדָר"],"Adar I":["אַדָר א׳"],"Adar II":["אַדָר ב׳"],Av:["אָב"],Cheshvan:["חֶשְׁוָן"],Elul:["אֱלוּל"],Iyyar:["אִיָיר"],Kislev:["כִּסְלֵו"],Nisan:["נִיסָן"],"Sh'vat":["שְׁבָט"],Sivan:["סִיוָן"],Tamuz:["תַּמּוּז"],Tevet:["טֵבֵת"],Tishrei:["
|
|
1581
|
+
var headers={"plural-forms":"nplurals=2; plural=(n > 1);",language:"he"};var contexts={"":{Adar:["אַדָר"],"Adar I":["אַדָר א׳"],"Adar II":["אַדָר ב׳"],Av:["אָב"],Cheshvan:["חֶשְׁוָן"],Elul:["אֱלוּל"],Iyyar:["אִיָיר"],Kislev:["כִּסְלֵו"],Nisan:["נִיסָן"],"Sh'vat":["שְׁבָט"],Sivan:["סִיוָן"],Tamuz:["תַּמּוּז"],Tevet:["טֵבֵת"],Tishrei:["תִשְׁרֵי"]}};var poHeMin = {headers:headers,contexts:contexts};
|
|
1578
1582
|
|
|
1579
1583
|
Locale.addLocale('he', poHeMin);
|
|
1580
1584
|
Locale.addLocale('h', poHeMin);
|