@hebcal/core 4.1.1 → 4.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +67 -0
- package/dist/bundle.js +251 -271
- package/dist/bundle.min.js +2 -2
- package/dist/greg0.mjs +1 -1
- package/dist/hdate-bundle.js +91 -63
- package/dist/hdate-bundle.min.js +2 -2
- package/dist/hdate.js +88 -63
- package/dist/hdate.mjs +88 -39
- package/dist/hdate0-bundle.js +1 -1
- package/dist/hdate0-bundle.min.js +1 -1
- package/dist/hdate0.mjs +1 -1
- package/dist/index.js +92 -67
- package/dist/index.mjs +92 -68
- package/hebcal.d.ts +19 -1
- package/package.json +9 -9
- package/po/he.po +3 -3
package/dist/greg0.mjs
CHANGED
package/dist/hdate-bundle.js
CHANGED
|
@@ -1,65 +1,38 @@
|
|
|
1
|
-
/*! @hebcal/core v4.
|
|
1
|
+
/*! @hebcal/core v4.3.0 */
|
|
2
2
|
var hebcal = (function (exports) {
|
|
3
3
|
'use strict';
|
|
4
4
|
|
|
5
5
|
var GERESH = '׳';
|
|
6
6
|
var GERSHAYIM = '״';
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
return 'כ';
|
|
37
|
-
case 30:
|
|
38
|
-
return 'ל';
|
|
39
|
-
case 40:
|
|
40
|
-
return 'מ';
|
|
41
|
-
case 50:
|
|
42
|
-
return 'נ';
|
|
43
|
-
case 60:
|
|
44
|
-
return 'ס';
|
|
45
|
-
case 70:
|
|
46
|
-
return 'ע';
|
|
47
|
-
case 80:
|
|
48
|
-
return 'פ';
|
|
49
|
-
case 90:
|
|
50
|
-
return 'צ';
|
|
51
|
-
case 100:
|
|
52
|
-
return 'ק';
|
|
53
|
-
case 200:
|
|
54
|
-
return 'ר';
|
|
55
|
-
case 300:
|
|
56
|
-
return 'ש';
|
|
57
|
-
case 400:
|
|
58
|
-
return 'ת';
|
|
59
|
-
default:
|
|
60
|
-
return '*INVALID*';
|
|
61
|
-
}
|
|
62
|
-
}
|
|
7
|
+
var heb2num = {
|
|
8
|
+
'א': 1,
|
|
9
|
+
'ב': 2,
|
|
10
|
+
'ג': 3,
|
|
11
|
+
'ד': 4,
|
|
12
|
+
'ה': 5,
|
|
13
|
+
'ו': 6,
|
|
14
|
+
'ז': 7,
|
|
15
|
+
'ח': 8,
|
|
16
|
+
'ט': 9,
|
|
17
|
+
'י': 10,
|
|
18
|
+
'כ': 20,
|
|
19
|
+
'ל': 30,
|
|
20
|
+
'מ': 40,
|
|
21
|
+
'נ': 50,
|
|
22
|
+
'ס': 60,
|
|
23
|
+
'ע': 70,
|
|
24
|
+
'פ': 80,
|
|
25
|
+
'צ': 90,
|
|
26
|
+
'ק': 100,
|
|
27
|
+
'ר': 200,
|
|
28
|
+
'ש': 300,
|
|
29
|
+
'ת': 400
|
|
30
|
+
};
|
|
31
|
+
var num2heb = {};
|
|
32
|
+
Object.keys(heb2num).forEach(function (key) {
|
|
33
|
+
var val = heb2num[key];
|
|
34
|
+
num2heb[val] = key;
|
|
35
|
+
});
|
|
63
36
|
|
|
64
37
|
/**
|
|
65
38
|
* @private
|
|
@@ -111,23 +84,50 @@ function gematriya(number) {
|
|
|
111
84
|
if (thousands > 0 && thousands !== 5) {
|
|
112
85
|
var tdigits = num2digits(thousands);
|
|
113
86
|
for (var i = 0; i < tdigits.length; i++) {
|
|
114
|
-
str += num2heb
|
|
87
|
+
str += num2heb[tdigits[i]];
|
|
115
88
|
}
|
|
116
89
|
str += GERESH;
|
|
117
90
|
}
|
|
118
91
|
var digits = num2digits(num % 1000);
|
|
119
92
|
if (digits.length == 1) {
|
|
120
|
-
return str + num2heb
|
|
93
|
+
return str + num2heb[digits[0]] + GERESH;
|
|
121
94
|
}
|
|
122
95
|
for (var _i = 0; _i < digits.length; _i++) {
|
|
123
96
|
if (_i + 1 === digits.length) {
|
|
124
97
|
str += GERSHAYIM;
|
|
125
98
|
}
|
|
126
|
-
str += num2heb
|
|
99
|
+
str += num2heb[digits[_i]];
|
|
127
100
|
}
|
|
128
101
|
return str;
|
|
129
102
|
}
|
|
130
103
|
|
|
104
|
+
/**
|
|
105
|
+
* Converts a string of Hebrew letters to a numerical value.
|
|
106
|
+
*
|
|
107
|
+
* Only considers the value of Hebrew letters `א` through `ת`.
|
|
108
|
+
* Ignores final Hebrew letters such as `ך` (kaf sofit) or `ם` (mem sofit)
|
|
109
|
+
* and vowels (nekudot).
|
|
110
|
+
*
|
|
111
|
+
* @param {string} str
|
|
112
|
+
* @return {number}
|
|
113
|
+
*/
|
|
114
|
+
function gematriyaStrToNum(str) {
|
|
115
|
+
var num = 0;
|
|
116
|
+
var gereshIdx = str.indexOf(GERESH);
|
|
117
|
+
if (gereshIdx !== -1 && gereshIdx !== str.length - 1) {
|
|
118
|
+
var thousands = str.substring(0, gereshIdx);
|
|
119
|
+
num += gematriyaStrToNum(thousands) * 1000;
|
|
120
|
+
str = str.substring(gereshIdx);
|
|
121
|
+
}
|
|
122
|
+
for (var i = 0; i < str.length; i++) {
|
|
123
|
+
var n = heb2num[str[i]];
|
|
124
|
+
if (typeof n === 'number') {
|
|
125
|
+
num += n;
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
return num;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
131
|
function _typeof(obj) {
|
|
132
132
|
"@babel/helpers - typeof";
|
|
133
133
|
|
|
@@ -1157,7 +1157,7 @@ var HDate = /*#__PURE__*/function () {
|
|
|
1157
1157
|
/**
|
|
1158
1158
|
* Sets the day of the month of the date. Returns the object it was called upon
|
|
1159
1159
|
* @private
|
|
1160
|
-
* @param {number} month
|
|
1160
|
+
* @param {number|string} month A number, or Hebrew month name string
|
|
1161
1161
|
* @return {HDate}
|
|
1162
1162
|
*/
|
|
1163
1163
|
}, {
|
|
@@ -1663,7 +1663,11 @@ var HDate = /*#__PURE__*/function () {
|
|
|
1663
1663
|
}
|
|
1664
1664
|
return monthName;
|
|
1665
1665
|
}
|
|
1666
|
-
var c = monthName.toLowerCase();
|
|
1666
|
+
var c = Locale.hebrewStripNikkud(monthName).trim().toLowerCase();
|
|
1667
|
+
// If Hebrew month starts with a bet (for example `בתמוז`) then ignore it
|
|
1668
|
+
if (c[0] === 'ב') {
|
|
1669
|
+
c = c.substring(1);
|
|
1670
|
+
}
|
|
1667
1671
|
/*
|
|
1668
1672
|
the Hebrew months are unique to their second letter
|
|
1669
1673
|
N Nisan (November?)
|
|
@@ -1792,6 +1796,30 @@ var HDate = /*#__PURE__*/function () {
|
|
|
1792
1796
|
value: function isHDate(obj) {
|
|
1793
1797
|
return obj !== null && _typeof(obj) === 'object' && typeof obj.year === 'number' && typeof obj.month === 'number' && typeof obj.day === 'number' && typeof obj.greg === 'function' && typeof obj.abs === 'function';
|
|
1794
1798
|
}
|
|
1799
|
+
|
|
1800
|
+
/**
|
|
1801
|
+
* Construct a new instance of `HDate` from a Gematriya-formatted string
|
|
1802
|
+
* @example
|
|
1803
|
+
* HDate.fromGematriyaString('כ״ז בְּתַמּוּז תשפ״ג') // 27 Tamuz 5783
|
|
1804
|
+
* HDate.fromGematriyaString('כ׳ סיון תש״ד') // 20 Sivan 5704
|
|
1805
|
+
* HDate.fromGematriyaString('ה׳ אִיָיר תש״ח') // 5 Iyyar 5708
|
|
1806
|
+
* @param {string} str
|
|
1807
|
+
* @param {number} currentThousands
|
|
1808
|
+
* @return {HDate}
|
|
1809
|
+
*/
|
|
1810
|
+
}, {
|
|
1811
|
+
key: "fromGematriyaString",
|
|
1812
|
+
value: function fromGematriyaString(str) {
|
|
1813
|
+
var currentThousands = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 5000;
|
|
1814
|
+
var parts = str.split(' ');
|
|
1815
|
+
var day = gematriyaStrToNum(parts[0]);
|
|
1816
|
+
var month = HDate.monthFromName(parts[1]);
|
|
1817
|
+
var year = gematriyaStrToNum(parts[2]);
|
|
1818
|
+
if (year < 1000) {
|
|
1819
|
+
year += currentThousands;
|
|
1820
|
+
}
|
|
1821
|
+
return new HDate(day, month, year);
|
|
1822
|
+
}
|
|
1795
1823
|
}]);
|
|
1796
1824
|
return HDate;
|
|
1797
1825
|
}();
|
|
@@ -1948,7 +1976,7 @@ function getBirthdayOrAnniversary_(hyear, gdate) {
|
|
|
1948
1976
|
return new HDate(day, month, hyear);
|
|
1949
1977
|
}
|
|
1950
1978
|
|
|
1951
|
-
var version="4.
|
|
1979
|
+
var version="4.3.0";
|
|
1952
1980
|
|
|
1953
1981
|
var headers={"plural-forms":"nplurals=2; plural=(n > 1);"};var contexts={"":{Adar:["אַדָר"],"Adar I":["אַדָר א׳"],"Adar II":["אַדָר ב׳"],Av:["אָב"],Cheshvan:["חֶשְׁוָן"],Elul:["אֱלוּל"],Iyyar:["אִיָיר"],Kislev:["כִּסְלֵו"],Nisan:["נִיסָן"],"Sh'vat":["שְׁבָט"],Sivan:["סִיוָן"],Tamuz:["תַּמּוּז"],Tevet:["טֵבֵת"],Tishrei:["תִשְׁרֵי"]}};var poHeMin = {headers:headers,contexts:contexts};
|
|
1954
1982
|
|
package/dist/hdate-bundle.min.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
/*! @hebcal/core v4.
|
|
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){for(var t=[];e>0;){if(15===e||16===e){t.push(9),t.push(e-9);break}var r=100,n=void 0;for(n=400;n>e;n-=r)n===r&&(r/=10);t.push(n),e-=n}return t}function n(e){var n=parseInt(e,10);if(!n)throw new TypeError("invalid parameter to gematriya ".concat(e));var a="",o=Math.floor(n/1e3);if(o>0&&5!==o){for(var u=r(o),i=0;i<u.length;i++)a+=t(u[i]);a+="׳"}var c=r(n%1e3);if(1==c.length)return a+t(c[0])+"׳";for(var s=0;s<c.length;s++)s+1===c.length&&(a+="״"),a+=t(c[s]);return a}function a(e){return a="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},a(e)}function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function u(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,(a=n.key,o=void 0,"symbol"==typeof(o=function(e,t){if("object"!=typeof e||null===e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var n=r.call(e,t||"default");if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(a,"string"))?o:String(o)),n)}var a,o}function i(e,t,r){return t&&u(e.prototype,t),r&&u(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}var c=[0,31,28,31,30,31,30,31,31,30,31,30,31],s=[c,c.slice()];function h(e,t){return e-t*Math.floor(e/t)}function l(e,t){return Math.floor(e/t)}function f(e){return!(e%4||!(e%100)&&e%400)}function y(e){return"object"===a(e)&&Date.prototype===e.__proto__}function v(e){if(!y(e))throw new TypeError("Argument not a Date: ".concat(e));return d(e.getFullYear(),e.getMonth()+1,e.getDate())}function d(e,t,r){var n=e-1;return 365*n+l(n,4)-l(n,100)+l(n,400)+l(367*t-362,12)+(t<=2?0:f(e)?-1:-2)+r}function m(e){if("number"!=typeof e)throw new TypeError("Argument not a Number: ".concat(e));var t=function(e){var t=e-1,r=l(t,146097),n=h(t,146097),a=l(n,36524),o=h(n,36524),u=l(o,1461),i=l(h(o,1461),365),c=400*r+100*a+4*u+i;return 4!=a&&4!=i?c+1:c}(e=Math.trunc(e)),r=l(12*(e-d(t,1,1)+(e<d(t,3,1)?0:f(t)?1:2))+373,367),n=e-d(t,r,1)+1,a=new Date(t,r-1,n);return t<100&&t>=0&&a.setFullYear(t),a}s[1][2]=29;var g={monthNames:["","January","February","March","April","May","June","July","August","September","October","November","December"],isLeapYear:f,daysInMonth:function(e,t){return s[+f(t)][e]},isDate:y,dayOfYear:function(e){if(!y(e))throw new TypeError("Argument not a Date: ".concat(e));var t=e.getMonth(),r=e.getDate()+31*t;return t>1&&(r-=Math.floor((4*(t+1)+23)/10),f(e.getFullYear())&&r++),r},greg2abs:v,abs2greg:m},w={headers:{"plural-forms":"nplurals=2; plural=(n!=1);"},contexts:{"":{}}},p={h:"he",a:"ashkenazi",s:"en","":"en"},b=Object.create(null),k=null,I=null,A=function(){function e(){o(this,e)}return i(e,null,[{key:"lookupTranslation",value:function(e,t){var r=t&&t.toLowerCase(),n=("string"==typeof t&&b[r]||k)[e];if(n&&n.length&&n[0].length)return n[0]}},{key:"gettext",value:function(e,t){var r=this.lookupTranslation(e,t);return void 0===r?e:r}},{key:"addLocale",value:function(e,t){if("string"!=typeof e)throw new TypeError("Invalid locale name: ".concat(e));if("object"!==a(t.contexts)||"object"!==a(t.contexts[""]))throw new TypeError("Locale '".concat(e,"' invalid compact format"));b[e.toLowerCase()]=t.contexts[""]}},{key:"addTranslation",value:function(e,t,r){if("string"!=typeof e)throw new TypeError("Invalid locale name: ".concat(e));var n=e.toLowerCase(),a=b[n];if(!a)throw new TypeError("Unknown locale: ".concat(e));if("string"!=typeof t||0===t.length)throw new TypeError("Invalid id: ".concat(t));var o=Array.isArray(r);if(o){var u=r[0];if("string"!=typeof u||0===u.length)throw new TypeError("Invalid translation array: ".concat(r))}else if("string"!=typeof r)throw new TypeError("Invalid translation: ".concat(r));a[t]=o?r:[r]}},{key:"addTranslations",value:function(e,t){if("string"!=typeof e)throw new TypeError("Invalid locale name: ".concat(e));var r=e.toLowerCase(),n=b[r];if(!n)throw new TypeError("Unknown locale: ".concat(e));if("object"!==a(t.contexts)||"object"!==a(t.contexts[""]))throw new TypeError("Locale '".concat(e,"' invalid compact format"));var o=t.contexts[""];Object.keys(o).forEach((function(e){n[e]=o[e]}))}},{key:"useLocale",value:function(e){var t=e.toLowerCase(),r=b[t];if(!r)throw new RangeError("Locale '".concat(e,"' not found"));return I=p[t]||t,k=r}},{key:"getLocaleName",value:function(){return I}},{key:"getLocaleNames",value:function(){return Object.keys(b).sort()}},{key:"ordinal",value:function(e,t){var r=t&&t.toLowerCase()||I;if(!r)return this.getEnOrdinal(e);switch(r){case"en":case"s":case"a":case"ashkenazi":case"ashkenazi_litvish":case"ashkenazi_poylish":case"ashkenazi_standard":return this.getEnOrdinal(e);case"es":return e+"º";case"h":case"he":case"he-x-nonikud":return String(e);default:return e+"."}}},{key:"getEnOrdinal",value:function(e){var t=["th","st","nd","rd"],r=e%100;return e+(t[(r-20)%10]||t[r]||t[0])}},{key:"hebrewStripNikkud",value:function(e){return e.replace(/[\u0590-\u05bd]/g,"").replace(/[\u05bf-\u05c7]/g,"")}}]),e}();A.addLocale("en",w),A.addLocale("s",w),A.addLocale("",w),A.useLocale("en");var E=1,T=2,N=4,D=6,L=7,M=8,S=9,Y=10,H=12,R=13,O={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},V=["","Nisan","Iyyar","Sivan","Tamuz","Av","Elul","Tishrei","Cheshvan","Kislev","Tevet","Sh'vat"],x=[V.concat(["Adar","Nisan"]),V.concat(["Adar I","Adar II","Nisan"])],C=Object.create(null),F=-1373428,_=365.24682220597794;function j(e,t){if("number"!=typeof e||isNaN(e))throw new TypeError("invalid parameter '".concat(t,"' not a number: ").concat(e))}function z(e,t,r){if(j(e,"year"),j(t,"month"),j(r,"day"),e<1)throw new RangeError("hebrew2abs: invalid year ".concat(e));var n=r;if(t<L){for(var a=L;a<=P(e);a++)n+=J(a,e);for(var o=E;o<t;o++)n+=J(o,e)}else for(var u=L;u<t;u++)n+=J(u,e);return F+$(e)+n-1}function U(e){return F+$(e)}function K(e){if(j(e,"abs"),(e=Math.trunc(e))<=F)throw new RangeError("abs2hebrew: ".concat(e," is before epoch"));for(var t=Math.floor((e-F)/_);U(t)<=e;)++t;for(var r=e<z(--t,1,1)?7:1;e>z(t,r,J(r,t));)++r;return{yy:t,mm:r,dd:1+e-z(t,r,1)}}function B(e){return(1+7*e)%19<7}function P(e){return 12+B(e)}function J(e,t){switch(e){case T:case N:case D:case Y:case R:return 29}return e===H&&!B(t)||e===M&&!G(t)||e===S&&Q(t)?29:30}function Z(e,t){if(j(e,"month"),j(t,"year"),e<1||e>14)throw new TypeError("bad month argument ".concat(e));return x[+B(t)][e]}function $(e){var t=C[e]=C[e]||function(e){var t=e-1,r=235*Math.floor(t/19)+t%19*12+Math.floor((t%19*7+1)/19),n=204+r%1080*793,a=5+12*r+793*Math.floor(r/1080)+Math.floor(n/1080),o=n%1080+a%24*1080,u=1+29*r+Math.floor(a/24),i=u+(o>=19440||2==u%7&&o>=9924&&!B(e)||1==u%7&&o>=16789&&B(t));return i+(i%7==0||i%7==3||i%7==5)}(e);return t}function q(e){return $(e+1)-$(e)}function G(e){return q(e)%10==5}function Q(e){return q(e)%10==3}function W(e){throw new TypeError(e)}var X="day",ee="week",te="month",re="year",ne={d:X,w:ee,M:te,y:re},ae={day:X,week:ee,month:te,year:re},oe=function(){function e(t,r,n){if(o(this,e),2==arguments.length||arguments.length>3)throw new TypeError("HDate constructor requires 0, 1 or 3 arguments");if(3==arguments.length){if(this.day=this.month=1,n=parseInt(n,10),isNaN(n))throw new TypeError("HDate called with bad year argument: ".concat(n));if(this.year=n,this.setMonth(r),t=parseInt(t,10),isNaN(t))throw new TypeError("HDate called with bad day argument: ".concat(t));this.setDate(t)}else{void 0===t&&(t=new Date);var a="number"!=typeof t||isNaN(t)?y(t)?v(t):e.isHDate(t)?{dd:t.day,mm:t.month,yy:t.year}:W("HDate called with bad argument: ".concat(t)):t,u="number"==typeof a,i=u?K(a):a;this.day=i.dd,this.month=i.mm,this.year=i.yy,u&&(this.abs0=a)}}return i(e,[{key:"getFullYear",value:function(){return this.year}},{key:"isLeapYear",value:function(){return B(this.year)}},{key:"getMonth",value:function(){return this.month}},{key:"getTishreiMonth",value:function(){var e=P(this.getFullYear());return(this.getMonth()+e-6)%e||e}},{key:"daysInMonth",value:function(){return J(this.getMonth(),this.getFullYear())}},{key:"getDate",value:function(){return this.day}},{key:"getDay",value:function(){return h(this.abs(),7)}},{key:"setFullYear",value:function(e){return this.year=e,ue(this),this}},{key:"setMonth",value:function(t){return this.month=e.monthNum(t),ue(this),this}},{key:"setDate",value:function(e){return this.day=e,ue(this),this}},{key:"greg",value:function(){return m(this.abs())}},{key:"abs",value:function(){return"number"!=typeof this.abs0&&(this.abs0=z(this.year,this.month,this.day)),this.abs0}},{key:"getMonthName",value:function(){return Z(this.getMonth(),this.getFullYear())}},{key:"render",value:function(){var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],r=(arguments.length>0&&void 0!==arguments[0]?arguments[0]:null)||A.getLocaleName(),n=this.getDate(),a=A.gettext(this.getMonthName(),r),o=A.ordinal(n,r),u=e.getDayOfTranslation(r),i="".concat(o).concat(u," ").concat(a);if(t){var c=this.getFullYear();return"".concat(i,", ").concat(c)}return i}},{key:"renderGematriya",value:function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0],t=this.getDate(),r=e?"he-x-NoNikud":"he",a=A.gettext(this.getMonthName(),r),o=this.getFullYear();return n(t)+" "+a+" "+n(o)}},{key:"before",value:function(e){return ce(e,this,-1)}},{key:"onOrBefore",value:function(e){return ce(e,this,0)}},{key:"nearest",value:function(e){return ce(e,this,3)}},{key:"onOrAfter",value:function(e){return ce(e,this,6)}},{key:"after",value:function(e){return ce(e,this,7)}},{key:"next",value:function(){return new e(this.abs()+1)}},{key:"prev",value:function(){return new e(this.abs()-1)}},{key:"add",value:function(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"d";if(!(t=parseInt(t,10)))return new e(this);if((r=e.standardizeUnits(r))===X)return new e(this.abs()+t);if(r===ee)return new e(this.abs()+7*t);if(r===re)return new e(this.getDate(),this.getMonth(),this.getFullYear()+t);if(r===te){var n=new e(this),a=t>0?1:-1;t=Math.abs(t);for(var o=0;o<t;o++)n=new e(n.abs()+a*n.daysInMonth());return n}}},{key:"subtract",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"d";return this.add(-1*e,t)}},{key:"deltaDays",value:function(t){if(!e.isHDate(t))throw new TypeError("Bad argument: ".concat(t));return this.abs()-t.abs()}},{key:"isSameDate",value:function(t){return!!e.isHDate(t)&&(this.year==t.year&&this.month==t.month&&this.day==t.day)}},{key:"toString",value:function(){var e=this.getDate(),t=this.getFullYear(),r=this.getMonthName();return"".concat(e," ").concat(r," ").concat(t)}}],[{key:"hebrew2abs",value:function(e,t,r){return z(e,t,r)}},{key:"abs2hebrew",value:function(e){return K(e)}},{key:"getDayOfTranslation",value:function(e){switch(e){case"en":case"s":case"a":case"ashkenazi":return" of"}var t=A.lookupTranslation("of",e);return t?" "+t:"ashkenazi"===e.substring(0,9)?" of":""}},{key:"standardizeUnits",value:function(e){var t=ne[e]||String(e||"").toLowerCase().replace(/s$/,"");return ae[t]||W("Invalid units '".concat(e,"'"))}},{key:"isLeapYear",value:function(e){return B(e)}},{key:"monthsInYear",value:function(e){return P(e)}},{key:"daysInMonth",value:function(e,t){return J(e,t)}},{key:"getMonthName",value:function(e,t){return Z(e,t)}},{key:"monthNum",value:function(t){if("number"==typeof t){if(isNaN(t)||t>14)throw new RangeError("Invalid month number: ".concat(t));return t}return t.charCodeAt(0)>=48&&t.charCodeAt(0)<=57?parseInt(t,10):e.monthFromName(t)}},{key:"daysInYear",value:function(e){return q(e)}},{key:"longCheshvan",value:function(e){return G(e)}},{key:"shortKislev",value:function(e){return Q(e)}},{key:"monthFromName",value:function(e){if("number"==typeof e){if(isNaN(e)||e<1||e>14)throw new RangeError("Invalid month name: ".concat(e));return e}var t=e.toLowerCase();switch(t[0]){case"n":case"נ":if("o"==t[1])break;return O.NISAN;case"i":return O.IYYAR;case"e":return O.ELUL;case"c":case"ח":return O.CHESHVAN;case"k":case"כ":return O.KISLEV;case"s":switch(t[1]){case"i":return O.SIVAN;case"h":return O.SHVAT}case"t":switch(t[1]){case"a":return O.TAMUZ;case"i":return O.TISHREI;case"e":return O.TEVET}break;case"a":switch(t[1]){case"v":return O.AV;case"d":return/(1|[^i]i|a|א)$/i.test(e)?O.ADAR_I:O.ADAR_II}break;case"ס":return O.SIVAN;case"ט":return O.TEVET;case"ש":return O.SHVAT;case"א":switch(t[1]){case"ב":return O.AV;case"ד":return/(1|[^i]i|a|א)$/i.test(e)?O.ADAR_I:O.ADAR_II;case"י":return O.IYYAR;case"ל":return O.ELUL}break;case"ת":switch(t[1]){case"מ":return O.TAMUZ;case"ש":return O.TISHREI}}throw new RangeError("Unable to parse month name: ".concat(e))}},{key:"dayOnOrBefore",value:function(e,t){return t-(t-e)%7}},{key:"isHDate",value:function(e){return null!==e&&"object"===a(e)&&"number"==typeof e.year&&"number"==typeof e.month&&"number"==typeof e.day&&"function"==typeof e.greg&&"function"==typeof e.abs}}]),e}();function ue(e){ie(e),function(e){e.day<1&&(e.month==O.TISHREI&&(e.year-=1),e.day+=J(e.month,e.year),e.month-=1,ue(e));e.day>J(e.month,e.year)&&(e.month===O.ELUL&&(e.year+=1),e.day-=J(e.month,e.year),e.month+=1,ue(e));ie(e)}(e)}function ie(e){e.month!==O.ADAR_II||e.isLeapYear()?e.month<1?(e.month+=P(e.year),e.year-=1,ue(e)):e.month>P(e.year)&&(e.month-=P(e.year),e.year+=1,ue(e)):(e.month-=1,ue(e)),delete e.abs0}function ce(e,t,r){return new oe(oe.dayOnOrBefore(e,t.abs()+r))}var se=O.NISAN,he=O.CHESHVAN,le=O.KISLEV,fe=O.TEVET,ye=O.SHVAT,ve=O.ADAR_I,de=O.ADAR_II;var me={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",me),A.addLocale("h",me);var ge=me.contexts[""],we={};return Object.keys(ge).forEach((function(e){we[e]=[A.hebrewStripNikkud(ge[e][0])]})),A.addLocale("he-x-NoNikud",{headers:me.headers,contexts:{"":we}}),e.HDate=oe,e.Locale=A,e.gematriya=n,e.getBirthdayOrAnniversary=function(e,t){var r=oe.isHDate(t)?t:new oe(t),n=r.getFullYear();if(e===n)return r;if(!(e<n)){var a=B(n),o=r.getMonth(),u=r.getDate();return o==ve&&!a||o==de&&a?o=P(e):o!=he||30!=u||G(e)?o==le&&30==u&&Q(e)?(o=fe,u=1):o==ve&&30==u&&a&&!B(e)&&(o=se,u=1):(o=le,u=1),new oe(u,o,e)}},e.getYahrzeit=function(e,t){var r=oe.isHDate(t)?t:new oe(t),n={yy:r.getFullYear(),mm:r.getMonth(),dd:r.getDate()};if(!(e<=n.yy))return n.mm!=he||30!=n.dd||G(n.yy+1)?n.mm==le&&30==n.dd&&Q(n.yy+1)?n=K(z(e,fe,1)-1):n.mm==de?n.mm=P(e):n.mm!=ve||30!=n.dd||B(e)||(n.dd=30,n.mm=ye):n=K(z(e,le,1)-1),n.mm!=he||30!=n.dd||G(e)?n.mm==le&&30==n.dd&&Q(e)&&(n.mm=fe,n.dd=1):(n.mm=le,n.dd=1),new oe(n.dd,n.mm,e)},e.greg=g,e.months=O,e.version="4.1.1",e}({});
|
|
1
|
+
/*! @hebcal/core v4.3.0 */
|
|
2
|
+
var hebcal=function(e){"use strict";var t={"א":1,"ב":2,"ג":3,"ד":4,"ה":5,"ו":6,"ז":7,"ח":8,"ט":9,"י":10,"כ":20,"ל":30,"מ":40,"נ":50,"ס":60,"ע":70,"פ":80,"צ":90,"ק":100,"ר":200,"ש":300,"ת":400},r={};function n(e){for(var t=[];e>0;){if(15===e||16===e){t.push(9),t.push(e-9);break}var r=100,n=void 0;for(n=400;n>e;n-=r)n===r&&(r/=10);t.push(n),e-=n}return t}function a(e){var t=parseInt(e,10);if(!t)throw new TypeError("invalid parameter to gematriya ".concat(e));var a="",o=Math.floor(t/1e3);if(o>0&&5!==o){for(var i=n(o),u=0;u<i.length;u++)a+=r[i[u]];a+="׳"}var c=n(t%1e3);if(1==c.length)return a+r[c[0]]+"׳";for(var s=0;s<c.length;s++)s+1===c.length&&(a+="״"),a+=r[c[s]];return a}function o(e){var r=0,n=e.indexOf("׳");-1!==n&&n!==e.length-1&&(r+=1e3*o(e.substring(0,n)),e=e.substring(n));for(var a=0;a<e.length;a++){var i=t[e[a]];"number"==typeof i&&(r+=i)}return r}function i(e){return i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},i(e)}function u(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function c(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,(a=n.key,o=void 0,"symbol"==typeof(o=function(e,t){if("object"!=typeof e||null===e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var n=r.call(e,t||"default");if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(a,"string"))?o:String(o)),n)}var a,o}function s(e,t,r){return t&&c(e.prototype,t),r&&c(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}Object.keys(t).forEach((function(e){r[t[e]]=e}));var h=[0,31,28,31,30,31,30,31,31,30,31,30,31],l=[h,h.slice()];function f(e,t){return e-t*Math.floor(e/t)}function y(e,t){return Math.floor(e/t)}function v(e){return!(e%4||!(e%100)&&e%400)}function d(e){return"object"===i(e)&&Date.prototype===e.__proto__}function m(e){if(!d(e))throw new TypeError("Argument not a Date: ".concat(e));return g(e.getFullYear(),e.getMonth()+1,e.getDate())}function g(e,t,r){var n=e-1;return 365*n+y(n,4)-y(n,100)+y(n,400)+y(367*t-362,12)+(t<=2?0:v(e)?-1:-2)+r}function w(e){if("number"!=typeof e)throw new TypeError("Argument not a Number: ".concat(e));var t=function(e){var t=e-1,r=y(t,146097),n=f(t,146097),a=y(n,36524),o=f(n,36524),i=y(o,1461),u=y(f(o,1461),365),c=400*r+100*a+4*i+u;return 4!=a&&4!=u?c+1:c}(e=Math.trunc(e)),r=y(12*(e-g(t,1,1)+(e<g(t,3,1)?0:v(t)?1:2))+373,367),n=e-g(t,r,1)+1,a=new Date(t,r-1,n);return t<100&&t>=0&&a.setFullYear(t),a}l[1][2]=29;var b={monthNames:["","January","February","March","April","May","June","July","August","September","October","November","December"],isLeapYear:v,daysInMonth:function(e,t){return l[+v(t)][e]},isDate:d,dayOfYear:function(e){if(!d(e))throw new TypeError("Argument not a Date: ".concat(e));var t=e.getMonth(),r=e.getDate()+31*t;return t>1&&(r-=Math.floor((4*(t+1)+23)/10),v(e.getFullYear())&&r++),r},greg2abs:m,abs2greg:w},p={headers:{"plural-forms":"nplurals=2; plural=(n!=1);"},contexts:{"":{}}},k={h:"he",a:"ashkenazi",s:"en","":"en"},I=Object.create(null),A=null,E=null,T=function(){function e(){u(this,e)}return s(e,null,[{key:"lookupTranslation",value:function(e,t){var r=t&&t.toLowerCase(),n=("string"==typeof t&&I[r]||A)[e];if(n&&n.length&&n[0].length)return n[0]}},{key:"gettext",value:function(e,t){var r=this.lookupTranslation(e,t);return void 0===r?e:r}},{key:"addLocale",value:function(e,t){if("string"!=typeof e)throw new TypeError("Invalid locale name: ".concat(e));if("object"!==i(t.contexts)||"object"!==i(t.contexts[""]))throw new TypeError("Locale '".concat(e,"' invalid compact format"));I[e.toLowerCase()]=t.contexts[""]}},{key:"addTranslation",value:function(e,t,r){if("string"!=typeof e)throw new TypeError("Invalid locale name: ".concat(e));var n=e.toLowerCase(),a=I[n];if(!a)throw new TypeError("Unknown locale: ".concat(e));if("string"!=typeof t||0===t.length)throw new TypeError("Invalid id: ".concat(t));var o=Array.isArray(r);if(o){var i=r[0];if("string"!=typeof i||0===i.length)throw new TypeError("Invalid translation array: ".concat(r))}else if("string"!=typeof r)throw new TypeError("Invalid translation: ".concat(r));a[t]=o?r:[r]}},{key:"addTranslations",value:function(e,t){if("string"!=typeof e)throw new TypeError("Invalid locale name: ".concat(e));var r=e.toLowerCase(),n=I[r];if(!n)throw new TypeError("Unknown locale: ".concat(e));if("object"!==i(t.contexts)||"object"!==i(t.contexts[""]))throw new TypeError("Locale '".concat(e,"' invalid compact format"));var a=t.contexts[""];Object.keys(a).forEach((function(e){n[e]=a[e]}))}},{key:"useLocale",value:function(e){var t=e.toLowerCase(),r=I[t];if(!r)throw new RangeError("Locale '".concat(e,"' not found"));return E=k[t]||t,A=r}},{key:"getLocaleName",value:function(){return E}},{key:"getLocaleNames",value:function(){return Object.keys(I).sort()}},{key:"ordinal",value:function(e,t){var r=t&&t.toLowerCase()||E;if(!r)return this.getEnOrdinal(e);switch(r){case"en":case"s":case"a":case"ashkenazi":case"ashkenazi_litvish":case"ashkenazi_poylish":case"ashkenazi_standard":return this.getEnOrdinal(e);case"es":return e+"º";case"h":case"he":case"he-x-nonikud":return String(e);default:return e+"."}}},{key:"getEnOrdinal",value:function(e){var t=["th","st","nd","rd"],r=e%100;return e+(t[(r-20)%10]||t[r]||t[0])}},{key:"hebrewStripNikkud",value:function(e){return e.replace(/[\u0590-\u05bd]/g,"").replace(/[\u05bf-\u05c7]/g,"")}}]),e}();T.addLocale("en",p),T.addLocale("s",p),T.addLocale("",p),T.useLocale("en");var N=1,D=2,S=4,M=6,L=7,Y=8,H=9,O=10,R=12,V=13,x={NISAN:1,IYYAR:2,SIVAN:3,TAMUZ:4,AV:5,ELUL:6,TISHREI:7,CHESHVAN:8,KISLEV:9,TEVET:10,SHVAT:11,ADAR_I:12,ADAR_II:13},F=["","Nisan","Iyyar","Sivan","Tamuz","Av","Elul","Tishrei","Cheshvan","Kislev","Tevet","Sh'vat"],C=[F.concat(["Adar","Nisan"]),F.concat(["Adar I","Adar II","Nisan"])],j=Object.create(null),_=-1373428,z=365.24682220597794;function U(e,t){if("number"!=typeof e||isNaN(e))throw new TypeError("invalid parameter '".concat(t,"' not a number: ").concat(e))}function K(e,t,r){if(U(e,"year"),U(t,"month"),U(r,"day"),e<1)throw new RangeError("hebrew2abs: invalid year ".concat(e));var n=r;if(t<L){for(var a=L;a<=Z(e);a++)n+=$(a,e);for(var o=N;o<t;o++)n+=$(o,e)}else for(var i=L;i<t;i++)n+=$(i,e);return _+q(e)+n-1}function B(e){return _+q(e)}function P(e){if(U(e,"abs"),(e=Math.trunc(e))<=_)throw new RangeError("abs2hebrew: ".concat(e," is before epoch"));for(var t=Math.floor((e-_)/z);B(t)<=e;)++t;for(var r=e<K(--t,1,1)?7:1;e>K(t,r,$(r,t));)++r;return{yy:t,mm:r,dd:1+e-K(t,r,1)}}function J(e){return(1+7*e)%19<7}function Z(e){return 12+J(e)}function $(e,t){switch(e){case D:case S:case M:case O:case V:return 29}return e===R&&!J(t)||e===Y&&!W(t)||e===H&&X(t)?29:30}function G(e,t){if(U(e,"month"),U(t,"year"),e<1||e>14)throw new TypeError("bad month argument ".concat(e));return C[+J(t)][e]}function q(e){var t=j[e]=j[e]||function(e){var t=e-1,r=235*Math.floor(t/19)+t%19*12+Math.floor((t%19*7+1)/19),n=204+r%1080*793,a=5+12*r+793*Math.floor(r/1080)+Math.floor(n/1080),o=n%1080+a%24*1080,i=1+29*r+Math.floor(a/24),u=i+(o>=19440||2==i%7&&o>=9924&&!J(e)||1==i%7&&o>=16789&&J(t));return u+(u%7==0||u%7==3||u%7==5)}(e);return t}function Q(e){return q(e+1)-q(e)}function W(e){return Q(e)%10==5}function X(e){return Q(e)%10==3}function ee(e){throw new TypeError(e)}var te="day",re="week",ne="month",ae="year",oe={d:te,w:re,M:ne,y:ae},ie={day:te,week:re,month:ne,year:ae},ue=function(){function e(t,r,n){if(u(this,e),2==arguments.length||arguments.length>3)throw new TypeError("HDate constructor requires 0, 1 or 3 arguments");if(3==arguments.length){if(this.day=this.month=1,n=parseInt(n,10),isNaN(n))throw new TypeError("HDate called with bad year argument: ".concat(n));if(this.year=n,this.setMonth(r),t=parseInt(t,10),isNaN(t))throw new TypeError("HDate called with bad day argument: ".concat(t));this.setDate(t)}else{void 0===t&&(t=new Date);var a="number"!=typeof t||isNaN(t)?d(t)?m(t):e.isHDate(t)?{dd:t.day,mm:t.month,yy:t.year}:ee("HDate called with bad argument: ".concat(t)):t,o="number"==typeof a,i=o?P(a):a;this.day=i.dd,this.month=i.mm,this.year=i.yy,o&&(this.abs0=a)}}return s(e,[{key:"getFullYear",value:function(){return this.year}},{key:"isLeapYear",value:function(){return J(this.year)}},{key:"getMonth",value:function(){return this.month}},{key:"getTishreiMonth",value:function(){var e=Z(this.getFullYear());return(this.getMonth()+e-6)%e||e}},{key:"daysInMonth",value:function(){return $(this.getMonth(),this.getFullYear())}},{key:"getDate",value:function(){return this.day}},{key:"getDay",value:function(){return f(this.abs(),7)}},{key:"setFullYear",value:function(e){return this.year=e,ce(this),this}},{key:"setMonth",value:function(t){return this.month=e.monthNum(t),ce(this),this}},{key:"setDate",value:function(e){return this.day=e,ce(this),this}},{key:"greg",value:function(){return w(this.abs())}},{key:"abs",value:function(){return"number"!=typeof this.abs0&&(this.abs0=K(this.year,this.month,this.day)),this.abs0}},{key:"getMonthName",value:function(){return G(this.getMonth(),this.getFullYear())}},{key:"render",value:function(){var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],r=(arguments.length>0&&void 0!==arguments[0]?arguments[0]:null)||T.getLocaleName(),n=this.getDate(),a=T.gettext(this.getMonthName(),r),o=T.ordinal(n,r),i=e.getDayOfTranslation(r),u="".concat(o).concat(i," ").concat(a);if(t){var c=this.getFullYear();return"".concat(u,", ").concat(c)}return u}},{key:"renderGematriya",value:function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0],t=this.getDate(),r=e?"he-x-NoNikud":"he",n=T.gettext(this.getMonthName(),r),o=this.getFullYear();return a(t)+" "+n+" "+a(o)}},{key:"before",value:function(e){return he(e,this,-1)}},{key:"onOrBefore",value:function(e){return he(e,this,0)}},{key:"nearest",value:function(e){return he(e,this,3)}},{key:"onOrAfter",value:function(e){return he(e,this,6)}},{key:"after",value:function(e){return he(e,this,7)}},{key:"next",value:function(){return new e(this.abs()+1)}},{key:"prev",value:function(){return new e(this.abs()-1)}},{key:"add",value:function(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"d";if(!(t=parseInt(t,10)))return new e(this);if((r=e.standardizeUnits(r))===te)return new e(this.abs()+t);if(r===re)return new e(this.abs()+7*t);if(r===ae)return new e(this.getDate(),this.getMonth(),this.getFullYear()+t);if(r===ne){var n=new e(this),a=t>0?1:-1;t=Math.abs(t);for(var o=0;o<t;o++)n=new e(n.abs()+a*n.daysInMonth());return n}}},{key:"subtract",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"d";return this.add(-1*e,t)}},{key:"deltaDays",value:function(t){if(!e.isHDate(t))throw new TypeError("Bad argument: ".concat(t));return this.abs()-t.abs()}},{key:"isSameDate",value:function(t){return!!e.isHDate(t)&&(this.year==t.year&&this.month==t.month&&this.day==t.day)}},{key:"toString",value:function(){var e=this.getDate(),t=this.getFullYear(),r=this.getMonthName();return"".concat(e," ").concat(r," ").concat(t)}}],[{key:"hebrew2abs",value:function(e,t,r){return K(e,t,r)}},{key:"abs2hebrew",value:function(e){return P(e)}},{key:"getDayOfTranslation",value:function(e){switch(e){case"en":case"s":case"a":case"ashkenazi":return" of"}var t=T.lookupTranslation("of",e);return t?" "+t:"ashkenazi"===e.substring(0,9)?" of":""}},{key:"standardizeUnits",value:function(e){var t=oe[e]||String(e||"").toLowerCase().replace(/s$/,"");return ie[t]||ee("Invalid units '".concat(e,"'"))}},{key:"isLeapYear",value:function(e){return J(e)}},{key:"monthsInYear",value:function(e){return Z(e)}},{key:"daysInMonth",value:function(e,t){return $(e,t)}},{key:"getMonthName",value:function(e,t){return G(e,t)}},{key:"monthNum",value:function(t){if("number"==typeof t){if(isNaN(t)||t>14)throw new RangeError("Invalid month number: ".concat(t));return t}return t.charCodeAt(0)>=48&&t.charCodeAt(0)<=57?parseInt(t,10):e.monthFromName(t)}},{key:"daysInYear",value:function(e){return Q(e)}},{key:"longCheshvan",value:function(e){return W(e)}},{key:"shortKislev",value:function(e){return X(e)}},{key:"monthFromName",value:function(e){if("number"==typeof e){if(isNaN(e)||e<1||e>14)throw new RangeError("Invalid month name: ".concat(e));return e}var t=T.hebrewStripNikkud(e).trim().toLowerCase();switch("ב"===t[0]&&(t=t.substring(1)),t[0]){case"n":case"נ":if("o"==t[1])break;return x.NISAN;case"i":return x.IYYAR;case"e":return x.ELUL;case"c":case"ח":return x.CHESHVAN;case"k":case"כ":return x.KISLEV;case"s":switch(t[1]){case"i":return x.SIVAN;case"h":return x.SHVAT}case"t":switch(t[1]){case"a":return x.TAMUZ;case"i":return x.TISHREI;case"e":return x.TEVET}break;case"a":switch(t[1]){case"v":return x.AV;case"d":return/(1|[^i]i|a|א)$/i.test(e)?x.ADAR_I:x.ADAR_II}break;case"ס":return x.SIVAN;case"ט":return x.TEVET;case"ש":return x.SHVAT;case"א":switch(t[1]){case"ב":return x.AV;case"ד":return/(1|[^i]i|a|א)$/i.test(e)?x.ADAR_I:x.ADAR_II;case"י":return x.IYYAR;case"ל":return x.ELUL}break;case"ת":switch(t[1]){case"מ":return x.TAMUZ;case"ש":return x.TISHREI}}throw new RangeError("Unable to parse month name: ".concat(e))}},{key:"dayOnOrBefore",value:function(e,t){return t-(t-e)%7}},{key:"isHDate",value:function(e){return null!==e&&"object"===i(e)&&"number"==typeof e.year&&"number"==typeof e.month&&"number"==typeof e.day&&"function"==typeof e.greg&&"function"==typeof e.abs}},{key:"fromGematriyaString",value:function(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:5e3,n=t.split(" "),a=o(n[0]),i=e.monthFromName(n[1]),u=o(n[2]);return u<1e3&&(u+=r),new e(a,i,u)}}]),e}();function ce(e){se(e),function(e){e.day<1&&(e.month==x.TISHREI&&(e.year-=1),e.day+=$(e.month,e.year),e.month-=1,ce(e));e.day>$(e.month,e.year)&&(e.month===x.ELUL&&(e.year+=1),e.day-=$(e.month,e.year),e.month+=1,ce(e));se(e)}(e)}function se(e){e.month!==x.ADAR_II||e.isLeapYear()?e.month<1?(e.month+=Z(e.year),e.year-=1,ce(e)):e.month>Z(e.year)&&(e.month-=Z(e.year),e.year+=1,ce(e)):(e.month-=1,ce(e)),delete e.abs0}function he(e,t,r){return new ue(ue.dayOnOrBefore(e,t.abs()+r))}var le=x.NISAN,fe=x.CHESHVAN,ye=x.KISLEV,ve=x.TEVET,de=x.SHVAT,me=x.ADAR_I,ge=x.ADAR_II;var we={headers:{"plural-forms":"nplurals=2; plural=(n > 1);"},contexts:{"":{Adar:["אַדָר"],"Adar I":["אַדָר א׳"],"Adar II":["אַדָר ב׳"],Av:["אָב"],Cheshvan:["חֶשְׁוָן"],Elul:["אֱלוּל"],Iyyar:["אִיָיר"],Kislev:["כִּסְלֵו"],Nisan:["נִיסָן"],"Sh'vat":["שְׁבָט"],Sivan:["סִיוָן"],Tamuz:["תַּמּוּז"],Tevet:["טֵבֵת"],Tishrei:["תִשְׁרֵי"]}}};T.addLocale("he",we),T.addLocale("h",we);var be=we.contexts[""],pe={};return Object.keys(be).forEach((function(e){pe[e]=[T.hebrewStripNikkud(be[e][0])]})),T.addLocale("he-x-NoNikud",{headers:we.headers,contexts:{"":pe}}),e.HDate=ue,e.Locale=T,e.gematriya=a,e.getBirthdayOrAnniversary=function(e,t){var r=ue.isHDate(t)?t:new ue(t),n=r.getFullYear();if(e===n)return r;if(!(e<n)){var a=J(n),o=r.getMonth(),i=r.getDate();return o==me&&!a||o==ge&&a?o=Z(e):o!=fe||30!=i||W(e)?o==ye&&30==i&&X(e)?(o=ve,i=1):o==me&&30==i&&a&&!J(e)&&(o=le,i=1):(o=ye,i=1),new ue(i,o,e)}},e.getYahrzeit=function(e,t){var r=ue.isHDate(t)?t:new ue(t),n={yy:r.getFullYear(),mm:r.getMonth(),dd:r.getDate()};if(!(e<=n.yy))return n.mm!=fe||30!=n.dd||W(n.yy+1)?n.mm==ye&&30==n.dd&&X(n.yy+1)?n=P(K(e,ve,1)-1):n.mm==ge?n.mm=Z(e):n.mm!=me||30!=n.dd||J(e)||(n.dd=30,n.mm=de):n=P(K(e,ye,1)-1),n.mm!=fe||30!=n.dd||W(e)?n.mm==ye&&30==n.dd&&X(e)&&(n.mm=ve,n.dd=1):(n.mm=ye,n.dd=1),new ue(n.dd,n.mm,e)},e.greg=b,e.months=x,e.version="4.3.0",e}({});
|
package/dist/hdate.js
CHANGED
|
@@ -1,64 +1,37 @@
|
|
|
1
|
-
/*! @hebcal/core v4.
|
|
1
|
+
/*! @hebcal/core v4.3.0 */
|
|
2
2
|
'use strict';
|
|
3
3
|
|
|
4
4
|
const GERESH = '׳';
|
|
5
5
|
const GERSHAYIM = '״';
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
return 'כ';
|
|
36
|
-
case 30:
|
|
37
|
-
return 'ל';
|
|
38
|
-
case 40:
|
|
39
|
-
return 'מ';
|
|
40
|
-
case 50:
|
|
41
|
-
return 'נ';
|
|
42
|
-
case 60:
|
|
43
|
-
return 'ס';
|
|
44
|
-
case 70:
|
|
45
|
-
return 'ע';
|
|
46
|
-
case 80:
|
|
47
|
-
return 'פ';
|
|
48
|
-
case 90:
|
|
49
|
-
return 'צ';
|
|
50
|
-
case 100:
|
|
51
|
-
return 'ק';
|
|
52
|
-
case 200:
|
|
53
|
-
return 'ר';
|
|
54
|
-
case 300:
|
|
55
|
-
return 'ש';
|
|
56
|
-
case 400:
|
|
57
|
-
return 'ת';
|
|
58
|
-
default:
|
|
59
|
-
return '*INVALID*';
|
|
60
|
-
}
|
|
61
|
-
}
|
|
6
|
+
const heb2num = {
|
|
7
|
+
'א': 1,
|
|
8
|
+
'ב': 2,
|
|
9
|
+
'ג': 3,
|
|
10
|
+
'ד': 4,
|
|
11
|
+
'ה': 5,
|
|
12
|
+
'ו': 6,
|
|
13
|
+
'ז': 7,
|
|
14
|
+
'ח': 8,
|
|
15
|
+
'ט': 9,
|
|
16
|
+
'י': 10,
|
|
17
|
+
'כ': 20,
|
|
18
|
+
'ל': 30,
|
|
19
|
+
'מ': 40,
|
|
20
|
+
'נ': 50,
|
|
21
|
+
'ס': 60,
|
|
22
|
+
'ע': 70,
|
|
23
|
+
'פ': 80,
|
|
24
|
+
'צ': 90,
|
|
25
|
+
'ק': 100,
|
|
26
|
+
'ר': 200,
|
|
27
|
+
'ש': 300,
|
|
28
|
+
'ת': 400
|
|
29
|
+
};
|
|
30
|
+
const num2heb = {};
|
|
31
|
+
Object.keys(heb2num).forEach(key => {
|
|
32
|
+
const val = heb2num[key];
|
|
33
|
+
num2heb[val] = key;
|
|
34
|
+
});
|
|
62
35
|
|
|
63
36
|
/**
|
|
64
37
|
* @private
|
|
@@ -110,23 +83,50 @@ function gematriya(number) {
|
|
|
110
83
|
if (thousands > 0 && thousands !== 5) {
|
|
111
84
|
const tdigits = num2digits(thousands);
|
|
112
85
|
for (let i = 0; i < tdigits.length; i++) {
|
|
113
|
-
str += num2heb
|
|
86
|
+
str += num2heb[tdigits[i]];
|
|
114
87
|
}
|
|
115
88
|
str += GERESH;
|
|
116
89
|
}
|
|
117
90
|
const digits = num2digits(num % 1000);
|
|
118
91
|
if (digits.length == 1) {
|
|
119
|
-
return str + num2heb
|
|
92
|
+
return str + num2heb[digits[0]] + GERESH;
|
|
120
93
|
}
|
|
121
94
|
for (let i = 0; i < digits.length; i++) {
|
|
122
95
|
if (i + 1 === digits.length) {
|
|
123
96
|
str += GERSHAYIM;
|
|
124
97
|
}
|
|
125
|
-
str += num2heb
|
|
98
|
+
str += num2heb[digits[i]];
|
|
126
99
|
}
|
|
127
100
|
return str;
|
|
128
101
|
}
|
|
129
102
|
|
|
103
|
+
/**
|
|
104
|
+
* Converts a string of Hebrew letters to a numerical value.
|
|
105
|
+
*
|
|
106
|
+
* Only considers the value of Hebrew letters `א` through `ת`.
|
|
107
|
+
* Ignores final Hebrew letters such as `ך` (kaf sofit) or `ם` (mem sofit)
|
|
108
|
+
* and vowels (nekudot).
|
|
109
|
+
*
|
|
110
|
+
* @param {string} str
|
|
111
|
+
* @return {number}
|
|
112
|
+
*/
|
|
113
|
+
function gematriyaStrToNum(str) {
|
|
114
|
+
let num = 0;
|
|
115
|
+
const gereshIdx = str.indexOf(GERESH);
|
|
116
|
+
if (gereshIdx !== -1 && gereshIdx !== str.length - 1) {
|
|
117
|
+
const thousands = str.substring(0, gereshIdx);
|
|
118
|
+
num += gematriyaStrToNum(thousands) * 1000;
|
|
119
|
+
str = str.substring(gereshIdx);
|
|
120
|
+
}
|
|
121
|
+
for (let i = 0; i < str.length; i++) {
|
|
122
|
+
const n = heb2num[str[i]];
|
|
123
|
+
if (typeof n === 'number') {
|
|
124
|
+
num += n;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
return num;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
130
|
/*
|
|
131
131
|
* More minimal greg routines
|
|
132
132
|
*/
|
|
@@ -1085,7 +1085,7 @@ class HDate {
|
|
|
1085
1085
|
/**
|
|
1086
1086
|
* Sets the day of the month of the date. Returns the object it was called upon
|
|
1087
1087
|
* @private
|
|
1088
|
-
* @param {number} month
|
|
1088
|
+
* @param {number|string} month A number, or Hebrew month name string
|
|
1089
1089
|
* @return {HDate}
|
|
1090
1090
|
*/
|
|
1091
1091
|
setMonth(month) {
|
|
@@ -1522,7 +1522,11 @@ class HDate {
|
|
|
1522
1522
|
}
|
|
1523
1523
|
return monthName;
|
|
1524
1524
|
}
|
|
1525
|
-
|
|
1525
|
+
let c = Locale.hebrewStripNikkud(monthName).trim().toLowerCase();
|
|
1526
|
+
// If Hebrew month starts with a bet (for example `בתמוז`) then ignore it
|
|
1527
|
+
if (c[0] === 'ב') {
|
|
1528
|
+
c = c.substring(1);
|
|
1529
|
+
}
|
|
1526
1530
|
/*
|
|
1527
1531
|
the Hebrew months are unique to their second letter
|
|
1528
1532
|
N Nisan (November?)
|
|
@@ -1647,6 +1651,27 @@ class HDate {
|
|
|
1647
1651
|
static isHDate(obj) {
|
|
1648
1652
|
return obj !== null && typeof obj === 'object' && typeof obj.year === 'number' && typeof obj.month === 'number' && typeof obj.day === 'number' && typeof obj.greg === 'function' && typeof obj.abs === 'function';
|
|
1649
1653
|
}
|
|
1654
|
+
|
|
1655
|
+
/**
|
|
1656
|
+
* Construct a new instance of `HDate` from a Gematriya-formatted string
|
|
1657
|
+
* @example
|
|
1658
|
+
* HDate.fromGematriyaString('כ״ז בְּתַמּוּז תשפ״ג') // 27 Tamuz 5783
|
|
1659
|
+
* HDate.fromGematriyaString('כ׳ סיון תש״ד') // 20 Sivan 5704
|
|
1660
|
+
* HDate.fromGematriyaString('ה׳ אִיָיר תש״ח') // 5 Iyyar 5708
|
|
1661
|
+
* @param {string} str
|
|
1662
|
+
* @param {number} currentThousands
|
|
1663
|
+
* @return {HDate}
|
|
1664
|
+
*/
|
|
1665
|
+
static fromGematriyaString(str, currentThousands = 5000) {
|
|
1666
|
+
const parts = str.split(' ');
|
|
1667
|
+
const day = gematriyaStrToNum(parts[0]);
|
|
1668
|
+
const month = HDate.monthFromName(parts[1]);
|
|
1669
|
+
let year = gematriyaStrToNum(parts[2]);
|
|
1670
|
+
if (year < 1000) {
|
|
1671
|
+
year += currentThousands;
|
|
1672
|
+
}
|
|
1673
|
+
return new HDate(day, month, year);
|
|
1674
|
+
}
|
|
1650
1675
|
}
|
|
1651
1676
|
|
|
1652
1677
|
/**
|
|
@@ -1801,7 +1826,7 @@ function getBirthdayOrAnniversary_(hyear, gdate) {
|
|
|
1801
1826
|
return new HDate(day, month, hyear);
|
|
1802
1827
|
}
|
|
1803
1828
|
|
|
1804
|
-
const version="4.
|
|
1829
|
+
const version="4.3.0";
|
|
1805
1830
|
|
|
1806
1831
|
const headers={"plural-forms":"nplurals=2; plural=(n > 1);"};const contexts={"":{Adar:["אַדָר"],"Adar I":["אַדָר א׳"],"Adar II":["אַדָר ב׳"],Av:["אָב"],Cheshvan:["חֶשְׁוָן"],Elul:["אֱלוּל"],Iyyar:["אִיָיר"],Kislev:["כִּסְלֵו"],Nisan:["נִיסָן"],"Sh'vat":["שְׁבָט"],Sivan:["סִיוָן"],Tamuz:["תַּמּוּז"],Tevet:["טֵבֵת"],Tishrei:["תִשְׁרֵי"]}};var poHeMin = {headers:headers,contexts:contexts};
|
|
1807
1832
|
|