@hebcal/core 4.4.0 → 4.4.1

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.
@@ -1,4 +1,4 @@
1
- /*! @hebcal/core v4.4.0 */
1
+ /*! @hebcal/core v4.4.1 */
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 (let i = 0; i < tdigits.length; i++) {
87
- str += num2heb[tdigits[i]];
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 (let i = 0; i < str.length; i++) {
123
- const n = heb2num[str[i]];
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 && locale.toLowerCase();
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 && locale.toLowerCase();
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' === locale.substring(0, 9)) {
1209
+ if (locale.startsWith('ashkenazi')) {
1210
1210
  return ' of';
1211
1211
  }
1212
1212
  return '';
@@ -1598,9 +1598,7 @@ class HDate {
1598
1598
  return months.ADAR_I;
1599
1599
  }
1600
1600
  return months.ADAR_II;
1601
- // else assume sheini
1602
1601
  }
1603
-
1604
1602
  break;
1605
1603
  case 'ס':
1606
1604
  return months.SIVAN;
@@ -1833,7 +1831,7 @@ function getBirthdayOrAnniversary_(hyear, gdate) {
1833
1831
  return new HDate(day, month, hyear);
1834
1832
  }
1835
1833
 
1836
- const version="4.4.0";
1834
+ const version="4.4.1";
1837
1835
 
1838
1836
  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
1837
 
@@ -1,2 +1,2 @@
1
- /*! @hebcal/core v4.4.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(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.4.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}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.1",t}({});
package/dist/hdate.js CHANGED
@@ -1,4 +1,4 @@
1
- /*! @hebcal/core v4.4.0 */
1
+ /*! @hebcal/core v4.4.1 */
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 (let i = 0; i < tdigits.length; i++) {
86
- str += num2heb[tdigits[i]];
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 (let i = 0; i < str.length; i++) {
122
- const n = heb2num[str[i]];
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 && locale.toLowerCase();
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 && locale.toLowerCase();
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' === locale.substring(0, 9)) {
1206
+ if (locale.startsWith('ashkenazi')) {
1207
1207
  return ' of';
1208
1208
  }
1209
1209
  return '';
@@ -1592,9 +1592,7 @@ class HDate {
1592
1592
  return months.ADAR_I;
1593
1593
  }
1594
1594
  return months.ADAR_II;
1595
- // else assume sheini
1596
1595
  }
1597
-
1598
1596
  break;
1599
1597
  case 'ס':
1600
1598
  return months.SIVAN;
@@ -1826,7 +1824,7 @@ function getBirthdayOrAnniversary_(hyear, gdate) {
1826
1824
  return new HDate(day, month, hyear);
1827
1825
  }
1828
1826
 
1829
- const version="4.4.0";
1827
+ const version="4.4.1";
1830
1828
 
1831
1829
  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
1830
 
package/dist/hdate.mjs CHANGED
@@ -1,4 +1,4 @@
1
- /*! @hebcal/core v4.4.0 */
1
+ /*! @hebcal/core v4.4.1 */
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 (let i = 0; i < tdigits.length; i++) {
85
- str += num2heb[tdigits[i]];
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 (let i = 0; i < str.length; i++) {
121
- const n = heb2num[str[i]];
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 && locale.toLowerCase();
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 && locale.toLowerCase();
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' === locale.substring(0, 9)) {
1259
+ if (locale.startsWith('ashkenazi')) {
1260
1260
  return ' of';
1261
1261
  }
1262
1262
  return '';
@@ -1888,7 +1888,7 @@ function getBirthdayOrAnniversary_(hyear, gdate) {
1888
1888
  return new HDate(day, month, hyear);
1889
1889
  }
1890
1890
 
1891
- const version="4.4.0";
1891
+ const version="4.4.1";
1892
1892
 
1893
1893
  const headers={"plural-forms":"nplurals=2; plural=(n > 1);"};const contexts={"":{Adar:["אַדָר"],"Adar I":["אַדָר א׳"],"Adar II":["אַדָר ב׳"],Av:["אָב"],Cheshvan:["חֶשְׁוָן"],Elul:["אֱלוּל"],Iyyar:["אִיָיר"],Kislev:["כִּסְלֵו"],Nisan:["נִיסָן"],"Sh'vat":["שְׁבָט"],Sivan:["סִיוָן"],Tamuz:["תַּמּוּז"],Tevet:["טֵבֵת"],Tishrei:["תִּשְׁרֵי"]}};var poHeMin = {headers:headers,contexts:contexts};
1894
1894
 
@@ -1,4 +1,4 @@
1
- /*! @hebcal/core v4.4.0 */
1
+ /*! @hebcal/core v4.4.1 */
2
2
  var hebcal = (function (exports) {
3
3
  'use strict';
4
4
 
@@ -1,2 +1,2 @@
1
- /*! @hebcal/core v4.4.0 */
1
+ /*! @hebcal/core v4.4.1 */
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
@@ -1,4 +1,4 @@
1
- /*! @hebcal/core v4.4.0 */
1
+ /*! @hebcal/core v4.4.1 */
2
2
  /*
3
3
  * More minimal greg routines
4
4
  */
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- /*! @hebcal/core v4.4.0 */
1
+ /*! @hebcal/core v4.4.1 */
2
2
  'use strict';
3
3
 
4
4
  /*
@@ -325,8 +325,8 @@ function gematriya(number) {
325
325
  const thousands = Math.floor(num / 1000);
326
326
  if (thousands > 0 && thousands !== 5) {
327
327
  const tdigits = num2digits(thousands);
328
- for (let i = 0; i < tdigits.length; i++) {
329
- str += num2heb[tdigits[i]];
328
+ for (const tdig of tdigits) {
329
+ str += num2heb[tdig];
330
330
  }
331
331
  str += GERESH;
332
332
  }
@@ -361,8 +361,8 @@ function gematriyaStrToNum(str) {
361
361
  num += gematriyaStrToNum(thousands) * 1000;
362
362
  str = str.substring(gereshIdx);
363
363
  }
364
- for (let i = 0; i < str.length; i++) {
365
- const n = heb2num[str[i]];
364
+ for (const ch of str) {
365
+ const n = heb2num[ch];
366
366
  if (typeof n === 'number') {
367
367
  num += n;
368
368
  }
@@ -409,7 +409,7 @@ class Locale {
409
409
  * @return {string}
410
410
  */
411
411
  static lookupTranslation(id, locale) {
412
- const locale0 = locale && locale.toLowerCase();
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 && locale.toLowerCase();
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' === locale.substring(0, 9)) {
1206
+ if (locale.startsWith('ashkenazi')) {
1207
1207
  return ' of';
1208
1208
  }
1209
1209
  return '';
@@ -1592,9 +1592,7 @@ class HDate {
1592
1592
  return months.ADAR_I;
1593
1593
  }
1594
1594
  return months.ADAR_II;
1595
- // else assume sheini
1596
1595
  }
1597
-
1598
1596
  break;
1599
1597
  case 'ס':
1600
1598
  return months.SIVAN;
@@ -1953,8 +1951,7 @@ class Event {
1953
1951
  */
1954
1952
  getCategories() {
1955
1953
  const mask = this.getFlags();
1956
- for (let i = 0; i < flagToCategory.length; i++) {
1957
- const attrs = flagToCategory[i];
1954
+ for (const attrs of flagToCategory) {
1958
1955
  if (mask & attrs[0]) {
1959
1956
  return attrs.slice(1);
1960
1957
  }
@@ -1983,7 +1980,7 @@ class HebrewDateEvent extends Event {
1983
1980
  * @return {string}
1984
1981
  */
1985
1982
  render(locale) {
1986
- const locale1 = locale && locale.toLowerCase();
1983
+ const locale1 = locale === null || locale === void 0 ? void 0 : locale.toLowerCase();
1987
1984
  const locale0 = locale1 || Locale.getLocaleName();
1988
1985
  const hd = this.getDate();
1989
1986
  switch (locale0) {
@@ -2010,7 +2007,7 @@ class HebrewDateEvent extends Event {
2010
2007
  * @return {string}
2011
2008
  */
2012
2009
  renderBrief(locale) {
2013
- const locale1 = locale && locale.toLowerCase();
2010
+ const locale1 = locale === null || locale === void 0 ? void 0 : locale.toLowerCase();
2014
2011
  const locale0 = locale1 || Locale.getLocaleName();
2015
2012
  const hd = this.getDate();
2016
2013
  if (hd.getMonth() === months.TISHREI && hd.getDate() === 1) {
@@ -3309,7 +3306,7 @@ function makeFastStartEnd(ev, location) {
3309
3306
  if (desc === 'Erev Tish\'a B\'Av') {
3310
3307
  const sunset = zmanim.sunset();
3311
3308
  ev.startEvent = makeTimedEvent(hd, sunset, 'Fast begins', ev, location);
3312
- } else if (desc.substring(0, 11) === 'Tish\'a B\'Av') {
3309
+ } else if (desc.startsWith('Tish\'a B\'Av')) {
3313
3310
  ev.endEvent = makeTimedEvent(hd, zmanim.tzeit(TZEIT_3MEDIUM_STARS), 'Fast ends', ev, location);
3314
3311
  } else {
3315
3312
  const dawn = zmanim.alotHaShachar();
@@ -4614,16 +4611,6 @@ const staticModernHolidays = [{
4614
4611
 
4615
4612
  /** Represents a built-in holiday like Pesach, Purim or Tu BiShvat */
4616
4613
  class HolidayEvent extends Event {
4617
- /**
4618
- * Constructs Holiday event
4619
- * @param {HDate} date Hebrew date event occurs
4620
- * @param {string} desc Description (not translated)
4621
- * @param {number} [mask=0] optional holiday flags
4622
- * @param {Object} [attrs={}]
4623
- */
4624
- constructor(date, desc, mask, attrs) {
4625
- super(date, desc, mask, attrs);
4626
- }
4627
4614
  /** @return {string} */
4628
4615
  basename() {
4629
4616
  return this.getDesc().replace(/ \d{4}$/, '').replace(/ \(CH''M\)$/, '').replace(/ \(observed\)$/, '').replace(/ \(Hoshana Raba\)$/, '').replace(/ [IV]+$/, '').replace(/: \d Candles?$/, '').replace(/: 8th Day$/, '').replace(/^Erev /, '');
@@ -4715,15 +4702,6 @@ class RoshChodeshEvent extends HolidayEvent {
4715
4702
  * we subclass HolidayEvent to override the `url()` method.
4716
4703
  */
4717
4704
  class AsaraBTevetEvent extends HolidayEvent {
4718
- /**
4719
- * Constructs AsaraBTevetEvent
4720
- * @param {HDate} date Hebrew date event occurs
4721
- * @param {string} desc Description (not translated)
4722
- * @param {number} [mask=0] optional holiday flags
4723
- */
4724
- constructor(date, desc, mask) {
4725
- super(date, desc, mask);
4726
- }
4727
4705
  /** @return {string} */
4728
4706
  urlDateSuffix() {
4729
4707
  const isoDateTime = this.getDate().greg().toISOString();
@@ -5259,7 +5237,7 @@ function getBirthdayOrAnniversary_(hyear, gdate) {
5259
5237
  return new HDate(day, month, hyear);
5260
5238
  }
5261
5239
 
5262
- const version="4.4.0";
5240
+ const version="4.4.1";
5263
5241
 
5264
5242
  const headers$1={"plural-forms":"nplurals=2; plural=(n > 1);"};const contexts$1={"":{Shabbat:["Shabbos"],"Achrei Mot":["Achrei Mos"],Bechukotai:["Bechukosai"],"Beha'alotcha":["Beha'aloscha"],Bereshit:["Bereshis"],Chukat:["Chukas"],"Erev Shavuot":["Erev Shavuos"],"Erev Sukkot":["Erev Sukkos"],"Ki Tavo":["Ki Savo"],"Ki Teitzei":["Ki Seitzei"],"Ki Tisa":["Ki Sisa"],Matot:["Matos"],"Purim Katan":["Purim Koton"],"Shabbat Chazon":["Shabbos Chazon"],"Shabbat HaChodesh":["Shabbos HaChodesh"],"Shabbat HaGadol":["Shabbos HaGadol"],"Shabbat Nachamu":["Shabbos Nachamu"],"Shabbat Parah":["Shabbos Parah"],"Shabbat Shekalim":["Shabbos Shekalim"],"Shabbat Shuva":["Shabbos Shuvah"],"Shabbat Zachor":["Shabbos Zachor"],Shavuot:["Shavuos"],"Shavuot I":["Shavuos I"],"Shavuot II":["Shavuos II"],Shemot:["Shemos"],"Shmini Atzeret":["Shmini Atzeres"],"Simchat Torah":["Simchas Torah"],Sukkot:["Sukkos"],"Sukkot I":["Sukkos I"],"Sukkot II":["Sukkos II"],"Sukkot II (CH''M)":["Sukkos II (CH''M)"],"Sukkot III (CH''M)":["Sukkos III (CH''M)"],"Sukkot IV (CH''M)":["Sukkos IV (CH''M)"],"Sukkot V (CH''M)":["Sukkos V (CH''M)"],"Sukkot VI (CH''M)":["Sukkos VI (CH''M)"],"Sukkot VII (Hoshana Raba)":["Sukkos VII (Hoshana Raba)"],"Ta'anit Bechorot":["Ta'anis Bechoros"],"Ta'anit Esther":["Ta'anis Esther"],Toldot:["Toldos"],Vaetchanan:["Vaeschanan"],Yitro:["Yisro"],"Vezot Haberakhah":["Vezos Haberakhah"],Parashat:["Parshas"],"Leil Selichot":["Leil Selichos"],"Shabbat Mevarchim Chodesh":["Shabbos Mevorchim Chodesh"],"Shabbat Shirah":["Shabbos Shirah"],Tevet:["Teves"],"Asara B'Tevet":["Asara B'Teves"],"Alot HaShachar":["Alos HaShachar"],"Kriat Shema, sof zeman":["Krias Shema, sof zman"],"Tefilah, sof zeman":["Tefilah, sof zman"],"Kriat Shema, sof zeman (MGA)":["Krias Shema, sof zman (MGA)"],"Tefilah, sof zeman (MGA)":["Tefilah, sof zman (MGA)"],"Chatzot HaLailah":["Chatzos HaLailah"],"Chatzot hayom":["Chatzos"],"Tzeit HaKochavim":["Tzeis HaKochavim"],"Birkat Hachamah":["Birkas Hachamah"],"Shushan Purim Katan":["Shushan Purim Koton"]}};var poAshkenazi = {headers:headers$1,contexts:contexts$1};
5265
5243
 
@@ -5454,9 +5432,9 @@ function tachanunYear(year, il) {
5454
5432
  );
5455
5433
 
5456
5434
  return {
5457
- none: none.map(hd => hd.abs()).sort(),
5458
- some: some.map(hd => hd.abs()).sort(),
5459
- yesPrev: yesPrev.map(hd => hd.abs()).sort()
5435
+ none: none.map(hd => hd.abs()).sort((a, b) => a - b),
5436
+ some: some.map(hd => hd.abs()).sort((a, b) => a - b),
5437
+ yesPrev: yesPrev.map(hd => hd.abs()).sort((a, b) => a - b)
5460
5438
  };
5461
5439
  }
5462
5440
 
@@ -5593,7 +5571,7 @@ function checkCandleOptions(options) {
5593
5571
  return;
5594
5572
  }
5595
5573
  const location = options.location;
5596
- if (typeof location === 'undefined' || !location instanceof Location) {
5574
+ if (typeof location === 'undefined' || !(location instanceof Location)) {
5597
5575
  throw new TypeError('options.candlelighting requires valid options.location');
5598
5576
  }
5599
5577
  if (typeof options.havdalahMins === 'number' && typeof options.havdalahDeg === 'number') {
@@ -5760,6 +5738,7 @@ function getStartAndEnd(options) {
5760
5738
  * @return {number}
5761
5739
  */
5762
5740
  function getMaskFromOptions(options) {
5741
+ var _options$location;
5763
5742
  if (typeof options.mask === 'number') {
5764
5743
  const m = options.mask;
5765
5744
  if (m & ROSH_CHODESH) delete options.noRoshChodesh;
@@ -5789,7 +5768,7 @@ function getMaskFromOptions(options) {
5789
5768
  options.userMask = true;
5790
5769
  return m;
5791
5770
  }
5792
- const il = options.il || options.location && options.location.il || false;
5771
+ const il = options.il || ((_options$location = options.location) === null || _options$location === void 0 ? void 0 : _options$location.il) || false;
5793
5772
  let mask = 0;
5794
5773
 
5795
5774
  // default options
@@ -6047,7 +6026,7 @@ class HebrewCalendar {
6047
6026
  }
6048
6027
  const prevEventsLength = evts.length;
6049
6028
  const dow = hd.getDay();
6050
- let candlesEv = undefined;
6029
+ let candlesEv;
6051
6030
  const ev = holidaysYear.get(hd.toString()) || [];
6052
6031
  ev.forEach(e => {
6053
6032
  candlesEv = appendHolidayAndRelated(evts, e, options, candlesEv, dow);
@@ -6251,8 +6230,9 @@ class HebrewCalendar {
6251
6230
  * @return {string}
6252
6231
  */
6253
6232
  static reformatTimeStr(timeStr, suffix, options) {
6233
+ var _options$location2;
6254
6234
  if (typeof timeStr !== 'string') throw new TypeError(`Bad timeStr: ${timeStr}`);
6255
- const cc = options.location && options.location.cc || (options.il ? 'IL' : 'US');
6235
+ const cc = ((_options$location2 = options.location) === null || _options$location2 === void 0 ? void 0 : _options$location2.cc) || (options.il ? 'IL' : 'US');
6256
6236
  if (typeof options.hour12 !== 'undefined' && !options.hour12) {
6257
6237
  return timeStr;
6258
6238
  }
@@ -6388,9 +6368,7 @@ function appendHolidayAndRelated(events, ev, options, candlesEv, dow) {
6388
6368
  candlesEv = undefined;
6389
6369
  }
6390
6370
  }
6391
- if (options.yomKippurKatan && eFlags & flags.YOM_KIPPUR_KATAN) {
6392
- events.push(ev);
6393
- } else if (!options.noHolidays) {
6371
+ if (!options.noHolidays || options.yomKippurKatan && eFlags & flags.YOM_KIPPUR_KATAN) {
6394
6372
  events.push(ev); // the original event itself
6395
6373
  }
6396
6374
  }