@hebcal/core 5.3.13 → 5.4.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 +251 -173
- package/dist/bundle.js +11301 -11406
- package/dist/bundle.min.js +2 -2
- package/dist/event.d.ts +1 -1
- package/dist/hebcal.d.ts +8 -1
- package/dist/holidays.d.ts +1 -1
- package/dist/index.cjs +1517 -1916
- package/dist/index.d.ts +2 -4
- package/dist/index.mjs +1517 -1916
- package/dist/locale.d.ts +2 -2
- package/dist/modern.d.ts +1 -1
- package/dist/molad.d.ts +1 -1
- package/dist/pkgVersion.d.ts +1 -1
- package/dist/sedra.d.ts +1 -104
- package/dist/tachanun.d.ts +1 -1
- package/dist/zmanim.d.ts +1 -1
- package/package.json +7 -8
- package/po/ashkenazi.po +0 -195
- package/po/he.min.po +0 -50
- package/po/he.po +0 -931
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! @hebcal/core v5.
|
|
1
|
+
/*! @hebcal/core v5.4.0 */
|
|
2
2
|
/* eslint-disable @typescript-eslint/no-namespace, no-inner-declarations */
|
|
3
3
|
/** @private */
|
|
4
4
|
const lengths = [0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
|
|
@@ -541,7 +541,7 @@ const ADAR_II$1 = months.ADAR_II;
|
|
|
541
541
|
* @private
|
|
542
542
|
* @param {Object} obj
|
|
543
543
|
*/
|
|
544
|
-
function isSimpleHebrewDate(obj) {
|
|
544
|
+
function isSimpleHebrewDate$1(obj) {
|
|
545
545
|
return (typeof obj === 'object' &&
|
|
546
546
|
obj !== null &&
|
|
547
547
|
typeof obj.yy === 'number' &&
|
|
@@ -552,7 +552,7 @@ function isSimpleHebrewDate(obj) {
|
|
|
552
552
|
* @private
|
|
553
553
|
*/
|
|
554
554
|
function toSimpleHebrewDate(obj) {
|
|
555
|
-
if (isSimpleHebrewDate(obj)) {
|
|
555
|
+
if (isSimpleHebrewDate$1(obj)) {
|
|
556
556
|
return obj;
|
|
557
557
|
}
|
|
558
558
|
else if (typeof obj === 'number') {
|
|
@@ -991,230 +991,332 @@ function omerEmoji(omerDay) {
|
|
|
991
991
|
}
|
|
992
992
|
}
|
|
993
993
|
|
|
994
|
+
const _formatters = new Map();
|
|
995
|
+
/**
|
|
996
|
+
* @private
|
|
997
|
+
* @param {string} tzid
|
|
998
|
+
* @return {Intl.DateTimeFormat}
|
|
999
|
+
*/
|
|
1000
|
+
function getFormatter$1(tzid) {
|
|
1001
|
+
const fmt = _formatters.get(tzid);
|
|
1002
|
+
if (fmt)
|
|
1003
|
+
return fmt;
|
|
1004
|
+
const f = new Intl.DateTimeFormat('en-US', {
|
|
1005
|
+
year: 'numeric',
|
|
1006
|
+
month: '2-digit',
|
|
1007
|
+
day: '2-digit',
|
|
1008
|
+
hour: '2-digit',
|
|
1009
|
+
minute: '2-digit',
|
|
1010
|
+
second: '2-digit',
|
|
1011
|
+
hour12: false,
|
|
1012
|
+
timeZone: tzid,
|
|
1013
|
+
});
|
|
1014
|
+
_formatters.set(tzid, f);
|
|
1015
|
+
return f;
|
|
1016
|
+
}
|
|
1017
|
+
const dateFormatRegex = /^(\d+).(\d+).(\d+),?\s+(\d+).(\d+).(\d+)/;
|
|
1018
|
+
/**
|
|
1019
|
+
* Returns a string similar to `Date.toISOString()` but in the
|
|
1020
|
+
* timezone `tzid`. Contrary to the typical meaning of `Z` at the end
|
|
1021
|
+
* of the string, this is not actually a UTC date.
|
|
1022
|
+
* @param {string} tzid
|
|
1023
|
+
* @param {Date} date
|
|
1024
|
+
* @return {string}
|
|
1025
|
+
*/
|
|
1026
|
+
function getPseudoISO(tzid, date) {
|
|
1027
|
+
const str = getFormatter$1(tzid).format(date);
|
|
1028
|
+
const m = dateFormatRegex.exec(str);
|
|
1029
|
+
if (m === null) {
|
|
1030
|
+
throw new Error(`Unable to parse formatted string: ${str}`);
|
|
1031
|
+
}
|
|
1032
|
+
let hour = m[4];
|
|
1033
|
+
if (hour === '24') {
|
|
1034
|
+
hour = '00';
|
|
1035
|
+
}
|
|
1036
|
+
m[3] = pad4(parseInt(m[3], 10));
|
|
1037
|
+
return `${m[3]}-${m[1]}-${m[2]}T${hour}:${m[5]}:${m[6]}Z`;
|
|
1038
|
+
}
|
|
1039
|
+
/**
|
|
1040
|
+
* Returns number of minutes `tzid` is offset from UTC on date `date`.
|
|
1041
|
+
* @param {string} tzid
|
|
1042
|
+
* @param {Date} date
|
|
1043
|
+
* @return {number}
|
|
1044
|
+
*/
|
|
1045
|
+
function getTimezoneOffset(tzid, date) {
|
|
1046
|
+
const utcStr = getPseudoISO('UTC', date);
|
|
1047
|
+
const localStr = getPseudoISO(tzid, date);
|
|
1048
|
+
const diffMs = new Date(utcStr).getTime() - new Date(localStr).getTime();
|
|
1049
|
+
return Math.ceil(diffMs / 1000 / 60);
|
|
1050
|
+
}
|
|
1051
|
+
/**
|
|
1052
|
+
* Formats a number with leading zeros so the resulting string is 4 digits long.
|
|
1053
|
+
* Similar to `string.padStart(4, '0')` but will also format
|
|
1054
|
+
* negative numbers similar to how the JavaScript date formats
|
|
1055
|
+
* negative year numbers (e.g. `-37` is formatted as `-000037`).
|
|
1056
|
+
* @param {number} number
|
|
1057
|
+
* @return {string}
|
|
1058
|
+
*/
|
|
1059
|
+
function pad4(number) {
|
|
1060
|
+
if (number < 0) {
|
|
1061
|
+
return '-00' + pad4(-number);
|
|
1062
|
+
}
|
|
1063
|
+
else if (number < 10) {
|
|
1064
|
+
return '000' + number;
|
|
1065
|
+
}
|
|
1066
|
+
else if (number < 100) {
|
|
1067
|
+
return '00' + number;
|
|
1068
|
+
}
|
|
1069
|
+
else if (number < 1000) {
|
|
1070
|
+
return '0' + number;
|
|
1071
|
+
}
|
|
1072
|
+
return String(number);
|
|
1073
|
+
}
|
|
1074
|
+
/**
|
|
1075
|
+
* Formats a number with leading zeros so the resulting string is 2 digits long.
|
|
1076
|
+
* Similar to `string.padStart(2, '0')`.
|
|
1077
|
+
* @param {number} number
|
|
1078
|
+
* @return {string}
|
|
1079
|
+
*/
|
|
1080
|
+
function pad2(number) {
|
|
1081
|
+
if (number < 10) {
|
|
1082
|
+
return '0' + number;
|
|
1083
|
+
}
|
|
1084
|
+
return String(number);
|
|
1085
|
+
}
|
|
1086
|
+
/**
|
|
1087
|
+
* Returns YYYY-MM-DD in the local timezone
|
|
1088
|
+
* @private
|
|
1089
|
+
* @param {Date} dt
|
|
1090
|
+
* @return {string}
|
|
1091
|
+
*/
|
|
1092
|
+
function isoDateString(dt) {
|
|
1093
|
+
return (pad4(dt.getFullYear()) +
|
|
1094
|
+
'-' +
|
|
1095
|
+
pad2(dt.getMonth() + 1) +
|
|
1096
|
+
'-' +
|
|
1097
|
+
pad2(dt.getDate()));
|
|
1098
|
+
}
|
|
1099
|
+
|
|
1100
|
+
var poAshkenazi = { "headers": { "plural-forms": "nplurals=2; plural=(n > 1);" }, "contexts": { "": { "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"] } } };
|
|
1101
|
+
|
|
1102
|
+
var poHe = { "headers": { "plural-forms": "nplurals=2; plural=(n > 1);" }, "contexts": { "": { "Shabbat": ["שַׁבָּת"], "Daf Yomi": ["דַף יוֹמִי"], "Parashat": ["פָּרָשַׁת"], "Achrei Mot": ["אַחֲרֵי מוֹת"], "Balak": ["בָּלָק"], "Bamidbar": ["בְּמִדְבַּר"], "Bechukotai": ["בְּחֻקֹּתַי"], "Beha'alotcha": ["בְּהַעֲלֹתְךָ"], "Behar": ["בְּהַר"], "Bereshit": ["בְּרֵאשִׁית"], "Beshalach": ["בְּשַׁלַּח"], "Bo": ["בֹּא"], "Chayei Sara": ["חַיֵּי שָֹרָה"], "Chukat": ["חֻקַּת"], "Devarim": ["דְּבָרִים"], "Eikev": ["עֵקֶב"], "Emor": ["אֱמוֹר"], "Ha'azinu": ["הַאֲזִינוּ"], "Kedoshim": ["קְדשִׁים"], "Ki Tavo": ["כִּי־תָבוֹא"], "Ki Teitzei": ["כִּי־תֵצֵא"], "Ki Tisa": ["כִּי תִשָּׂא"], "Korach": ["קוֹרַח"], "Lech-Lecha": ["לֶךְ־לְךָ"], "Masei": ["מַסְעֵי"], "Matot": ["מַּטּוֹת"], "Metzora": ["מְּצֹרָע"], "Miketz": ["מִקֵּץ"], "Mishpatim": ["מִּשְׁפָּטִים"], "Nasso": ["נָשׂא"], "Nitzavim": ["נִצָּבִים"], "Noach": ["נֹחַ"], "Pekudei": ["פְקוּדֵי"], "Pinchas": ["פִּינְחָס"], "Re'eh": ["רְאֵה"], "Sh'lach": ["שְׁלַח־לְךָ"], "Shemot": ["שְׁמוֹת"], "Shmini": ["שְּׁמִינִי"], "Shoftim": ["שׁוֹפְטִים"], "Tazria": ["תַזְרִיעַ"], "Terumah": ["תְּרוּמָה"], "Tetzaveh": ["תְּצַוֶּה"], "Toldot": ["תּוֹלְדוֹת"], "Tzav": ["צַו"], "Vaera": ["וָאֵרָא"], "Vaetchanan": ["וָאֶתְחַנַּן"], "Vayakhel": ["וַיַּקְהֵל"], "Vayechi": ["וַיְחִי"], "Vayeilech": ["וַיֵּלֶךְ"], "Vayera": ["וַיֵּרָא"], "Vayeshev": ["וַיֵּשֶׁב"], "Vayetzei": ["וַיֵּצֵא"], "Vayigash": ["וַיִּגַּשׁ"], "Vayikra": ["וַיִּקְרָא"], "Vayishlach": ["וַיִּשְׁלַח"], "Vezot Haberakhah": ["וְזֹאת הַבְּרָכָה"], "Yitro": ["יִתְרוֹ"], "Asara B'Tevet": ["עֲשָׂרָה בְּטֵבֵת"], "Candle lighting": ["הַדְלָקַת נֵרוֹת"], "Chanukah": ["חֲנוּכָּה"], "Chanukah: 1 Candle": ["חֲנוּכָּה: א׳ נֵר"], "Chanukah: 2 Candles": ["חֲנוּכָּה: ב׳ נֵרוֹת"], "Chanukah: 3 Candles": ["חֲנוּכָּה: ג׳ נֵרוֹת"], "Chanukah: 4 Candles": ["חֲנוּכָּה: ד׳ נֵרוֹת"], "Chanukah: 5 Candles": ["חֲנוּכָּה: ה׳ נֵרוֹת"], "Chanukah: 6 Candles": ["חֲנוּכָּה: ו׳ נֵרוֹת"], "Chanukah: 7 Candles": ["חֲנוּכָּה: ז׳ נֵרוֹת"], "Chanukah: 8 Candles": ["חֲנוּכָּה: ח׳ נֵרוֹת"], "Chanukah: 8th Day": ["חֲנוּכָּה: יוֹם ח׳"], "Days of the Omer": ["סְפִירַת הָעוֹמֶר"], "Omer": ["עוֹמֶר"], "day of the Omer": ["בָּעוֹמֶר"], "Erev Pesach": ["עֶרֶב פֶּסַח"], "Erev Purim": ["עֶרֶב פּוּרִים"], "Erev Rosh Hashana": ["עֶרֶב רֹאשׁ הַשָּׁנָה"], "Erev Shavuot": ["עֶרֶב שָׁבוּעוֹת"], "Erev Simchat Torah": ["עֶרֶב שִׂמְחַת תּוֹרָה"], "Erev Sukkot": ["עֶרֶב סוּכּוֹת"], "Erev Tish'a B'Av": ["עֶרֶב תִּשְׁעָה בְּאָב"], "Erev Yom Kippur": ["עֶרֶב יוֹם כִּפּוּר"], "Havdalah": ["הַבְדָּלָה"], "Lag BaOmer": ["ל״ג בָּעוֹמֶר"], "Leil Selichot": ["סליחות"], "Pesach": ["פֶּסַח"], "Pesach I": ["פֶּסַח א׳"], "Pesach II": ["פֶּסַח ב׳"], "Pesach II (CH''M)": ["פֶּסַח ב׳ (חוה״מ)"], "Pesach III (CH''M)": ["פֶּסַח ג׳ (חוה״מ)"], "Pesach IV (CH''M)": ["פֶּסַח ד׳ (חוה״מ)"], "Pesach Sheni": ["פֶּסַח שני"], "Pesach V (CH''M)": ["פֶּסַח ה׳ (חוה״מ)"], "Pesach VI (CH''M)": ["פֶּסַח ו׳ (חוה״מ)"], "Pesach VII": ["פֶּסַח ז׳"], "Pesach VIII": ["פֶּסַח ח׳"], "Purim": ["פּוּרִים"], "Purim Katan": ["פּוּרִים קָטָן"], "Rosh Chodesh %s": ["רֹאשׁ חוֹדֶשׁ %s"], "Rosh Chodesh": ["רֹאשׁ חוֹדֶשׁ"], "Adar": ["אַדָר"], "Adar I": ["אַדָר א׳"], "Adar II": ["אַדָר ב׳"], "Av": ["אָב"], "Cheshvan": ["חֶשְׁוָן"], "Elul": ["אֱלוּל"], "Iyyar": ["אִיָיר"], "Kislev": ["כִּסְלֵו"], "Nisan": ["נִיסָן"], "Sh'vat": ["שְׁבָט"], "Sivan": ["סִיוָן"], "Tamuz": ["תַּמּוּז"], "Tevet": ["טֵבֵת"], "Tishrei": ["תִּשְׁרֵי"], "Rosh Hashana": ["רֹאשׁ הַשָּׁנָה"], "Rosh Hashana I": ["רֹאשׁ הַשָּׁנָה א׳"], "Rosh Hashana II": ["רֹאשׁ הַשָּׁנָה ב׳"], "Shabbat Chazon": ["שַׁבָּת חֲזוֹן"], "Shabbat HaChodesh": ["שַׁבָּת הַחֹדֶשׁ"], "Shabbat HaGadol": ["שַׁבָּת הַגָּדוֹל"], "Shabbat Machar Chodesh": ["שַׁבָּת מָחָר חוֹדֶשׁ"], "Shabbat Nachamu": ["שַׁבָּת נַחֲמוּ"], "Shabbat Parah": ["שַׁבָּת פּרה"], "Shabbat Rosh Chodesh": ["שַׁבָּת רֹאשׁ חוֹדֶשׁ"], "Shabbat Shekalim": ["שַׁבָּת שְׁקָלִים"], "Shabbat Shuva": ["שַׁבָּת שׁוּבָה"], "Shabbat Zachor": ["שַׁבָּת זָכוֹר"], "Shavuot": ["שָׁבוּעוֹת"], "Shavuot I": ["שָׁבוּעוֹת א׳"], "Shavuot II": ["שָׁבוּעוֹת ב׳"], "Shmini Atzeret": ["שְׁמִינִי עֲצֶרֶת"], "Shushan Purim": ["שׁוּשָׁן פּוּרִים"], "Sigd": ["סיגד"], "Simchat Torah": ["שִׂמְחַת תּוֹרָה"], "Sukkot": ["סוּכּוֹת"], "Sukkot I": ["סוּכּוֹת א׳"], "Sukkot II": ["סוּכּוֹת ב׳"], "Sukkot II (CH''M)": ["סוּכּוֹת ב׳ (חוה״מ)"], "Sukkot III (CH''M)": ["סוּכּוֹת ג׳ (חוה״מ)"], "Sukkot IV (CH''M)": ["סוּכּוֹת ד׳ (חוה״מ)"], "Sukkot V (CH''M)": ["סוּכּוֹת ה׳ (חוה״מ)"], "Sukkot VI (CH''M)": ["סוּכּוֹת ו׳ (חוה״מ)"], "Sukkot VII (Hoshana Raba)": ["סוּכּוֹת ז׳ (הוֹשַׁעְנָא רַבָּה)"], "Ta'anit Bechorot": ["תַּעֲנִית בְּכוֹרוֹת"], "Ta'anit Esther": ["תַּעֲנִית אֶסְתֵּר"], "Tish'a B'Av": ["תִּשְׁעָה בְּאָב"], "Tu B'Av": ["טוּ בְּאָב"], "Tu BiShvat": ["טוּ בִּשְׁבָט"], "Tu B'Shvat": ["טוּ בִּשְׁבָט"], "Tzom Gedaliah": ["צוֹם גְּדַלְיָה"], "Tzom Tammuz": ["צוֹם תָּמוּז"], "Yom HaAtzma'ut": ["יוֹם הָעַצְמָאוּת"], "Yom HaShoah": ["יוֹם הַשּׁוֹאָה"], "Yom HaZikaron": ["יוֹם הַזִּכָּרוֹן"], "Yom Kippur": ["יוֹם כִּפּוּר"], "Yom Yerushalayim": ["יוֹם יְרוּשָׁלַיִם"], "Yom HaAliyah": ["יוֹם הַעֲלִיָּה"], "Yom HaAliyah School Observance": ["שְׁמִירָת בֵּית הַסֵפֶר לְיוֹם הַעֲלִיָּה"], "Pesach I (on Shabbat)": ["פֶּסַח יוֹם א׳ (בְּשַׁבָּת)"], "Pesach Chol ha-Moed Day 1": ["פֶּסַח חוֹל הַמּוֹעֵד יוֹם א׳"], "Pesach Chol ha-Moed Day 2": ["פֶּסַח חוֹל הַמּוֹעֵד יוֹם ב׳"], "Pesach Chol ha-Moed Day 3": ["פֶּסַח חוֹל הַמּוֹעֵד יוֹם ג׳"], "Pesach Chol ha-Moed Day 4": ["פֶּסַח חוֹל הַמּוֹעֵד יוֹם ד׳"], "Pesach Chol ha-Moed Day 5": ["פֶּסַח חוֹל הַמּוֹעֵד יוֹם ה׳"], "Pesach Shabbat Chol ha-Moed": ["פֶּסַח שַׁבָּת חוֹל הַמּוֹעֵד"], "Shavuot II (on Shabbat)": ["שָׁבוּעוֹת יוֹם ב׳ (בְּשַׁבָּת)"], "Rosh Hashana I (on Shabbat)": ["רֹאשׁ הַשָּׁנָה יוֹם א׳ (בְּשַׁבָּת)"], "Yom Kippur (on Shabbat)": ["יוֹם כִּפּוּר (בְּשַׁבָּת)"], "Yom Kippur (Mincha, Traditional)": ["יוֹם כִּפּוּר מִנחָה"], "Yom Kippur (Mincha, Alternate)": ["יוֹם כִּפּוּר מִנחָה"], "Sukkot I (on Shabbat)": ["סוּכּוֹת יוֹם א׳ (בְּשַׁבָּת)"], "Sukkot Chol ha-Moed Day 1": ["סוּכּוֹת חוֹל הַמּוֹעֵד יוֹם א׳"], "Sukkot Chol ha-Moed Day 2": ["סוּכּוֹת חוֹל הַמּוֹעֵד יוֹם ב׳"], "Sukkot Chol ha-Moed Day 3": ["סוּכּוֹת חוֹל הַמּוֹעֵד יוֹם ג׳"], "Sukkot Chol ha-Moed Day 4": ["סוּכּוֹת חוֹל הַמּוֹעֵד יוֹם ד׳"], "Sukkot Chol ha-Moed Day 5": ["סוּכּוֹת חוֹל הַמּוֹעֵד יוֹם ה׳"], "Sukkot Shabbat Chol ha-Moed": ["סוּכּוֹת שַׁבָּת חוֹל הַמּוֹעֵד"], "Sukkot Final Day (Hoshana Raba)": ["סוּכּוֹת ז׳ (הוֹשַׁעְנָא רַבָּה)"], "Rosh Chodesh Adar": ["רֹאשׁ חוֹדֶשׁ אַדָר"], "Rosh Chodesh Adar I": ["רֹאשׁ חוֹדֶשׁ אַדָר א׳"], "Rosh Chodesh Adar II": ["רֹאשׁ חוֹדֶשׁ אַדָר ב׳"], "Rosh Chodesh Av": ["רֹאשׁ חוֹדֶשׁ אָב"], "Rosh Chodesh Cheshvan": ["רֹאשׁ חוֹדֶשׁ חֶשְׁוָן"], "Rosh Chodesh Elul": ["רֹאשׁ חוֹדֶשׁ אֱלוּל"], "Rosh Chodesh Iyyar": ["רֹאשׁ חוֹדֶשׁ אִיָיר"], "Rosh Chodesh Kislev": ["רֹאשׁ חוֹדֶשׁ כִּסְלֵו"], "Rosh Chodesh Nisan": ["רֹאשׁ חוֹדֶשׁ נִיסָן"], "Rosh Chodesh Sh'vat": ["רֹאשׁ חוֹדֶשׁ שְׁבָט"], "Rosh Chodesh Sivan": ["רֹאשׁ חוֹדֶשׁ סִיוָן"], "Rosh Chodesh Tamuz": ["רֹאשׁ חוֹדֶשׁ תָּמוּז"], "Rosh Chodesh Tevet": ["רֹאשׁ חוֹדֶשׁ טֵבֵת"], "min": ["דַּקּוֹת"], "Fast begins": ["תחילת הַצוֹם"], "Fast ends": ["סִיּוּם הַצוֹם"], "Rosh Hashana LaBehemot": ["רֹאשׁ הַשָּׁנָה לְמַעְשַׂר בְּהֵמָה"], "Tish'a B'Av (observed)": ["תִּשְׁעָה בְּאָב נִדחֶה"], "Shabbat Mevarchim Chodesh": ["שַׁבָּת מְבָרְכִים חוֹדֶשׁ"], "Shabbat Shirah": ["שַׁבָּת שִׁירָה"], "Chatzot HaLailah": ["חֲצוֹת הַלַיְלָה"], "Alot haShachar": ["עֲלוֹת הַשַּׁחַר"], "Misheyakir": ["מִשֶּׁיַּכִּיר"], "Misheyakir Machmir": ["מִשֶּׁיַּכִּיר מַחמִיר"], "Dawn": ["דִּימְדּוּמֵי בּוֹקֵר"], "Sunrise": ["הַנֵץ הַחַמָּה"], "Kriat Shema, sof zeman": ["סוֹף זְמַן קְרִיאַת שְׁמַע גר״א"], "Tefilah, sof zeman": ["סוֹף זְמַן תְּפִלָּה גר״א"], "Kriat Shema, sof zeman (MGA)": ["סוֹף זְמַן קְרִיאַת שְׁמַע מג״א"], "Tefilah, sof zeman (MGA)": ["סוֹף זְמַן תְּפִלָּה מג״א"], "Chatzot hayom": ["חֲצוֹת הַיּוֹם"], "Mincha Gedolah": ["מִנְחָה גְּדוֹלָה"], "Mincha Ketanah": ["מִנְחָה קְטַנָּה"], "Plag HaMincha": ["פְּלַג הַמִּנְחָה"], "Dusk": ["דִּימְדּוּמֵי עֶרֶב"], "Sunset": ["שְׁקִיעָה"], "Nightfall - End of ordained fasts": ["לַיְלָה - גמר תעניות דרבנן"], "Tzeit HaKochavim": ["צֵאת הַכּוֹכָבִים"], "Lovingkindness": ["חֶֽסֶד"], "Might": ["גְבוּרָה"], "Beauty": ["תִּפאֶרֶת"], "Eternity": ["נֶּֽצַח"], "Splendor": ["הוֹד"], "Foundation": ["יְּסוֹד"], "Majesty": ["מַּלְכוּת"], "day": ["יוֹם"], "Chanukah Day 1": ["חֲנוּכָּה יוֹם א׳"], "Chanukah Day 2": ["חֲנוּכָּה יוֹם ב׳"], "Chanukah Day 3": ["חֲנוּכָּה יוֹם ג׳"], "Chanukah Day 4": ["חֲנוּכָּה יוֹם ד׳"], "Chanukah Day 5": ["חֲנוּכָּה יוֹם ה׳"], "Chanukah Day 6": ["חֲנוּכָּה יוֹם ו׳"], "Chanukah Day 7": ["חֲנוּכָּה יוֹם ז׳"], "Chanukah Day 7 (on Rosh Chodesh)": ["חֲנוּכָּה יוֹם ז׳ (רֹאשׁ חוֹדֶשׁ)"], "Chanukah Day 8": ["חֲנוּכָּה יוֹם ח׳"], "Chanukah Day 1 (on Shabbat)": ["חֲנוּכָּה יוֹם א׳ (בְּשַׁבָּת)"], "Chanukah Day 2 (on Shabbat)": ["חֲנוּכָּה יוֹם ב׳ (בְּשַׁבָּת)"], "Chanukah Day 3 (on Shabbat)": ["חֲנוּכָּה יוֹם ג׳ (בְּשַׁבָּת)"], "Chanukah Day 4 (on Shabbat)": ["חֲנוּכָּה יוֹם ד׳ (בְּשַׁבָּת)"], "Chanukah Day 5 (on Shabbat)": ["חֲנוּכָּה יוֹם ה׳ (בְּשַׁבָּת)"], "Chanukah Day 7 (on Shabbat)": ["חֲנוּכָּה יוֹם ז׳ (בְּשַׁבָּת)"], "Chanukah Day 8 (on Shabbat)": ["חֲנוּכָּה יוֹם ח׳ (בְּשַׁבָּת)"], "Shabbat Rosh Chodesh Chanukah": ["שַׁבָּת רֹאשׁ חוֹדֶשׁ חֲנוּכָּה"], "Yom Kippur Katan": ["יוֹם כִּפּוּר קָטָן"], "Family Day": ["יוֹם הַמִּשׁפָּחָה"], "Yitzhak Rabin Memorial Day": ["יוֹם הַזִּכָּרוֹן ליצחק רבין"], "Jabotinsky Day": ["יוֹם ז׳בוטינסקי"], "Herzl Day": ["יוֹם הרצל"], "Ben-Gurion Day": ["יוֹם בן־גוריון"], "Hebrew Language Day": ["יוֹם הַשָׂפָה הַעִברִית"], "Birkat Hachamah": ["בִרְכַּת הַחַמָּה"], "Shushan Purim Katan": ["שׁוּשָׁן פּוּרִים קָטָן"], "Purim Meshulash": ["פּוּרִים מְשׁוּלָּשׁ"], "after sunset": ["לְאַחַר הַשְׁקִיעָה"], "Yerushalmi": ["יְרוּשַׁלְמִי"], "Chag HaBanot": ["חַג הַבָּנוֹת"], "Joshua": ["יְהוֹשׁוּעַ"], "Judges": ["שׁוֹפְטִים"], "I Samuel": ["שְׁמוּאֵל רִאשׁוֹן"], "II Samuel": ["שְׁמוּאֵל שֵׁנִי"], "I Kings": ["מְלָכִים רִאשׁוֹן"], "II Kings": ["מְלָכִים שֵׁנִי"], "Isaiah": ["יְשַׁעְיָהוּ"], "Jeremiah": ["יִרְמְיָהוּ"], "Ezekiel": ["יְחֶזְקֵאל"], "Hosea": ["הוֹשֵׁעַ"], "Joel": ["יוֹאֵל"], "Amos": ["עָמוּס"], "Obadiah": ["עוֹבַדְיָה"], "Jonah": ["יוֹנָה"], "Micah": ["מִיכָה"], "Nachum": ["נַחוּם"], "Habakkuk": ["חֲבַקּוּק"], "Zephaniah": ["צְפַנְיָה"], "Haggai": ["חַגַּי"], "Zechariah": ["זְכַרְיָה"], "Malachi": ["מַלְאָכִי"], "Psalms": ["תְּהִלִּים"], "Proverbs": ["מִשְׁלֵי"], "Job": ["אִיּוֹב"], "Song of Songs": ["שִׁיר הַשִּׁירִים"], "Ruth": ["רוּת"], "Lamentations": ["אֵיכָה"], "Ecclesiastes": ["קֹהֶלֶת"], "Esther": ["אֶסְתֵּר"], "Daniel": ["דָּנִיֵּאל"], "Ezra": ["עֶזְרָא"], "Nehemiah": ["נְחֶמְיָה"], "I Chronicles": ["דִברֵי הַיָמִים רִאשׁוֹן"], "II Chronicles": ["דִברֵי הַיָמִים שֵׁנִי"], "Yom Kippur (Mincha)": ["יוֹם כִּפּוּר מִנחָה"], "Tish'a B'Av (Mincha)": ["תִּשְׁעָה בְּאָב מִנחָה"], "Asara B'Tevet (Mincha)": ["עֲשָׂרָה בְּטֵבֵת מִנחָה"], "Ta'anit Bechorot (Mincha)": ["תַּעֲנִית בְּכוֹרוֹת מִנחָה"], "Ta'anit Esther (Mincha)": ["תַּעֲנִית אֶסְתֵּר מִנחָה"], "Tzom Gedaliah (Mincha)": ["צוֹם גְּדַלְיָה מִנחָה"], "Tzom Tammuz (Mincha)": ["צוֹם תָּמוּז מִנחָה"], "Molad": ["מוֹלָד הָלְּבָנָה"], "chalakim": ["חֲלָקִים"], "Pirkei Avot": ["פִּרְקֵי אָבוֹת"] } } };
|
|
1103
|
+
|
|
994
1104
|
const noopLocale = {
|
|
995
|
-
|
|
996
|
-
'
|
|
997
|
-
},
|
|
998
|
-
contexts: {
|
|
999
|
-
'': {}
|
|
1000
|
-
}
|
|
1105
|
+
headers: { 'plural-forms': 'nplurals=2; plural=(n!=1);' },
|
|
1106
|
+
contexts: { '': {} },
|
|
1001
1107
|
};
|
|
1002
1108
|
const alias = {
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1109
|
+
'h': 'he',
|
|
1110
|
+
'a': 'ashkenazi',
|
|
1111
|
+
's': 'en',
|
|
1112
|
+
'': 'en',
|
|
1007
1113
|
};
|
|
1008
|
-
|
|
1009
1114
|
/** @private */
|
|
1010
1115
|
const locales = new Map();
|
|
1011
1116
|
/** @private */
|
|
1012
|
-
let activeLocale
|
|
1117
|
+
let activeLocale;
|
|
1013
1118
|
/** @private */
|
|
1014
|
-
let activeName
|
|
1015
|
-
|
|
1119
|
+
let activeName;
|
|
1016
1120
|
/**
|
|
1017
1121
|
* A locale in Hebcal is used for translations/transliterations of
|
|
1018
|
-
* holidays. `@hebcal/
|
|
1122
|
+
* holidays. `@hebcal/hdate` supports four locales by default
|
|
1019
1123
|
* * `en` - default, Sephardic transliterations (e.g. "Shabbat")
|
|
1020
1124
|
* * `ashkenazi` - Ashkenazi transliterations (e.g. "Shabbos")
|
|
1021
1125
|
* * `he` - Hebrew (e.g. "שַׁבָּת")
|
|
1022
1126
|
* * `he-x-NoNikud` - Hebrew without nikud (e.g. "שבת")
|
|
1023
1127
|
*/
|
|
1024
1128
|
class Locale {
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1129
|
+
/**
|
|
1130
|
+
* Returns translation only if `locale` offers a non-empty translation for `id`.
|
|
1131
|
+
* Otherwise, returns `undefined`.
|
|
1132
|
+
* @param {string} id Message ID to translate
|
|
1133
|
+
* @param {string} [locale] Optional locale name (i.e: `'he'`, `'fr'`). Defaults to active locale.
|
|
1134
|
+
* @return {string}
|
|
1135
|
+
*/
|
|
1136
|
+
static lookupTranslation(id, locale) {
|
|
1137
|
+
const loc = (typeof locale === 'string' && locales.get(locale.toLowerCase())) || activeLocale;
|
|
1138
|
+
const array = loc[id];
|
|
1139
|
+
if ((array === null || array === void 0 ? void 0 : array.length) && array[0].length) {
|
|
1140
|
+
return array[0];
|
|
1141
|
+
}
|
|
1142
|
+
return undefined;
|
|
1038
1143
|
}
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
return id;
|
|
1144
|
+
/**
|
|
1145
|
+
* By default, if no translation was found, returns `id`.
|
|
1146
|
+
* @param {string} id Message ID to translate
|
|
1147
|
+
* @param {string} [locale] Optional locale name (i.e: `'he'`, `'fr'`). Defaults to active locale.
|
|
1148
|
+
* @return {string}
|
|
1149
|
+
*/
|
|
1150
|
+
static gettext(id, locale) {
|
|
1151
|
+
const text = this.lookupTranslation(id, locale);
|
|
1152
|
+
if (typeof text === 'undefined') {
|
|
1153
|
+
return id;
|
|
1154
|
+
}
|
|
1155
|
+
return text;
|
|
1052
1156
|
}
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1157
|
+
/**
|
|
1158
|
+
* Register locale translations.
|
|
1159
|
+
* @param {string} locale Locale name (i.e.: `'he'`, `'fr'`)
|
|
1160
|
+
* @param {LocaleData} data parsed data from a `.po` file.
|
|
1161
|
+
*/
|
|
1162
|
+
static addLocale(locale, data) {
|
|
1163
|
+
if (typeof locale !== 'string') {
|
|
1164
|
+
throw new TypeError(`Invalid locale name: ${locale}`);
|
|
1165
|
+
}
|
|
1166
|
+
if (typeof data.contexts !== 'object' || typeof data.contexts[''] !== 'object') {
|
|
1167
|
+
throw new TypeError(`Locale '${locale}' invalid compact format`);
|
|
1168
|
+
}
|
|
1169
|
+
locales.set(locale.toLowerCase(), data.contexts['']);
|
|
1064
1170
|
}
|
|
1065
|
-
|
|
1066
|
-
|
|
1171
|
+
/**
|
|
1172
|
+
* Adds a translation to `locale`, replacing any previous translation.
|
|
1173
|
+
* @param {string} locale Locale name (i.e: `'he'`, `'fr'`).
|
|
1174
|
+
* @param {string} id Message ID to translate
|
|
1175
|
+
* @param {string} translation Translation text
|
|
1176
|
+
*/
|
|
1177
|
+
static addTranslation(locale, id, translation) {
|
|
1178
|
+
if (typeof locale !== 'string') {
|
|
1179
|
+
throw new TypeError(`Invalid locale name: ${locale}`);
|
|
1180
|
+
}
|
|
1181
|
+
const loc = locales.get(locale.toLowerCase());
|
|
1182
|
+
if (!loc) {
|
|
1183
|
+
throw new TypeError(`Unknown locale: ${locale}`);
|
|
1184
|
+
}
|
|
1185
|
+
if (typeof id !== 'string' || id.length === 0) {
|
|
1186
|
+
throw new TypeError(`Invalid id: ${id}`);
|
|
1187
|
+
}
|
|
1188
|
+
const isArray = Array.isArray(translation);
|
|
1189
|
+
if (isArray) {
|
|
1190
|
+
const t0 = translation[0];
|
|
1191
|
+
if (typeof t0 !== 'string' || t0.length === 0) {
|
|
1192
|
+
throw new TypeError(`Invalid translation array: ${translation}`);
|
|
1193
|
+
}
|
|
1194
|
+
}
|
|
1195
|
+
else if (typeof translation !== 'string') {
|
|
1196
|
+
throw new TypeError(`Invalid translation: ${translation}`);
|
|
1197
|
+
}
|
|
1198
|
+
loc[id] = isArray ? translation : [translation];
|
|
1067
1199
|
}
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
if (typeof id !== 'string' || id.length === 0) {
|
|
1087
|
-
throw new TypeError(`Invalid id: ${id}`);
|
|
1088
|
-
}
|
|
1089
|
-
const isArray = Array.isArray(translation);
|
|
1090
|
-
if (isArray) {
|
|
1091
|
-
const t0 = translation[0];
|
|
1092
|
-
if (typeof t0 !== 'string' || t0.length === 0) {
|
|
1093
|
-
throw new TypeError(`Invalid translation array: ${translation}`);
|
|
1094
|
-
}
|
|
1095
|
-
} else if (typeof translation !== 'string') {
|
|
1096
|
-
throw new TypeError(`Invalid translation: ${translation}`);
|
|
1200
|
+
/**
|
|
1201
|
+
* Adds multiple translations to `locale`, replacing any previous translations.
|
|
1202
|
+
* @param {string} locale Locale name (i.e: `'he'`, `'fr'`).
|
|
1203
|
+
* @param {LocaleData} data parsed data from a `.po` file.
|
|
1204
|
+
*/
|
|
1205
|
+
static addTranslations(locale, data) {
|
|
1206
|
+
if (typeof locale !== 'string') {
|
|
1207
|
+
throw new TypeError(`Invalid locale name: ${locale}`);
|
|
1208
|
+
}
|
|
1209
|
+
const loc = locales.get(locale.toLowerCase());
|
|
1210
|
+
if (!loc) {
|
|
1211
|
+
throw new TypeError(`Unknown locale: ${locale}`);
|
|
1212
|
+
}
|
|
1213
|
+
if (typeof data.contexts !== 'object' || typeof data.contexts[''] !== 'object') {
|
|
1214
|
+
throw new TypeError(`Locale '${locale}' invalid compact format`);
|
|
1215
|
+
}
|
|
1216
|
+
const ctx = data.contexts[''];
|
|
1217
|
+
Object.assign(loc, ctx);
|
|
1097
1218
|
}
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1219
|
+
/**
|
|
1220
|
+
* Activates a locale. Throws an error if the locale has not been previously added.
|
|
1221
|
+
* After setting the locale to be used, all strings marked for translations
|
|
1222
|
+
* will be represented by the corresponding translation in the specified locale.
|
|
1223
|
+
* @param {string} locale Locale name (i.e: `'he'`, `'fr'`)
|
|
1224
|
+
*/
|
|
1225
|
+
static useLocale(locale) {
|
|
1226
|
+
const locale0 = locale.toLowerCase();
|
|
1227
|
+
const obj = locales.get(locale0);
|
|
1228
|
+
if (!obj) {
|
|
1229
|
+
throw new RangeError(`Locale '${locale}' not found`);
|
|
1230
|
+
}
|
|
1231
|
+
activeName = alias[locale0] || locale0;
|
|
1232
|
+
activeLocale = obj;
|
|
1233
|
+
return activeLocale;
|
|
1108
1234
|
}
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1235
|
+
/**
|
|
1236
|
+
* Returns the name of the active locale (i.e. 'he', 'ashkenazi', 'fr')
|
|
1237
|
+
* @return {string}
|
|
1238
|
+
*/
|
|
1239
|
+
static getLocaleName() {
|
|
1240
|
+
return activeName;
|
|
1113
1241
|
}
|
|
1114
|
-
|
|
1115
|
-
|
|
1242
|
+
/**
|
|
1243
|
+
* Returns the names of registered locales
|
|
1244
|
+
* @return {string[]}
|
|
1245
|
+
*/
|
|
1246
|
+
static getLocaleNames() {
|
|
1247
|
+
const keys = Array.from(locales.keys());
|
|
1248
|
+
return keys.sort((a, b) => a.localeCompare(b));
|
|
1116
1249
|
}
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1250
|
+
/**
|
|
1251
|
+
* @param {number} n
|
|
1252
|
+
* @param {string} [locale] Optional locale name (i.e: `'he'`, `'fr'`). Defaults to active locale.
|
|
1253
|
+
* @return {string}
|
|
1254
|
+
*/
|
|
1255
|
+
static ordinal(n, locale) {
|
|
1256
|
+
const locale1 = locale === null || locale === void 0 ? void 0 : locale.toLowerCase();
|
|
1257
|
+
const locale0 = locale1 || activeName;
|
|
1258
|
+
if (!locale0) {
|
|
1259
|
+
return this.getEnOrdinal(n);
|
|
1260
|
+
}
|
|
1261
|
+
switch (locale0) {
|
|
1262
|
+
case 'en':
|
|
1263
|
+
case 's':
|
|
1264
|
+
case 'a':
|
|
1265
|
+
case 'ashkenazi':
|
|
1266
|
+
case 'ashkenazi_litvish':
|
|
1267
|
+
case 'ashkenazi_poylish':
|
|
1268
|
+
case 'ashkenazi_standard':
|
|
1269
|
+
return this.getEnOrdinal(n);
|
|
1270
|
+
case 'es':
|
|
1271
|
+
return n + 'º';
|
|
1272
|
+
case 'h':
|
|
1273
|
+
case 'he':
|
|
1274
|
+
case 'he-x-nonikud':
|
|
1275
|
+
return String(n);
|
|
1276
|
+
default:
|
|
1277
|
+
return n + '.';
|
|
1278
|
+
}
|
|
1132
1279
|
}
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
static getLocaleName() {
|
|
1143
|
-
return activeName;
|
|
1144
|
-
}
|
|
1145
|
-
|
|
1146
|
-
/**
|
|
1147
|
-
* Returns the names of registered locales
|
|
1148
|
-
* @return {string[]}
|
|
1149
|
-
*/
|
|
1150
|
-
static getLocaleNames() {
|
|
1151
|
-
const keys = Array.from(locales.keys());
|
|
1152
|
-
return keys.sort((a, b) => a.localeCompare(b));
|
|
1153
|
-
}
|
|
1154
|
-
|
|
1155
|
-
/**
|
|
1156
|
-
* @param {number} n
|
|
1157
|
-
* @param {string} [locale] Optional locale name (i.e: `'he'`, `'fr'`). Defaults to active locale.
|
|
1158
|
-
* @return {string}
|
|
1159
|
-
*/
|
|
1160
|
-
static ordinal(n, locale) {
|
|
1161
|
-
const locale1 = locale === null || locale === void 0 ? void 0 : locale.toLowerCase();
|
|
1162
|
-
const locale0 = locale1 || activeName;
|
|
1163
|
-
if (!locale0) {
|
|
1164
|
-
return this.getEnOrdinal(n);
|
|
1280
|
+
/**
|
|
1281
|
+
* @private
|
|
1282
|
+
* @param {number} n
|
|
1283
|
+
* @return {string}
|
|
1284
|
+
*/
|
|
1285
|
+
static getEnOrdinal(n) {
|
|
1286
|
+
const s = ['th', 'st', 'nd', 'rd'];
|
|
1287
|
+
const v = n % 100;
|
|
1288
|
+
return n + (s[(v - 20) % 10] || s[v] || s[0]);
|
|
1165
1289
|
}
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
case 'ashkenazi_standard':
|
|
1174
|
-
return this.getEnOrdinal(n);
|
|
1175
|
-
case 'es':
|
|
1176
|
-
return n + 'º';
|
|
1177
|
-
case 'h':
|
|
1178
|
-
case 'he':
|
|
1179
|
-
case 'he-x-nonikud':
|
|
1180
|
-
return String(n);
|
|
1181
|
-
default:
|
|
1182
|
-
return n + '.';
|
|
1290
|
+
/**
|
|
1291
|
+
* Removes nekudot from Hebrew string
|
|
1292
|
+
* @param {string} str
|
|
1293
|
+
* @return {string}
|
|
1294
|
+
*/
|
|
1295
|
+
static hebrewStripNikkud(str) {
|
|
1296
|
+
return str.replace(/[\u0590-\u05bd]/g, '').replace(/[\u05bf-\u05c7]/g, '');
|
|
1183
1297
|
}
|
|
1184
|
-
}
|
|
1185
|
-
|
|
1186
|
-
/**
|
|
1187
|
-
* @private
|
|
1188
|
-
* @param {number} n
|
|
1189
|
-
* @return {string}
|
|
1190
|
-
*/
|
|
1191
|
-
static getEnOrdinal(n) {
|
|
1192
|
-
const s = ['th', 'st', 'nd', 'rd'];
|
|
1193
|
-
const v = n % 100;
|
|
1194
|
-
return n + (s[(v - 20) % 10] || s[v] || s[0]);
|
|
1195
|
-
}
|
|
1196
|
-
|
|
1197
|
-
/**
|
|
1198
|
-
* Removes nekudot from Hebrew string
|
|
1199
|
-
* @param {string} str
|
|
1200
|
-
* @return {string}
|
|
1201
|
-
*/
|
|
1202
|
-
static hebrewStripNikkud(str) {
|
|
1203
|
-
return str.replace(/[\u0590-\u05bd]/g, '').replace(/[\u05bf-\u05c7]/g, '');
|
|
1204
|
-
}
|
|
1205
1298
|
}
|
|
1206
1299
|
Locale.addLocale('en', noopLocale);
|
|
1207
1300
|
Locale.addLocale('s', noopLocale);
|
|
1208
1301
|
Locale.addLocale('', noopLocale);
|
|
1209
1302
|
Locale.useLocale('en');
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1303
|
+
/* Ashkenazic transliterations */
|
|
1304
|
+
Locale.addLocale('ashkenazi', poAshkenazi);
|
|
1305
|
+
Locale.addLocale('a', poAshkenazi);
|
|
1306
|
+
/* Hebrew with nikkud */
|
|
1307
|
+
Locale.addLocale('he', poHe);
|
|
1308
|
+
Locale.addLocale('h', poHe);
|
|
1309
|
+
/* Hebrew without nikkud */
|
|
1310
|
+
const heStrs = poHe.contexts[''];
|
|
1311
|
+
const heNoNikud = {};
|
|
1312
|
+
for (const [key, val] of Object.entries(heStrs)) {
|
|
1313
|
+
heNoNikud[key] = [Locale.hebrewStripNikkud(val[0])];
|
|
1217
1314
|
}
|
|
1315
|
+
const poHeNoNikud = {
|
|
1316
|
+
headers: poHe.headers,
|
|
1317
|
+
contexts: { '': heNoNikud },
|
|
1318
|
+
};
|
|
1319
|
+
Locale.addLocale('he-x-NoNikud', poHeNoNikud);
|
|
1218
1320
|
|
|
1219
1321
|
/*
|
|
1220
1322
|
Hebcal - A Jewish Calendar Generator
|
|
@@ -1236,738 +1338,1070 @@ function throwTypeError(msg) {
|
|
|
1236
1338
|
You should have received a copy of the GNU General Public License
|
|
1237
1339
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
1238
1340
|
*/
|
|
1239
|
-
|
|
1240
1341
|
// eslint-disable-next-line require-jsdoc
|
|
1241
1342
|
function mod(x, y) {
|
|
1242
|
-
|
|
1343
|
+
return x - y * Math.floor(x / y);
|
|
1344
|
+
}
|
|
1345
|
+
function isSimpleHebrewDate(obj) {
|
|
1346
|
+
return obj.yy !== undefined;
|
|
1243
1347
|
}
|
|
1244
1348
|
const UNITS_DAY = 'day';
|
|
1245
1349
|
const UNITS_WEEK = 'week';
|
|
1246
1350
|
const UNITS_MONTH = 'month';
|
|
1247
1351
|
const UNITS_YEAR = 'year';
|
|
1248
|
-
const UNITS_SINGLE = {
|
|
1249
|
-
d: UNITS_DAY,
|
|
1250
|
-
w: UNITS_WEEK,
|
|
1251
|
-
M: UNITS_MONTH,
|
|
1252
|
-
y: UNITS_YEAR
|
|
1253
|
-
};
|
|
1254
|
-
const UNITS_VALID = {
|
|
1255
|
-
day: UNITS_DAY,
|
|
1256
|
-
week: UNITS_WEEK,
|
|
1257
|
-
month: UNITS_MONTH,
|
|
1258
|
-
year: UNITS_YEAR
|
|
1259
|
-
};
|
|
1260
|
-
|
|
1261
|
-
/**
|
|
1262
|
-
* A simple Hebrew date object with numeric fields `yy`, `mm`, and `dd`
|
|
1263
|
-
* @typedef {Object} SimpleHebrewDate
|
|
1264
|
-
* @property {number} yy Hebrew year
|
|
1265
|
-
* @property {number} mm Hebrew month of year (1=NISAN, 7=TISHREI)
|
|
1266
|
-
* @property {number} dd Day of month (1-30)
|
|
1267
|
-
* @private
|
|
1268
|
-
*/
|
|
1269
|
-
|
|
1270
1352
|
/** Represents a Hebrew date */
|
|
1271
1353
|
class HDate {
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
/**
|
|
1343
|
-
* @private
|
|
1344
|
-
* @type {number}
|
|
1345
|
-
*/
|
|
1346
|
-
this.mm = d.mm;
|
|
1347
|
-
/**
|
|
1348
|
-
* @private
|
|
1349
|
-
* @type {number}
|
|
1350
|
-
*/
|
|
1351
|
-
this.yy = d.yy;
|
|
1352
|
-
if (isNumber) {
|
|
1353
|
-
/**
|
|
1354
|
-
* @private
|
|
1355
|
-
* @type {number}
|
|
1356
|
-
*/
|
|
1357
|
-
this.rd = abs0;
|
|
1358
|
-
}
|
|
1354
|
+
/**
|
|
1355
|
+
* Create a Hebrew date. There are 3 basic forms for the `HDate()` constructor.
|
|
1356
|
+
*
|
|
1357
|
+
* 1. No parameters - represents the current Hebrew date at time of instantiation
|
|
1358
|
+
* 2. One parameter
|
|
1359
|
+
* * `Date` - represents the Hebrew date corresponding to the Gregorian date using
|
|
1360
|
+
* local time. Hours, minutes, seconds and milliseconds are ignored.
|
|
1361
|
+
* * `HDate` - clones a copy of the given Hebrew date
|
|
1362
|
+
* * `number` - Converts absolute R.D. days to Hebrew date.
|
|
1363
|
+
* R.D. 1 == the imaginary date January 1, 1 (Gregorian)
|
|
1364
|
+
* 3. Three parameters: Hebrew day, Hebrew month, Hebrew year. Hebrew day should
|
|
1365
|
+
* be a number between 1-30, Hebrew month can be a number or string, and
|
|
1366
|
+
* Hebrew year is always a number.
|
|
1367
|
+
* @example
|
|
1368
|
+
* import {HDate, months} from '@hebcal/hdate';
|
|
1369
|
+
*
|
|
1370
|
+
* const hd1 = new HDate();
|
|
1371
|
+
* const hd2 = new HDate(new Date(2008, 10, 13));
|
|
1372
|
+
* const hd3 = new HDate(15, 'Cheshvan', 5769);
|
|
1373
|
+
* const hd4 = new HDate(15, months.CHESHVAN, 5769);
|
|
1374
|
+
* const hd5 = new HDate(733359); // ==> 15 Cheshvan 5769
|
|
1375
|
+
* const monthName = 'אייר';
|
|
1376
|
+
* const hd6 = new HDate(5, monthName, 5773);
|
|
1377
|
+
* @param {number|Date|HDate} [day] - Day of month (1-30) if a `number`.
|
|
1378
|
+
* If a `Date` is specified, represents the Hebrew date corresponding to the
|
|
1379
|
+
* Gregorian date using local time.
|
|
1380
|
+
* If an `HDate` is specified, clones a copy of the given Hebrew date.
|
|
1381
|
+
* @param {number|string} [month] - Hebrew month of year (1=NISAN, 7=TISHREI)
|
|
1382
|
+
* @param {number} [year] - Hebrew year
|
|
1383
|
+
*/
|
|
1384
|
+
constructor(day, month, year) {
|
|
1385
|
+
if (arguments.length === 2 || arguments.length > 3) {
|
|
1386
|
+
throw new TypeError('HDate constructor requires 0, 1 or 3 arguments');
|
|
1387
|
+
}
|
|
1388
|
+
if (arguments.length === 3) {
|
|
1389
|
+
// Hebrew day, Hebrew month, Hebrew year
|
|
1390
|
+
this.dd = this.mm = 1;
|
|
1391
|
+
const yy = typeof year === 'string' ? parseInt(year, 10) : year;
|
|
1392
|
+
if (isNaN(yy)) {
|
|
1393
|
+
throw new TypeError(`HDate called with bad year argument: ${year}`);
|
|
1394
|
+
}
|
|
1395
|
+
this.yy = yy;
|
|
1396
|
+
setMonth(this, month); // will throw if we can't parse
|
|
1397
|
+
const dd = typeof day === 'string' ? parseInt(day, 10) : day;
|
|
1398
|
+
if (isNaN(dd)) {
|
|
1399
|
+
throw new TypeError(`HDate called with bad day argument: ${day}`);
|
|
1400
|
+
}
|
|
1401
|
+
setDate(this, dd);
|
|
1402
|
+
}
|
|
1403
|
+
else {
|
|
1404
|
+
// 0 arguments
|
|
1405
|
+
if (typeof day === 'undefined' || day === null) {
|
|
1406
|
+
day = new Date();
|
|
1407
|
+
}
|
|
1408
|
+
// 1 argument
|
|
1409
|
+
const abs0 = (typeof day === 'number' && !isNaN(day)) ? day :
|
|
1410
|
+
greg.isDate(day) ? greg.greg2abs(day) :
|
|
1411
|
+
isSimpleHebrewDate(day) ? day : null;
|
|
1412
|
+
if (abs0 === null) {
|
|
1413
|
+
throw new TypeError(`HDate called with bad argument: ${day}`);
|
|
1414
|
+
}
|
|
1415
|
+
const isNumber = typeof abs0 === 'number';
|
|
1416
|
+
const d = isNumber ? abs2hebrew(abs0) : abs0;
|
|
1417
|
+
this.yy = d.yy;
|
|
1418
|
+
this.mm = d.mm;
|
|
1419
|
+
this.dd = d.dd;
|
|
1420
|
+
if (isNumber) {
|
|
1421
|
+
this.rd = abs0;
|
|
1422
|
+
}
|
|
1423
|
+
}
|
|
1359
1424
|
}
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
getFullYear() {
|
|
1367
|
-
return this.yy;
|
|
1368
|
-
}
|
|
1369
|
-
|
|
1370
|
-
/**
|
|
1371
|
-
* Tests if this date occurs during a leap year
|
|
1372
|
-
* @return {boolean}
|
|
1373
|
-
*/
|
|
1374
|
-
isLeapYear() {
|
|
1375
|
-
return isLeapYear(this.yy);
|
|
1376
|
-
}
|
|
1377
|
-
|
|
1378
|
-
/**
|
|
1379
|
-
* Gets the Hebrew month (1=NISAN, 7=TISHREI) of this Hebrew date
|
|
1380
|
-
* @return {number}
|
|
1381
|
-
*/
|
|
1382
|
-
getMonth() {
|
|
1383
|
-
return this.mm;
|
|
1384
|
-
}
|
|
1385
|
-
|
|
1386
|
-
/**
|
|
1387
|
-
* The Tishrei-based month of the date. 1 is Tishrei, 7 is Nisan, 13 is Elul in a leap year
|
|
1388
|
-
* @return {number}
|
|
1389
|
-
*/
|
|
1390
|
-
getTishreiMonth() {
|
|
1391
|
-
const nummonths = monthsInYear(this.getFullYear());
|
|
1392
|
-
return (this.getMonth() + nummonths - 6) % nummonths || nummonths;
|
|
1393
|
-
}
|
|
1394
|
-
|
|
1395
|
-
/**
|
|
1396
|
-
* Number of days in the month of this Hebrew date
|
|
1397
|
-
* @return {number}
|
|
1398
|
-
*/
|
|
1399
|
-
daysInMonth() {
|
|
1400
|
-
return daysInMonth(this.getMonth(), this.getFullYear());
|
|
1401
|
-
}
|
|
1402
|
-
|
|
1403
|
-
/**
|
|
1404
|
-
* Gets the day within the month (1-30)
|
|
1405
|
-
* @return {number}
|
|
1406
|
-
*/
|
|
1407
|
-
getDate() {
|
|
1408
|
-
return this.dd;
|
|
1409
|
-
}
|
|
1410
|
-
|
|
1411
|
-
/**
|
|
1412
|
-
* Gets the day of the week. 0=Sunday, 6=Saturday
|
|
1413
|
-
* @return {number}
|
|
1414
|
-
*/
|
|
1415
|
-
getDay() {
|
|
1416
|
-
return mod(this.abs(), 7);
|
|
1417
|
-
}
|
|
1418
|
-
|
|
1419
|
-
/**
|
|
1420
|
-
* Sets the day of the month of the date. Returns the object it was called upon
|
|
1421
|
-
* @private
|
|
1422
|
-
* @param {number|string} month A number, or Hebrew month name string
|
|
1423
|
-
* @return {HDate}
|
|
1424
|
-
*/
|
|
1425
|
-
setMonth(month) {
|
|
1426
|
-
this.mm = HDate.monthNum(month);
|
|
1427
|
-
fix(this);
|
|
1428
|
-
return this;
|
|
1429
|
-
}
|
|
1430
|
-
|
|
1431
|
-
/**
|
|
1432
|
-
* @private
|
|
1433
|
-
* @param {number} date
|
|
1434
|
-
* @return {HDate}
|
|
1435
|
-
*/
|
|
1436
|
-
setDate(date) {
|
|
1437
|
-
this.dd = date;
|
|
1438
|
-
fix(this);
|
|
1439
|
-
return this;
|
|
1440
|
-
}
|
|
1441
|
-
|
|
1442
|
-
/**
|
|
1443
|
-
* Converts to Gregorian date
|
|
1444
|
-
* @return {Date}
|
|
1445
|
-
*/
|
|
1446
|
-
greg() {
|
|
1447
|
-
return greg.abs2greg(this.abs());
|
|
1448
|
-
}
|
|
1449
|
-
|
|
1450
|
-
/**
|
|
1451
|
-
* Returns R.D. (Rata Die) fixed days.
|
|
1452
|
-
* R.D. 1 == Monday, January 1, 1 (Gregorian)
|
|
1453
|
-
* Note also that R.D. = Julian Date − 1,721,424.5
|
|
1454
|
-
* https://en.wikipedia.org/wiki/Rata_Die#Dershowitz_and_Reingold
|
|
1455
|
-
* @return {number}
|
|
1456
|
-
*/
|
|
1457
|
-
abs() {
|
|
1458
|
-
if (typeof this.rd !== 'number') {
|
|
1459
|
-
this.rd = hebrew2abs(this.yy, this.mm, this.dd);
|
|
1425
|
+
/**
|
|
1426
|
+
* Gets the Hebrew year of this Hebrew date
|
|
1427
|
+
* @return {number}
|
|
1428
|
+
*/
|
|
1429
|
+
getFullYear() {
|
|
1430
|
+
return this.yy;
|
|
1460
1431
|
}
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
* Calendar.
|
|
1468
|
-
* @param {number} year Hebrew year
|
|
1469
|
-
* @param {number} month Hebrew month
|
|
1470
|
-
* @param {number} day Hebrew date (1-30)
|
|
1471
|
-
* @return {number}
|
|
1472
|
-
*/
|
|
1473
|
-
static hebrew2abs(year, month, day) {
|
|
1474
|
-
return hebrew2abs(year, month, day);
|
|
1475
|
-
}
|
|
1476
|
-
|
|
1477
|
-
/**
|
|
1478
|
-
* Returns a transliterated Hebrew month name, e.g. `'Elul'` or `'Cheshvan'`.
|
|
1479
|
-
* @return {string}
|
|
1480
|
-
*/
|
|
1481
|
-
getMonthName() {
|
|
1482
|
-
return getMonthName(this.getMonth(), this.getFullYear());
|
|
1483
|
-
}
|
|
1484
|
-
|
|
1485
|
-
/**
|
|
1486
|
-
* Renders this Hebrew date as a translated or transliterated string,
|
|
1487
|
-
* including ordinal e.g. `'15th of Cheshvan, 5769'`.
|
|
1488
|
-
* @example
|
|
1489
|
-
* import {HDate, months} from '@hebcal/core';
|
|
1490
|
-
*
|
|
1491
|
-
* const hd = new HDate(15, months.CHESHVAN, 5769);
|
|
1492
|
-
* console.log(hd.render('en')); // '15th of Cheshvan, 5769'
|
|
1493
|
-
* console.log(hd.render('he')); // '15 חֶשְׁוָן, 5769'
|
|
1494
|
-
* @param {string} [locale] Optional locale name (defaults to active locale).
|
|
1495
|
-
* @param {boolean} [showYear=true] Display year (defaults to true).
|
|
1496
|
-
* @return {string}
|
|
1497
|
-
*/
|
|
1498
|
-
render(locale = null, showYear = true) {
|
|
1499
|
-
const locale0 = locale || Locale.getLocaleName();
|
|
1500
|
-
const day = this.getDate();
|
|
1501
|
-
const monthName0 = Locale.gettext(this.getMonthName(), locale0);
|
|
1502
|
-
const monthName = monthName0.replace(/'/g, '’');
|
|
1503
|
-
const nth = Locale.ordinal(day, locale0);
|
|
1504
|
-
const dayOf = HDate.getDayOfTranslation(locale0);
|
|
1505
|
-
const dateStr = `${nth}${dayOf} ${monthName}`;
|
|
1506
|
-
if (showYear) {
|
|
1507
|
-
const fullYear = this.getFullYear();
|
|
1508
|
-
return `${dateStr}, ${fullYear}`;
|
|
1509
|
-
} else {
|
|
1510
|
-
return dateStr;
|
|
1432
|
+
/**
|
|
1433
|
+
* Tests if this date occurs during a leap year
|
|
1434
|
+
* @return {boolean}
|
|
1435
|
+
*/
|
|
1436
|
+
isLeapYear() {
|
|
1437
|
+
return isLeapYear(this.yy);
|
|
1511
1438
|
}
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
|
|
1439
|
+
/**
|
|
1440
|
+
* Gets the Hebrew month (1=NISAN, 7=TISHREI) of this Hebrew date
|
|
1441
|
+
* @return {number}
|
|
1442
|
+
*/
|
|
1443
|
+
getMonth() {
|
|
1444
|
+
return this.mm;
|
|
1445
|
+
}
|
|
1446
|
+
/**
|
|
1447
|
+
* The Tishrei-based month of the date. 1 is Tishrei, 7 is Nisan, 13 is Elul in a leap year
|
|
1448
|
+
* @return {number}
|
|
1449
|
+
*/
|
|
1450
|
+
getTishreiMonth() {
|
|
1451
|
+
const nummonths = monthsInYear(this.getFullYear());
|
|
1452
|
+
return (this.getMonth() + nummonths - 6) % nummonths || nummonths;
|
|
1453
|
+
}
|
|
1454
|
+
/**
|
|
1455
|
+
* Number of days in the month of this Hebrew date
|
|
1456
|
+
* @return {number}
|
|
1457
|
+
*/
|
|
1458
|
+
daysInMonth() {
|
|
1459
|
+
return daysInMonth(this.getMonth(), this.getFullYear());
|
|
1460
|
+
}
|
|
1461
|
+
/**
|
|
1462
|
+
* Gets the day within the month (1-30)
|
|
1463
|
+
* @return {number}
|
|
1464
|
+
*/
|
|
1465
|
+
getDate() {
|
|
1466
|
+
return this.dd;
|
|
1467
|
+
}
|
|
1468
|
+
/**
|
|
1469
|
+
* Gets the day of the week. 0=Sunday, 6=Saturday
|
|
1470
|
+
* @return {number}
|
|
1471
|
+
*/
|
|
1472
|
+
getDay() {
|
|
1473
|
+
return mod(this.abs(), 7);
|
|
1474
|
+
}
|
|
1475
|
+
/**
|
|
1476
|
+
* Converts to Gregorian date
|
|
1477
|
+
* @return {Date}
|
|
1478
|
+
*/
|
|
1479
|
+
greg() {
|
|
1480
|
+
return greg.abs2greg(this.abs());
|
|
1481
|
+
}
|
|
1482
|
+
/**
|
|
1483
|
+
* Returns R.D. (Rata Die) fixed days.
|
|
1484
|
+
* R.D. 1 == Monday, January 1, 1 (Gregorian)
|
|
1485
|
+
* Note also that R.D. = Julian Date − 1,721,424.5
|
|
1486
|
+
* https://en.wikipedia.org/wiki/Rata_Die#Dershowitz_and_Reingold
|
|
1487
|
+
* @return {number}
|
|
1488
|
+
*/
|
|
1489
|
+
abs() {
|
|
1490
|
+
if (typeof this.rd !== 'number') {
|
|
1491
|
+
this.rd = hebrew2abs(this.yy, this.mm, this.dd);
|
|
1492
|
+
}
|
|
1493
|
+
return this.rd;
|
|
1494
|
+
}
|
|
1495
|
+
/**
|
|
1496
|
+
* Converts Hebrew date to R.D. (Rata Die) fixed days.
|
|
1497
|
+
* R.D. 1 is the imaginary date Monday, January 1, 1 on the Gregorian
|
|
1498
|
+
* Calendar.
|
|
1499
|
+
* @param {number} year Hebrew year
|
|
1500
|
+
* @param {number} month Hebrew month
|
|
1501
|
+
* @param {number} day Hebrew date (1-30)
|
|
1502
|
+
* @return {number}
|
|
1503
|
+
*/
|
|
1504
|
+
static hebrew2abs(year, month, day) {
|
|
1505
|
+
return hebrew2abs(year, month, day);
|
|
1506
|
+
}
|
|
1507
|
+
/**
|
|
1508
|
+
* Returns a transliterated Hebrew month name, e.g. `'Elul'` or `'Cheshvan'`.
|
|
1509
|
+
* @return {string}
|
|
1510
|
+
*/
|
|
1511
|
+
getMonthName() {
|
|
1512
|
+
return getMonthName(this.getMonth(), this.getFullYear());
|
|
1513
|
+
}
|
|
1514
|
+
/**
|
|
1515
|
+
* Renders this Hebrew date as a translated or transliterated string,
|
|
1516
|
+
* including ordinal e.g. `'15th of Cheshvan, 5769'`.
|
|
1517
|
+
* @example
|
|
1518
|
+
* import {HDate, months} from '@hebcal/hdate';
|
|
1519
|
+
*
|
|
1520
|
+
* const hd = new HDate(15, months.CHESHVAN, 5769);
|
|
1521
|
+
* console.log(hd.render('en')); // '15th of Cheshvan, 5769'
|
|
1522
|
+
* console.log(hd.render('he')); // '15 חֶשְׁוָן, 5769'
|
|
1523
|
+
* @param {string} [locale] Optional locale name (defaults to active locale).
|
|
1524
|
+
* @param {boolean} [showYear=true] Display year (defaults to true).
|
|
1525
|
+
* @return {string}
|
|
1526
|
+
*/
|
|
1527
|
+
render(locale, showYear = true) {
|
|
1528
|
+
const locale0 = locale || Locale.getLocaleName();
|
|
1529
|
+
const day = this.getDate();
|
|
1530
|
+
const monthName0 = Locale.gettext(this.getMonthName(), locale0);
|
|
1531
|
+
const monthName = monthName0.replace(/'/g, '’');
|
|
1532
|
+
const nth = Locale.ordinal(day, locale0);
|
|
1533
|
+
const dayOf = getDayOfTranslation(locale0);
|
|
1534
|
+
const dateStr = `${nth}${dayOf} ${monthName}`;
|
|
1535
|
+
if (showYear) {
|
|
1536
|
+
const fullYear = this.getFullYear();
|
|
1537
|
+
return `${dateStr}, ${fullYear}`;
|
|
1538
|
+
}
|
|
1539
|
+
else {
|
|
1540
|
+
return dateStr;
|
|
1541
|
+
}
|
|
1542
|
+
}
|
|
1543
|
+
/**
|
|
1544
|
+
* Renders this Hebrew date in Hebrew gematriya, regardless of locale.
|
|
1545
|
+
* @example
|
|
1546
|
+
* import {HDate, months} from '@hebcal/hdate';
|
|
1547
|
+
* const hd = new HDate(15, months.CHESHVAN, 5769);
|
|
1548
|
+
* console.log(hd.renderGematriya()); // 'ט״ו חֶשְׁוָן תשס״ט'
|
|
1549
|
+
* @param {boolean} [suppressNikud]
|
|
1550
|
+
* @return {string}
|
|
1551
|
+
*/
|
|
1552
|
+
renderGematriya(suppressNikud = false) {
|
|
1553
|
+
const d = this.getDate();
|
|
1554
|
+
const locale = suppressNikud ? 'he-x-NoNikud' : 'he';
|
|
1555
|
+
const m = Locale.gettext(this.getMonthName(), locale);
|
|
1556
|
+
const y = this.getFullYear();
|
|
1557
|
+
return gematriya(d) + ' ' + m + ' ' + gematriya(y);
|
|
1558
|
+
}
|
|
1559
|
+
/**
|
|
1560
|
+
* Returns an `HDate` representing the a dayNumber before the current date.
|
|
1561
|
+
* Sunday=0, Saturday=6
|
|
1562
|
+
* @example
|
|
1563
|
+
* new HDate(new Date('Wednesday February 19, 2014')).before(6).greg() // Sat Feb 15 2014
|
|
1564
|
+
* @param {number} dow day of week
|
|
1565
|
+
* @return {HDate}
|
|
1566
|
+
*/
|
|
1567
|
+
before(dow) {
|
|
1568
|
+
return onOrBefore(dow, this, -1);
|
|
1569
|
+
}
|
|
1570
|
+
/**
|
|
1571
|
+
* Returns an `HDate` representing the a dayNumber on or before the current date.
|
|
1572
|
+
* Sunday=0, Saturday=6
|
|
1573
|
+
* @example
|
|
1574
|
+
* new HDate(new Date('Wednesday February 19, 2014')).onOrBefore(6).greg() // Sat Feb 15 2014
|
|
1575
|
+
* new HDate(new Date('Saturday February 22, 2014')).onOrBefore(6).greg() // Sat Feb 22 2014
|
|
1576
|
+
* new HDate(new Date('Sunday February 23, 2014')).onOrBefore(6).greg() // Sat Feb 22 2014
|
|
1577
|
+
* @param {number} dow day of week
|
|
1578
|
+
* @return {HDate}
|
|
1579
|
+
*/
|
|
1580
|
+
onOrBefore(dow) {
|
|
1581
|
+
return onOrBefore(dow, this, 0);
|
|
1582
|
+
}
|
|
1583
|
+
/**
|
|
1584
|
+
* Returns an `HDate` representing the nearest dayNumber to the current date
|
|
1585
|
+
* Sunday=0, Saturday=6
|
|
1586
|
+
* @example
|
|
1587
|
+
* new HDate(new Date('Wednesday February 19, 2014')).nearest(6).greg() // Sat Feb 22 2014
|
|
1588
|
+
* new HDate(new Date('Tuesday February 18, 2014')).nearest(6).greg() // Sat Feb 15 2014
|
|
1589
|
+
* @param {number} dow day of week
|
|
1590
|
+
* @return {HDate}
|
|
1591
|
+
*/
|
|
1592
|
+
nearest(dow) {
|
|
1593
|
+
return onOrBefore(dow, this, 3);
|
|
1594
|
+
}
|
|
1595
|
+
/**
|
|
1596
|
+
* Returns an `HDate` representing the a dayNumber on or after the current date.
|
|
1597
|
+
* Sunday=0, Saturday=6
|
|
1598
|
+
* @example
|
|
1599
|
+
* new HDate(new Date('Wednesday February 19, 2014')).onOrAfter(6).greg() // Sat Feb 22 2014
|
|
1600
|
+
* new HDate(new Date('Saturday February 22, 2014')).onOrAfter(6).greg() // Sat Feb 22 2014
|
|
1601
|
+
* new HDate(new Date('Sunday February 23, 2014')).onOrAfter(6).greg() // Sat Mar 01 2014
|
|
1602
|
+
* @param {number} dow day of week
|
|
1603
|
+
* @return {HDate}
|
|
1604
|
+
*/
|
|
1605
|
+
onOrAfter(dow) {
|
|
1606
|
+
return onOrBefore(dow, this, 6);
|
|
1607
|
+
}
|
|
1608
|
+
/**
|
|
1609
|
+
* Returns an `HDate` representing the a dayNumber after the current date.
|
|
1610
|
+
* Sunday=0, Saturday=6
|
|
1611
|
+
* @example
|
|
1612
|
+
* new HDate(new Date('Wednesday February 19, 2014')).after(6).greg() // Sat Feb 22 2014
|
|
1613
|
+
* new HDate(new Date('Saturday February 22, 2014')).after(6).greg() // Sat Mar 01 2014
|
|
1614
|
+
* new HDate(new Date('Sunday February 23, 2014')).after(6).greg() // Sat Mar 01 2014
|
|
1615
|
+
* @param {number} dow day of week
|
|
1616
|
+
* @return {HDate}
|
|
1617
|
+
*/
|
|
1618
|
+
after(dow) {
|
|
1619
|
+
return onOrBefore(dow, this, 7);
|
|
1620
|
+
}
|
|
1621
|
+
/**
|
|
1622
|
+
* Returns the next Hebrew date
|
|
1623
|
+
* @return {HDate}
|
|
1624
|
+
*/
|
|
1625
|
+
next() {
|
|
1626
|
+
return new HDate(this.abs() + 1);
|
|
1627
|
+
}
|
|
1628
|
+
/**
|
|
1629
|
+
* Returns the previous Hebrew date
|
|
1630
|
+
* @return {HDate}
|
|
1631
|
+
*/
|
|
1632
|
+
prev() {
|
|
1633
|
+
return new HDate(this.abs() - 1);
|
|
1634
|
+
}
|
|
1635
|
+
/**
|
|
1636
|
+
* Returns a cloned `HDate` object with a specified amount of time added
|
|
1637
|
+
*
|
|
1638
|
+
* Units are case insensitive, and support plural and short forms.
|
|
1639
|
+
* Note, short forms are case sensitive.
|
|
1640
|
+
*
|
|
1641
|
+
* | Unit | Shorthand | Description
|
|
1642
|
+
* | --- | --- | --- |
|
|
1643
|
+
* | `day` | `d` | days |
|
|
1644
|
+
* | `week` | `w` | weeks |
|
|
1645
|
+
* | `month` | `M` | months |
|
|
1646
|
+
* | `year` | `y` | years |
|
|
1647
|
+
* @param {number} amount
|
|
1648
|
+
* @param {string} [units]
|
|
1649
|
+
* @return {HDate}
|
|
1650
|
+
*/
|
|
1651
|
+
add(amount, units = 'd') {
|
|
1652
|
+
amount = typeof amount === 'string' ? parseInt(amount, 10) : amount;
|
|
1653
|
+
if (!amount) {
|
|
1654
|
+
return new HDate(this);
|
|
1655
|
+
}
|
|
1656
|
+
units = standardizeUnits(units);
|
|
1657
|
+
if (units === UNITS_DAY) {
|
|
1658
|
+
return new HDate(this.abs() + amount);
|
|
1659
|
+
}
|
|
1660
|
+
else if (units === UNITS_WEEK) {
|
|
1661
|
+
return new HDate(this.abs() + (7 * amount));
|
|
1662
|
+
}
|
|
1663
|
+
else if (units === UNITS_YEAR) {
|
|
1664
|
+
return new HDate(this.getDate(), this.getMonth(), this.getFullYear() + amount);
|
|
1665
|
+
}
|
|
1666
|
+
else if (units === UNITS_MONTH) {
|
|
1667
|
+
let hd = new HDate(this);
|
|
1668
|
+
const sign = amount > 0 ? 1 : -1;
|
|
1669
|
+
amount = Math.abs(amount);
|
|
1670
|
+
for (let i = 0; i < amount; i++) {
|
|
1671
|
+
hd = new HDate(hd.abs() + (sign * hd.daysInMonth()));
|
|
1672
|
+
}
|
|
1673
|
+
return hd;
|
|
1674
|
+
}
|
|
1675
|
+
else {
|
|
1676
|
+
throw new TypeError(`Invalid units '${units}'`);
|
|
1677
|
+
}
|
|
1678
|
+
}
|
|
1679
|
+
/**
|
|
1680
|
+
* Returns a cloned `HDate` object with a specified amount of time subracted
|
|
1681
|
+
*
|
|
1682
|
+
* Units are case insensitive, and support plural and short forms.
|
|
1683
|
+
* Note, short forms are case sensitive.
|
|
1684
|
+
*
|
|
1685
|
+
* | Unit | Shorthand | Description
|
|
1686
|
+
* | --- | --- | --- |
|
|
1687
|
+
* | `day` | `d` | days |
|
|
1688
|
+
* | `week` | `w` | weeks |
|
|
1689
|
+
* | `month` | `M` | months |
|
|
1690
|
+
* | `year` | `y` | years |
|
|
1691
|
+
* @example
|
|
1692
|
+
* import {HDate, months} from '@hebcal/hdate';
|
|
1693
|
+
*
|
|
1694
|
+
* const hd1 = new HDate(15, months.CHESHVAN, 5769);
|
|
1695
|
+
* const hd2 = hd1.add(1, 'weeks'); // 7 Kislev 5769
|
|
1696
|
+
* const hd3 = hd1.add(-3, 'M'); // 30 Av 5768
|
|
1697
|
+
* @param {number} amount
|
|
1698
|
+
* @param {string} [units]
|
|
1699
|
+
* @return {HDate}
|
|
1700
|
+
*/
|
|
1701
|
+
subtract(amount, units = 'd') {
|
|
1702
|
+
return this.add(amount * -1, units);
|
|
1703
|
+
}
|
|
1704
|
+
/**
|
|
1705
|
+
* Returns the difference in days between the two given HDates.
|
|
1706
|
+
*
|
|
1707
|
+
* The result is positive if `this` date is comes chronologically
|
|
1708
|
+
* after the `other` date, and negative
|
|
1709
|
+
* if the order of the two dates is reversed.
|
|
1710
|
+
*
|
|
1711
|
+
* The result is zero if the two dates are identical.
|
|
1712
|
+
* @example
|
|
1713
|
+
* import {HDate, months} from '@hebcal/hdate';
|
|
1714
|
+
*
|
|
1715
|
+
* const hd1 = new HDate(25, months.KISLEV, 5770);
|
|
1716
|
+
* const hd2 = new HDate(15, months.CHESHVAN, 5769);
|
|
1717
|
+
* const days = hd1.deltaDays(hd2); // 394
|
|
1718
|
+
* @param {HDate} other Hebrew date to compare
|
|
1719
|
+
* @return {number}
|
|
1720
|
+
*/
|
|
1721
|
+
deltaDays(other) {
|
|
1722
|
+
if (!HDate.isHDate(other)) {
|
|
1723
|
+
throw new TypeError(`Bad argument: ${other}`);
|
|
1724
|
+
}
|
|
1725
|
+
return this.abs() - other.abs();
|
|
1726
|
+
}
|
|
1727
|
+
/**
|
|
1728
|
+
* Compares this date to another date, returning `true` if the dates match.
|
|
1729
|
+
* @param {HDate} other Hebrew date to compare
|
|
1730
|
+
* @return {boolean}
|
|
1731
|
+
*/
|
|
1732
|
+
isSameDate(other) {
|
|
1733
|
+
if (HDate.isHDate(other)) {
|
|
1734
|
+
return this.yy === other.yy &&
|
|
1735
|
+
this.mm === other.mm &&
|
|
1736
|
+
this.dd === other.dd;
|
|
1737
|
+
}
|
|
1738
|
+
return false;
|
|
1739
|
+
}
|
|
1740
|
+
/** @return {string} */
|
|
1741
|
+
toString() {
|
|
1742
|
+
const day = this.getDate();
|
|
1743
|
+
const fullYear = this.getFullYear();
|
|
1744
|
+
const monthName = this.getMonthName();
|
|
1745
|
+
return `${day} ${monthName} ${fullYear}`;
|
|
1746
|
+
}
|
|
1747
|
+
/**
|
|
1748
|
+
* Returns true if Hebrew year is a leap year
|
|
1749
|
+
* @param {number} year Hebrew year
|
|
1750
|
+
* @return {boolean}
|
|
1751
|
+
*/
|
|
1752
|
+
static isLeapYear(year) {
|
|
1753
|
+
return isLeapYear(year);
|
|
1754
|
+
}
|
|
1755
|
+
/**
|
|
1756
|
+
* Number of months in this Hebrew year (either 12 or 13 depending on leap year)
|
|
1757
|
+
* @param {number} year Hebrew year
|
|
1758
|
+
* @return {number}
|
|
1759
|
+
*/
|
|
1760
|
+
static monthsInYear(year) {
|
|
1761
|
+
return monthsInYear(year);
|
|
1762
|
+
}
|
|
1763
|
+
/**
|
|
1764
|
+
* Number of days in Hebrew month in a given year (29 or 30)
|
|
1765
|
+
* @param {number} month Hebrew month (e.g. months.TISHREI)
|
|
1766
|
+
* @param {number} year Hebrew year
|
|
1767
|
+
* @return {number}
|
|
1768
|
+
*/
|
|
1769
|
+
static daysInMonth(month, year) {
|
|
1770
|
+
return daysInMonth(month, year);
|
|
1771
|
+
}
|
|
1772
|
+
/**
|
|
1773
|
+
* Returns a transliterated string name of Hebrew month in year,
|
|
1774
|
+
* for example 'Elul' or 'Cheshvan'.
|
|
1775
|
+
* @param {number} month Hebrew month (e.g. months.TISHREI)
|
|
1776
|
+
* @param {number} year Hebrew year
|
|
1777
|
+
* @return {string}
|
|
1778
|
+
*/
|
|
1779
|
+
static getMonthName(month, year) {
|
|
1780
|
+
return getMonthName(month, year);
|
|
1781
|
+
}
|
|
1782
|
+
/**
|
|
1783
|
+
* Returns the Hebrew month number (NISAN=1, TISHREI=7)
|
|
1784
|
+
* @param {number|string} month A number, or Hebrew month name string
|
|
1785
|
+
* @return {number}
|
|
1786
|
+
*/
|
|
1787
|
+
static monthNum(month) {
|
|
1788
|
+
if (typeof month === 'number') {
|
|
1789
|
+
if (isNaN(month) || month > 14) {
|
|
1790
|
+
throw new RangeError(`Invalid month number: ${month}`);
|
|
1791
|
+
}
|
|
1792
|
+
return month;
|
|
1793
|
+
}
|
|
1794
|
+
return month.charCodeAt(0) >= 48 && month.charCodeAt(0) <= 57 ? /* number */
|
|
1795
|
+
parseInt(month, 10) :
|
|
1796
|
+
HDate.monthFromName(month);
|
|
1797
|
+
}
|
|
1798
|
+
/**
|
|
1799
|
+
* Number of days in the hebrew YEAR
|
|
1800
|
+
* @param {number} year Hebrew year
|
|
1801
|
+
* @return {number}
|
|
1802
|
+
*/
|
|
1803
|
+
static daysInYear(year) {
|
|
1804
|
+
return daysInYear(year);
|
|
1805
|
+
}
|
|
1806
|
+
/**
|
|
1807
|
+
* true if Cheshvan is long in Hebrew year
|
|
1808
|
+
* @param {number} year Hebrew year
|
|
1809
|
+
* @return {boolean}
|
|
1810
|
+
*/
|
|
1811
|
+
static longCheshvan(year) {
|
|
1812
|
+
return longCheshvan(year);
|
|
1813
|
+
}
|
|
1814
|
+
/**
|
|
1815
|
+
* true if Kislev is short in Hebrew year
|
|
1816
|
+
* @param {number} year Hebrew year
|
|
1817
|
+
* @return {boolean}
|
|
1818
|
+
*/
|
|
1819
|
+
static shortKislev(year) {
|
|
1820
|
+
return shortKislev(year);
|
|
1821
|
+
}
|
|
1822
|
+
/**
|
|
1823
|
+
* Converts Hebrew month string name to numeric
|
|
1824
|
+
* @param {string|number} monthName monthName
|
|
1825
|
+
* @return {number}
|
|
1826
|
+
*/
|
|
1827
|
+
static monthFromName(monthName) {
|
|
1828
|
+
if (typeof monthName === 'number') {
|
|
1829
|
+
if (isNaN(monthName) || monthName < 1 || monthName > 14) {
|
|
1830
|
+
throw new RangeError(`Invalid month name: ${monthName}`);
|
|
1831
|
+
}
|
|
1832
|
+
return monthName;
|
|
1833
|
+
}
|
|
1834
|
+
const name = Locale.hebrewStripNikkud(monthName);
|
|
1835
|
+
return monthFromName(name);
|
|
1836
|
+
}
|
|
1837
|
+
/**
|
|
1838
|
+
* Note: Applying this function to d+6 gives us the DAYNAME on or after an
|
|
1839
|
+
* absolute day d. Similarly, applying it to d+3 gives the DAYNAME nearest to
|
|
1840
|
+
* absolute date d, applying it to d-1 gives the DAYNAME previous to absolute
|
|
1841
|
+
* date d, and applying it to d+7 gives the DAYNAME following absolute date d.
|
|
1842
|
+
* @param {number} dayOfWeek
|
|
1843
|
+
* @param {number} absdate
|
|
1844
|
+
* @return {number}
|
|
1845
|
+
*/
|
|
1846
|
+
static dayOnOrBefore(dayOfWeek, absdate) {
|
|
1847
|
+
return absdate - ((absdate - dayOfWeek) % 7);
|
|
1848
|
+
}
|
|
1849
|
+
/**
|
|
1850
|
+
* Tests if the object is an instance of `HDate`
|
|
1851
|
+
* @param {any} obj
|
|
1852
|
+
* @return {boolean}
|
|
1853
|
+
*/
|
|
1854
|
+
static isHDate(obj) {
|
|
1855
|
+
return obj !== null && typeof obj === 'object' &&
|
|
1856
|
+
typeof obj.yy === 'number' &&
|
|
1857
|
+
typeof obj.mm === 'number' &&
|
|
1858
|
+
typeof obj.dd === 'number' &&
|
|
1859
|
+
typeof obj.greg === 'function' &&
|
|
1860
|
+
typeof obj.abs === 'function';
|
|
1861
|
+
}
|
|
1862
|
+
/**
|
|
1863
|
+
* Construct a new instance of `HDate` from a Gematriya-formatted string
|
|
1864
|
+
* @example
|
|
1865
|
+
* HDate.fromGematriyaString('כ״ז בְּתַמּוּז תשפ״ג') // 27 Tamuz 5783
|
|
1866
|
+
* HDate.fromGematriyaString('כ׳ סיון תש״ד') // 20 Sivan 5704
|
|
1867
|
+
* HDate.fromGematriyaString('ה׳ אִיָיר תש״ח') // 5 Iyyar 5708
|
|
1868
|
+
* @param {string} str
|
|
1869
|
+
* @param {number} currentThousands
|
|
1870
|
+
* @return {HDate}
|
|
1871
|
+
*/
|
|
1872
|
+
static fromGematriyaString(str, currentThousands = 5000) {
|
|
1873
|
+
const parts = str.split(' ').filter((x) => x.length !== 0);
|
|
1874
|
+
const numParts = parts.length;
|
|
1875
|
+
if (numParts !== 3 && numParts !== 4) {
|
|
1876
|
+
throw new RangeError(`Unable to parse gematriya string: "${str}"`);
|
|
1877
|
+
}
|
|
1878
|
+
const day = gematriyaStrToNum(parts[0]);
|
|
1879
|
+
const monthStr = numParts === 3 ? parts[1] : parts[1] + ' ' + parts[2];
|
|
1880
|
+
const month = HDate.monthFromName(monthStr);
|
|
1881
|
+
const yearStr = numParts === 3 ? parts[2] : parts[3];
|
|
1882
|
+
let year = gematriyaStrToNum(yearStr);
|
|
1883
|
+
if (year < 1000) {
|
|
1884
|
+
year += currentThousands;
|
|
1885
|
+
}
|
|
1886
|
+
return new HDate(day, month, year);
|
|
1887
|
+
}
|
|
1888
|
+
}
|
|
1889
|
+
function standardizeUnits(units) {
|
|
1890
|
+
switch (units) {
|
|
1891
|
+
case 'd': return UNITS_DAY;
|
|
1892
|
+
case 'w': return UNITS_WEEK;
|
|
1893
|
+
case 'M': return UNITS_MONTH;
|
|
1894
|
+
case 'y': return UNITS_YEAR;
|
|
1895
|
+
}
|
|
1896
|
+
const str = String(units || '').toLowerCase().replace(/s$/, '');
|
|
1897
|
+
switch (str) {
|
|
1898
|
+
case UNITS_DAY:
|
|
1899
|
+
case UNITS_WEEK:
|
|
1900
|
+
case UNITS_MONTH:
|
|
1901
|
+
case UNITS_YEAR:
|
|
1902
|
+
return str;
|
|
1903
|
+
}
|
|
1904
|
+
throw new TypeError(`Invalid units '${units}'`);
|
|
1905
|
+
}
|
|
1906
|
+
function getDayOfTranslation(locale) {
|
|
1520
1907
|
switch (locale) {
|
|
1521
|
-
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
|
|
1908
|
+
case 'en':
|
|
1909
|
+
case 's':
|
|
1910
|
+
case 'a':
|
|
1911
|
+
case 'ashkenazi':
|
|
1912
|
+
return ' of';
|
|
1526
1913
|
}
|
|
1527
1914
|
const ofStr = Locale.lookupTranslation('of', locale);
|
|
1528
1915
|
if (ofStr) {
|
|
1529
|
-
|
|
1916
|
+
return ' ' + ofStr;
|
|
1530
1917
|
}
|
|
1531
1918
|
if (locale.startsWith('ashkenazi')) {
|
|
1532
|
-
|
|
1919
|
+
return ' of';
|
|
1533
1920
|
}
|
|
1534
1921
|
return '';
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
|
|
1540
|
-
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
|
|
1548
|
-
|
|
1549
|
-
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
|
|
1556
|
-
|
|
1557
|
-
|
|
1558
|
-
|
|
1559
|
-
|
|
1560
|
-
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
|
|
1564
|
-
}
|
|
1565
|
-
|
|
1566
|
-
/**
|
|
1567
|
-
* Returns an `HDate` representing the a dayNumber on or before the current date.
|
|
1568
|
-
* Sunday=0, Saturday=6
|
|
1569
|
-
* @example
|
|
1570
|
-
* new HDate(new Date('Wednesday February 19, 2014')).onOrBefore(6).greg() // Sat Feb 15 2014
|
|
1571
|
-
* new HDate(new Date('Saturday February 22, 2014')).onOrBefore(6).greg() // Sat Feb 22 2014
|
|
1572
|
-
* new HDate(new Date('Sunday February 23, 2014')).onOrBefore(6).greg() // Sat Feb 22 2014
|
|
1573
|
-
* @param {number} dow day of week
|
|
1574
|
-
* @return {HDate}
|
|
1575
|
-
*/
|
|
1576
|
-
onOrBefore(dow) {
|
|
1577
|
-
return onOrBefore(dow, this, 0);
|
|
1578
|
-
}
|
|
1579
|
-
|
|
1580
|
-
/**
|
|
1581
|
-
* Returns an `HDate` representing the nearest dayNumber to the current date
|
|
1582
|
-
* Sunday=0, Saturday=6
|
|
1583
|
-
* @example
|
|
1584
|
-
* new HDate(new Date('Wednesday February 19, 2014')).nearest(6).greg() // Sat Feb 22 2014
|
|
1585
|
-
* new HDate(new Date('Tuesday February 18, 2014')).nearest(6).greg() // Sat Feb 15 2014
|
|
1586
|
-
* @param {number} dow day of week
|
|
1587
|
-
* @return {HDate}
|
|
1588
|
-
*/
|
|
1589
|
-
nearest(dow) {
|
|
1590
|
-
return onOrBefore(dow, this, 3);
|
|
1591
|
-
}
|
|
1592
|
-
|
|
1593
|
-
/**
|
|
1594
|
-
* Returns an `HDate` representing the a dayNumber on or after the current date.
|
|
1595
|
-
* Sunday=0, Saturday=6
|
|
1596
|
-
* @example
|
|
1597
|
-
* new HDate(new Date('Wednesday February 19, 2014')).onOrAfter(6).greg() // Sat Feb 22 2014
|
|
1598
|
-
* new HDate(new Date('Saturday February 22, 2014')).onOrAfter(6).greg() // Sat Feb 22 2014
|
|
1599
|
-
* new HDate(new Date('Sunday February 23, 2014')).onOrAfter(6).greg() // Sat Mar 01 2014
|
|
1600
|
-
* @param {number} dow day of week
|
|
1601
|
-
* @return {HDate}
|
|
1602
|
-
*/
|
|
1603
|
-
onOrAfter(dow) {
|
|
1604
|
-
return onOrBefore(dow, this, 6);
|
|
1605
|
-
}
|
|
1606
|
-
|
|
1607
|
-
/**
|
|
1608
|
-
* Returns an `HDate` representing the a dayNumber after the current date.
|
|
1609
|
-
* Sunday=0, Saturday=6
|
|
1610
|
-
* @example
|
|
1611
|
-
* new HDate(new Date('Wednesday February 19, 2014')).after(6).greg() // Sat Feb 22 2014
|
|
1612
|
-
* new HDate(new Date('Saturday February 22, 2014')).after(6).greg() // Sat Mar 01 2014
|
|
1613
|
-
* new HDate(new Date('Sunday February 23, 2014')).after(6).greg() // Sat Mar 01 2014
|
|
1614
|
-
* @param {number} day day of week
|
|
1615
|
-
* @return {HDate}
|
|
1616
|
-
*/
|
|
1617
|
-
after(day) {
|
|
1618
|
-
return onOrBefore(day, this, 7);
|
|
1619
|
-
}
|
|
1620
|
-
|
|
1621
|
-
/**
|
|
1622
|
-
* Returns the next Hebrew date
|
|
1623
|
-
* @return {HDate}
|
|
1624
|
-
*/
|
|
1625
|
-
next() {
|
|
1626
|
-
return new HDate(this.abs() + 1);
|
|
1627
|
-
}
|
|
1628
|
-
|
|
1629
|
-
/**
|
|
1630
|
-
* Returns the previous Hebrew date
|
|
1631
|
-
* @return {HDate}
|
|
1632
|
-
*/
|
|
1633
|
-
prev() {
|
|
1634
|
-
return new HDate(this.abs() - 1);
|
|
1635
|
-
}
|
|
1636
|
-
|
|
1637
|
-
/**
|
|
1638
|
-
* Returns a cloned `HDate` object with a specified amount of time added
|
|
1639
|
-
*
|
|
1640
|
-
* Units are case insensitive, and support plural and short forms.
|
|
1641
|
-
* Note, short forms are case sensitive.
|
|
1642
|
-
*
|
|
1643
|
-
* | Unit | Shorthand | Description
|
|
1644
|
-
* | --- | --- | --- |
|
|
1645
|
-
* | `day` | `d` | days |
|
|
1646
|
-
* | `week` | `w` | weeks |
|
|
1647
|
-
* | `month` | `M` | months |
|
|
1648
|
-
* | `year` | `y` | years |
|
|
1649
|
-
* @param {number} number
|
|
1650
|
-
* @param {string} [units]
|
|
1651
|
-
* @return {HDate}
|
|
1652
|
-
*/
|
|
1653
|
-
add(number, units = 'd') {
|
|
1654
|
-
number = parseInt(number, 10);
|
|
1655
|
-
if (!number) {
|
|
1656
|
-
return new HDate(this);
|
|
1657
|
-
}
|
|
1658
|
-
units = HDate.standardizeUnits(units);
|
|
1659
|
-
if (units === UNITS_DAY) {
|
|
1660
|
-
return new HDate(this.abs() + number);
|
|
1661
|
-
} else if (units === UNITS_WEEK) {
|
|
1662
|
-
return new HDate(this.abs() + 7 * number);
|
|
1663
|
-
} else if (units === UNITS_YEAR) {
|
|
1664
|
-
return new HDate(this.getDate(), this.getMonth(), this.getFullYear() + number);
|
|
1665
|
-
} else if (units === UNITS_MONTH) {
|
|
1666
|
-
let hd = new HDate(this);
|
|
1667
|
-
const sign = number > 0 ? 1 : -1;
|
|
1668
|
-
number = Math.abs(number);
|
|
1669
|
-
for (let i = 0; i < number; i++) {
|
|
1670
|
-
hd = new HDate(hd.abs() + sign * hd.daysInMonth());
|
|
1671
|
-
}
|
|
1672
|
-
return hd;
|
|
1922
|
+
}
|
|
1923
|
+
/**
|
|
1924
|
+
* Sets the day of the month of the date. Returns the object it was called upon
|
|
1925
|
+
* @private
|
|
1926
|
+
* @param {number|string} month A number, or Hebrew month name string
|
|
1927
|
+
* @return {HDate}
|
|
1928
|
+
*/
|
|
1929
|
+
function setMonth(hd, month) {
|
|
1930
|
+
hd.mm = HDate.monthNum(month);
|
|
1931
|
+
fix(hd);
|
|
1932
|
+
return hd;
|
|
1933
|
+
}
|
|
1934
|
+
function setDate(hd, date) {
|
|
1935
|
+
hd.dd = date;
|
|
1936
|
+
fix(hd);
|
|
1937
|
+
return hd;
|
|
1938
|
+
}
|
|
1939
|
+
function fix(hd) {
|
|
1940
|
+
fixMonth(hd);
|
|
1941
|
+
fixDate(hd);
|
|
1942
|
+
}
|
|
1943
|
+
function fixDate(hd) {
|
|
1944
|
+
if (hd.dd < 1) {
|
|
1945
|
+
if (hd.mm === months.TISHREI) {
|
|
1946
|
+
hd.yy -= 1;
|
|
1947
|
+
}
|
|
1948
|
+
hd.dd += daysInMonth(hd.mm, hd.yy);
|
|
1949
|
+
hd.mm -= 1;
|
|
1950
|
+
fix(hd);
|
|
1673
1951
|
}
|
|
1674
|
-
|
|
1675
|
-
|
|
1676
|
-
|
|
1677
|
-
|
|
1678
|
-
|
|
1679
|
-
|
|
1680
|
-
|
|
1681
|
-
|
|
1682
|
-
|
|
1683
|
-
|
|
1684
|
-
|
|
1685
|
-
|
|
1686
|
-
/**
|
|
1687
|
-
* Returns a cloned `HDate` object with a specified amount of time subracted
|
|
1688
|
-
*
|
|
1689
|
-
* Units are case insensitive, and support plural and short forms.
|
|
1690
|
-
* Note, short forms are case sensitive.
|
|
1691
|
-
*
|
|
1692
|
-
* | Unit | Shorthand | Description
|
|
1693
|
-
* | --- | --- | --- |
|
|
1694
|
-
* | `day` | `d` | days |
|
|
1695
|
-
* | `week` | `w` | weeks |
|
|
1696
|
-
* | `month` | `M` | months |
|
|
1697
|
-
* | `year` | `y` | years |
|
|
1698
|
-
* @example
|
|
1699
|
-
* import {HDate, months} from '@hebcal/core';
|
|
1700
|
-
*
|
|
1701
|
-
* const hd1 = new HDate(15, months.CHESHVAN, 5769);
|
|
1702
|
-
* const hd2 = hd1.add(1, 'weeks'); // 7 Kislev 5769
|
|
1703
|
-
* const hd3 = hd1.add(-3, 'M'); // 30 Av 5768
|
|
1704
|
-
* @param {number} number
|
|
1705
|
-
* @param {string} [units]
|
|
1706
|
-
* @return {HDate}
|
|
1707
|
-
*/
|
|
1708
|
-
subtract(number, units = 'd') {
|
|
1709
|
-
return this.add(number * -1, units);
|
|
1710
|
-
}
|
|
1711
|
-
|
|
1712
|
-
/**
|
|
1713
|
-
* Returns the difference in days between the two given HDates.
|
|
1714
|
-
*
|
|
1715
|
-
* The result is positive if `this` date is comes chronologically
|
|
1716
|
-
* after the `other` date, and negative
|
|
1717
|
-
* if the order of the two dates is reversed.
|
|
1718
|
-
*
|
|
1719
|
-
* The result is zero if the two dates are identical.
|
|
1720
|
-
* @example
|
|
1721
|
-
* import {HDate, months} from '@hebcal/core';
|
|
1722
|
-
*
|
|
1723
|
-
* const hd1 = new HDate(25, months.KISLEV, 5770);
|
|
1724
|
-
* const hd2 = new HDate(15, months.CHESHVAN, 5769);
|
|
1725
|
-
* const days = hd1.deltaDays(hd2); // 394
|
|
1726
|
-
* @param {HDate} other Hebrew date to compare
|
|
1727
|
-
* @return {number}
|
|
1728
|
-
*/
|
|
1729
|
-
deltaDays(other) {
|
|
1730
|
-
if (!HDate.isHDate(other)) {
|
|
1731
|
-
throw new TypeError(`Bad argument: ${other}`);
|
|
1952
|
+
if (hd.dd > daysInMonth(hd.mm, hd.yy)) {
|
|
1953
|
+
if (hd.mm === months.ELUL) {
|
|
1954
|
+
hd.yy += 1;
|
|
1955
|
+
}
|
|
1956
|
+
hd.dd -= daysInMonth(hd.mm, hd.yy);
|
|
1957
|
+
if (hd.mm === monthsInYear(hd.yy)) {
|
|
1958
|
+
hd.mm = 1; // rollover to NISAN
|
|
1959
|
+
}
|
|
1960
|
+
else {
|
|
1961
|
+
hd.mm += 1;
|
|
1962
|
+
}
|
|
1963
|
+
fix(hd);
|
|
1732
1964
|
}
|
|
1733
|
-
|
|
1734
|
-
|
|
1735
|
-
|
|
1736
|
-
|
|
1737
|
-
|
|
1738
|
-
|
|
1739
|
-
* @return {boolean}
|
|
1740
|
-
*/
|
|
1741
|
-
isSameDate(other) {
|
|
1742
|
-
if (HDate.isHDate(other)) {
|
|
1743
|
-
return this.yy == other.yy && this.mm == other.mm && this.dd == other.dd;
|
|
1965
|
+
fixMonth(hd);
|
|
1966
|
+
}
|
|
1967
|
+
function fixMonth(hd) {
|
|
1968
|
+
if (hd.mm === months.ADAR_II && !hd.isLeapYear()) {
|
|
1969
|
+
hd.mm -= 1; // to Adar I
|
|
1970
|
+
fix(hd);
|
|
1744
1971
|
}
|
|
1745
|
-
|
|
1746
|
-
|
|
1747
|
-
|
|
1748
|
-
|
|
1749
|
-
toString() {
|
|
1750
|
-
const day = this.getDate();
|
|
1751
|
-
const fullYear = this.getFullYear();
|
|
1752
|
-
const monthName = this.getMonthName();
|
|
1753
|
-
return `${day} ${monthName} ${fullYear}`;
|
|
1754
|
-
}
|
|
1755
|
-
|
|
1756
|
-
/**
|
|
1757
|
-
* Returns true if Hebrew year is a leap year
|
|
1758
|
-
* @param {number} year Hebrew year
|
|
1759
|
-
* @return {boolean}
|
|
1760
|
-
*/
|
|
1761
|
-
static isLeapYear(year) {
|
|
1762
|
-
return isLeapYear(year);
|
|
1763
|
-
}
|
|
1764
|
-
|
|
1765
|
-
/**
|
|
1766
|
-
* Number of months in this Hebrew year (either 12 or 13 depending on leap year)
|
|
1767
|
-
* @param {number} year Hebrew year
|
|
1768
|
-
* @return {number}
|
|
1769
|
-
*/
|
|
1770
|
-
static monthsInYear(year) {
|
|
1771
|
-
return monthsInYear(year);
|
|
1772
|
-
}
|
|
1773
|
-
|
|
1774
|
-
/**
|
|
1775
|
-
* Number of days in Hebrew month in a given year (29 or 30)
|
|
1776
|
-
* @param {number} month Hebrew month (e.g. months.TISHREI)
|
|
1777
|
-
* @param {number} year Hebrew year
|
|
1778
|
-
* @return {number}
|
|
1779
|
-
*/
|
|
1780
|
-
static daysInMonth(month, year) {
|
|
1781
|
-
return daysInMonth(month, year);
|
|
1782
|
-
}
|
|
1783
|
-
|
|
1784
|
-
/**
|
|
1785
|
-
* Returns a transliterated string name of Hebrew month in year,
|
|
1786
|
-
* for example 'Elul' or 'Cheshvan'.
|
|
1787
|
-
* @param {number} month Hebrew month (e.g. months.TISHREI)
|
|
1788
|
-
* @param {number} year Hebrew year
|
|
1789
|
-
* @return {string}
|
|
1790
|
-
*/
|
|
1791
|
-
static getMonthName(month, year) {
|
|
1792
|
-
return getMonthName(month, year);
|
|
1793
|
-
}
|
|
1794
|
-
|
|
1795
|
-
/**
|
|
1796
|
-
* Returns the Hebrew month number (NISAN=1, TISHREI=7)
|
|
1797
|
-
* @param {number|string} month A number, or Hebrew month name string
|
|
1798
|
-
* @return {number}
|
|
1799
|
-
*/
|
|
1800
|
-
static monthNum(month) {
|
|
1801
|
-
if (typeof month === 'number') {
|
|
1802
|
-
if (isNaN(month) || month > 14) {
|
|
1803
|
-
throw new RangeError(`Invalid month number: ${month}`);
|
|
1804
|
-
}
|
|
1805
|
-
return month;
|
|
1972
|
+
else if (hd.mm < 1) {
|
|
1973
|
+
hd.mm += monthsInYear(hd.yy);
|
|
1974
|
+
hd.yy -= 1;
|
|
1975
|
+
fix(hd);
|
|
1806
1976
|
}
|
|
1807
|
-
|
|
1808
|
-
|
|
1809
|
-
|
|
1810
|
-
|
|
1811
|
-
/**
|
|
1812
|
-
* Number of days in the hebrew YEAR
|
|
1813
|
-
* @param {number} year Hebrew year
|
|
1814
|
-
* @return {number}
|
|
1815
|
-
*/
|
|
1816
|
-
static daysInYear(year) {
|
|
1817
|
-
return daysInYear(year);
|
|
1818
|
-
}
|
|
1819
|
-
|
|
1820
|
-
/**
|
|
1821
|
-
* true if Cheshvan is long in Hebrew year
|
|
1822
|
-
* @param {number} year Hebrew year
|
|
1823
|
-
* @return {boolean}
|
|
1824
|
-
*/
|
|
1825
|
-
static longCheshvan(year) {
|
|
1826
|
-
return longCheshvan(year);
|
|
1827
|
-
}
|
|
1828
|
-
|
|
1829
|
-
/**
|
|
1830
|
-
* true if Kislev is short in Hebrew year
|
|
1831
|
-
* @param {number} year Hebrew year
|
|
1832
|
-
* @return {boolean}
|
|
1833
|
-
*/
|
|
1834
|
-
static shortKislev(year) {
|
|
1835
|
-
return shortKislev(year);
|
|
1836
|
-
}
|
|
1837
|
-
|
|
1838
|
-
/**
|
|
1839
|
-
* Converts Hebrew month string name to numeric
|
|
1840
|
-
* @param {string|number} monthName monthName
|
|
1841
|
-
* @return {number}
|
|
1842
|
-
*/
|
|
1843
|
-
static monthFromName(monthName) {
|
|
1844
|
-
if (typeof monthName === 'number') {
|
|
1845
|
-
if (isNaN(monthName) || monthName < 1 || monthName > 14) {
|
|
1846
|
-
throw new RangeError(`Invalid month name: ${monthName}`);
|
|
1847
|
-
}
|
|
1848
|
-
return monthName;
|
|
1977
|
+
else if (hd.mm > monthsInYear(hd.yy)) {
|
|
1978
|
+
hd.mm -= monthsInYear(hd.yy);
|
|
1979
|
+
hd.yy += 1;
|
|
1980
|
+
fix(hd);
|
|
1849
1981
|
}
|
|
1850
|
-
|
|
1851
|
-
|
|
1852
|
-
|
|
1982
|
+
delete hd.rd;
|
|
1983
|
+
}
|
|
1984
|
+
function onOrBefore(day, t, offset) {
|
|
1985
|
+
return new HDate(HDate.dayOnOrBefore(day, t.abs() + offset));
|
|
1986
|
+
}
|
|
1853
1987
|
|
|
1854
|
-
|
|
1855
|
-
|
|
1856
|
-
|
|
1857
|
-
|
|
1858
|
-
* date d, and applying it to d+7 gives the DAYNAME following absolute date d.
|
|
1859
|
-
* @param {number} dayOfWeek
|
|
1860
|
-
* @param {number} absdate
|
|
1861
|
-
* @return {number}
|
|
1862
|
-
*/
|
|
1863
|
-
static dayOnOrBefore(dayOfWeek, absdate) {
|
|
1864
|
-
return absdate - (absdate - dayOfWeek) % 7;
|
|
1865
|
-
}
|
|
1988
|
+
/*
|
|
1989
|
+
Hebcal - A Jewish Calendar Generator
|
|
1990
|
+
Copyright (c) 1994-2020 Danny Sadinoff
|
|
1991
|
+
Portions copyright Eyal Schachter and Michael J. Radwin
|
|
1866
1992
|
|
|
1867
|
-
|
|
1868
|
-
* Tests if the object is an instance of `HDate`
|
|
1869
|
-
* @param {any} obj
|
|
1870
|
-
* @return {boolean}
|
|
1871
|
-
*/
|
|
1872
|
-
static isHDate(obj) {
|
|
1873
|
-
return obj !== null && typeof obj === 'object' && typeof obj.yy === 'number' && typeof obj.mm === 'number' && typeof obj.dd === 'number' && typeof obj.greg === 'function' && typeof obj.abs === 'function';
|
|
1874
|
-
}
|
|
1993
|
+
https://github.com/hebcal/hebcal-es6
|
|
1875
1994
|
|
|
1876
|
-
|
|
1877
|
-
|
|
1878
|
-
|
|
1879
|
-
|
|
1880
|
-
|
|
1881
|
-
|
|
1882
|
-
|
|
1883
|
-
|
|
1884
|
-
|
|
1885
|
-
|
|
1886
|
-
|
|
1887
|
-
|
|
1888
|
-
|
|
1889
|
-
|
|
1890
|
-
|
|
1995
|
+
This program is free software; you can redistribute it and/or
|
|
1996
|
+
modify it under the terms of the GNU General Public License
|
|
1997
|
+
as published by the Free Software Foundation; either version 2
|
|
1998
|
+
of the License, or (at your option) any later version.
|
|
1999
|
+
|
|
2000
|
+
This program is distributed in the hope that it will be useful,
|
|
2001
|
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
2002
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
2003
|
+
GNU General Public License for more details.
|
|
2004
|
+
|
|
2005
|
+
You should have received a copy of the GNU General Public License
|
|
2006
|
+
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
2007
|
+
*/
|
|
2008
|
+
/*
|
|
2009
|
+
* Many of the following algorithms were taken from hebrew calendar
|
|
2010
|
+
* routines by Maimonedes, from his Mishneh Torah, and implemented by
|
|
2011
|
+
* Nachum Dershowitz Department of Computer Science
|
|
2012
|
+
* (217) 333-4219 University of Illinois at Urbana-Champaign
|
|
2013
|
+
* nachum@cs.uiuedu 1304 West Springfield Avenue
|
|
2014
|
+
* Urbana, Illinois 61801
|
|
2015
|
+
*
|
|
2016
|
+
* The routines were included in the emacs 19 distribution.
|
|
2017
|
+
*
|
|
2018
|
+
*/
|
|
2019
|
+
const INCOMPLETE = 0;
|
|
2020
|
+
const REGULAR = 1;
|
|
2021
|
+
const COMPLETE = 2;
|
|
2022
|
+
/**
|
|
2023
|
+
* Represents Parashah HaShavua for an entire Hebrew year
|
|
2024
|
+
*/
|
|
2025
|
+
class Sedra {
|
|
2026
|
+
/**
|
|
2027
|
+
* Caculates the Parashah HaShavua for an entire Hebrew year
|
|
2028
|
+
* @param {number} hyear - Hebrew year (e.g. 5749)
|
|
2029
|
+
* @param {boolean} il - Use Israel sedra schedule (false for Diaspora)
|
|
2030
|
+
*/
|
|
2031
|
+
constructor(hyear, il) {
|
|
2032
|
+
hyear = +hyear;
|
|
2033
|
+
const longC = HDate.longCheshvan(hyear);
|
|
2034
|
+
const shortK = HDate.shortKislev(hyear);
|
|
2035
|
+
const type = (longC && !shortK) ? COMPLETE :
|
|
2036
|
+
(!longC && shortK) ? INCOMPLETE :
|
|
2037
|
+
REGULAR;
|
|
2038
|
+
this.year = hyear;
|
|
2039
|
+
const rh0 = new HDate(1, months.TISHREI, hyear);
|
|
2040
|
+
const rh = rh0.abs();
|
|
2041
|
+
const rhDay = rh0.getDay() + 1;
|
|
2042
|
+
// find the first Saturday on or after Rosh Hashana
|
|
2043
|
+
this.firstSaturday = HDate.dayOnOrBefore(6, rh + 6);
|
|
2044
|
+
const leap = +HDate.isLeapYear(hyear);
|
|
2045
|
+
this.il = Boolean(il);
|
|
2046
|
+
let key = `${leap}${rhDay}${type}`;
|
|
2047
|
+
if (types[key]) {
|
|
2048
|
+
this.theSedraArray = types[key];
|
|
2049
|
+
}
|
|
2050
|
+
else {
|
|
2051
|
+
key = key + (+this.il); // cast to num, then concat
|
|
2052
|
+
this.theSedraArray = types[key];
|
|
2053
|
+
}
|
|
2054
|
+
if (!this.theSedraArray) {
|
|
2055
|
+
throw new Error(`improper sedra year type ${key} calculated for ${hyear}`);
|
|
2056
|
+
}
|
|
2057
|
+
}
|
|
2058
|
+
/**
|
|
2059
|
+
* Returns the parsha (or parshiyot) read on Hebrew date
|
|
2060
|
+
* @param {HDate|number} hd Hebrew date or R.D. days
|
|
2061
|
+
* @return {string[]}
|
|
2062
|
+
*/
|
|
2063
|
+
get(hd) {
|
|
2064
|
+
return this.lookup(hd).parsha;
|
|
1891
2065
|
}
|
|
1892
|
-
|
|
1893
|
-
|
|
1894
|
-
|
|
1895
|
-
|
|
1896
|
-
|
|
1897
|
-
|
|
1898
|
-
|
|
2066
|
+
/**
|
|
2067
|
+
* Looks up parsha for the date, then returns a translated or transliterated string
|
|
2068
|
+
* @param {HDate|number} hd Hebrew date or R.D. days
|
|
2069
|
+
* @param {string} [locale] Optional locale name (i.e: `'he'`, `'fr'`). Defaults to active locale
|
|
2070
|
+
* @return {string}
|
|
2071
|
+
*/
|
|
2072
|
+
getString(hd, locale) {
|
|
2073
|
+
const parsha = this.get(hd);
|
|
2074
|
+
const locale0 = locale || Locale.getLocaleName();
|
|
2075
|
+
let name = Locale.gettext(parsha[0], locale0);
|
|
2076
|
+
if (parsha.length == 2) {
|
|
2077
|
+
const hyphen = locale0 == 'he' ? '־' : '-';
|
|
2078
|
+
name += hyphen + Locale.gettext(parsha[1], locale0);
|
|
2079
|
+
}
|
|
2080
|
+
name = name.replace(/'/g, '’');
|
|
2081
|
+
return Locale.gettext('Parashat', locale0) + ' ' + name;
|
|
2082
|
+
}
|
|
2083
|
+
/**
|
|
2084
|
+
* Checks to see if this day would be a regular parasha HaShavua
|
|
2085
|
+
* Torah reading or special holiday reading
|
|
2086
|
+
* @param {HDate|number} hd Hebrew date or R.D. days
|
|
2087
|
+
* @return {boolean}
|
|
2088
|
+
*/
|
|
2089
|
+
isParsha(hd) {
|
|
2090
|
+
return !this.lookup(hd).chag;
|
|
2091
|
+
}
|
|
2092
|
+
/**
|
|
2093
|
+
* Returns the date that a parsha occurs
|
|
2094
|
+
* or `null` if the parsha doesn't occur this year
|
|
2095
|
+
* @param {number|string|string[]} parsha
|
|
2096
|
+
* @return {HDate|null}
|
|
2097
|
+
*/
|
|
2098
|
+
find(parsha) {
|
|
2099
|
+
if (typeof parsha === 'number') {
|
|
2100
|
+
if (parsha > 53 || (parsha < 0 && !isValidDouble(parsha))) {
|
|
2101
|
+
throw new RangeError(`Invalid parsha number: ${parsha}`);
|
|
2102
|
+
}
|
|
2103
|
+
const idx = this.theSedraArray.indexOf(parsha);
|
|
2104
|
+
if (idx === -1) {
|
|
2105
|
+
return null; // doesn't occur this year
|
|
2106
|
+
}
|
|
2107
|
+
return new HDate(this.firstSaturday + (idx * 7));
|
|
2108
|
+
}
|
|
2109
|
+
else if (typeof parsha === 'string') {
|
|
2110
|
+
const num = parsha2id.get(parsha);
|
|
2111
|
+
if (typeof num === 'number') {
|
|
2112
|
+
return this.find(num);
|
|
2113
|
+
}
|
|
2114
|
+
else if (parsha.indexOf('-') !== -1) {
|
|
2115
|
+
return this.find(parsha.split('-'));
|
|
2116
|
+
}
|
|
2117
|
+
else {
|
|
2118
|
+
// try to find Saturday holiday like 'Yom Kippur'
|
|
2119
|
+
const idx = this.theSedraArray.indexOf(parsha);
|
|
2120
|
+
if (idx === -1) {
|
|
2121
|
+
return null; // doesn't occur this year
|
|
2122
|
+
}
|
|
2123
|
+
return new HDate(this.firstSaturday + (idx * 7));
|
|
2124
|
+
}
|
|
2125
|
+
}
|
|
2126
|
+
else if (Array.isArray(parsha) && parsha.length === 1 &&
|
|
2127
|
+
typeof parsha[0] === 'string') {
|
|
2128
|
+
return this.find(parsha[0]);
|
|
2129
|
+
}
|
|
2130
|
+
else if (Array.isArray(parsha) && parsha.length === 2 &&
|
|
2131
|
+
typeof parsha[0] === 'string' && typeof parsha[1] === 'string') {
|
|
2132
|
+
const p1 = parsha[0];
|
|
2133
|
+
const p2 = parsha[1];
|
|
2134
|
+
const num1 = parsha2id.get(p1);
|
|
2135
|
+
const num2 = parsha2id.get(p2);
|
|
2136
|
+
if (num2 === num1 + 1) {
|
|
2137
|
+
return this.find(-num1);
|
|
2138
|
+
}
|
|
2139
|
+
else {
|
|
2140
|
+
throw new RangeError(`Unrecognized parsha name: ${p1}-${p2}`);
|
|
2141
|
+
}
|
|
2142
|
+
}
|
|
2143
|
+
else {
|
|
2144
|
+
throw new TypeError(`Invalid parsha argument: ${parsha}`);
|
|
2145
|
+
}
|
|
2146
|
+
}
|
|
2147
|
+
/**
|
|
2148
|
+
* Returns the underlying annual sedra schedule.
|
|
2149
|
+
* Used by `@hebcal/triennial`
|
|
2150
|
+
* @return {NumberOrString[]}
|
|
2151
|
+
*/
|
|
2152
|
+
getSedraArray() {
|
|
2153
|
+
return this.theSedraArray;
|
|
2154
|
+
}
|
|
2155
|
+
/**
|
|
2156
|
+
* R.D. date of the first Saturday on or after Rosh Hashana
|
|
2157
|
+
* @return {number}
|
|
2158
|
+
*/
|
|
2159
|
+
getFirstSaturday() {
|
|
2160
|
+
return this.firstSaturday;
|
|
2161
|
+
}
|
|
2162
|
+
/** @return {number} */
|
|
2163
|
+
getYear() {
|
|
2164
|
+
return this.year;
|
|
2165
|
+
}
|
|
2166
|
+
/**
|
|
2167
|
+
* Returns an object describing the parsha on the first Saturday on or after `hd`
|
|
2168
|
+
* @param {HDate|number} hd Hebrew date or R.D. days
|
|
2169
|
+
* @return {SedraResult}
|
|
2170
|
+
*/
|
|
2171
|
+
lookup(hd) {
|
|
2172
|
+
const abs = (typeof hd === 'number') ? hd :
|
|
2173
|
+
HDate.isHDate(hd) ? hd.abs() : NaN;
|
|
2174
|
+
if (isNaN(abs)) {
|
|
2175
|
+
throw new TypeError(`Bad date argument: ${hd}`);
|
|
2176
|
+
}
|
|
2177
|
+
// find the first saturday on or after today's date
|
|
2178
|
+
const saturday = HDate.dayOnOrBefore(6, abs + 6);
|
|
2179
|
+
const weekNum = (saturday - this.firstSaturday) / 7;
|
|
2180
|
+
const index = this.theSedraArray[weekNum];
|
|
2181
|
+
if (typeof index === 'undefined') {
|
|
2182
|
+
const sedra = new Sedra(this.year + 1, this.il);
|
|
2183
|
+
return sedra.lookup(saturday); // must be next year
|
|
2184
|
+
}
|
|
2185
|
+
if (typeof index === 'string') {
|
|
2186
|
+
// Shabbat has a chag. Return a description
|
|
2187
|
+
return { parsha: [index], chag: true };
|
|
2188
|
+
}
|
|
2189
|
+
if (index >= 0) {
|
|
2190
|
+
return { parsha: [parshiot[index]], chag: false, num: index + 1 };
|
|
2191
|
+
}
|
|
2192
|
+
const p1 = D$1(index); // undouble the parsha
|
|
2193
|
+
return {
|
|
2194
|
+
parsha: [parshiot[p1], parshiot[p1 + 1]],
|
|
2195
|
+
chag: false,
|
|
2196
|
+
num: [p1 + 1, p1 + 2],
|
|
2197
|
+
};
|
|
1899
2198
|
}
|
|
1900
|
-
return new HDate(day, month, year);
|
|
1901
|
-
}
|
|
1902
2199
|
}
|
|
1903
|
-
|
|
1904
2200
|
/**
|
|
1905
|
-
*
|
|
1906
|
-
*
|
|
2201
|
+
* The 54 parshiyot of the Torah as transilterated strings
|
|
2202
|
+
* parshiot[0] == 'Bereshit', parshiot[1] == 'Noach', parshiot[52] == "Ha'azinu".
|
|
2203
|
+
* @readonly
|
|
2204
|
+
* @type {string[]}
|
|
1907
2205
|
*/
|
|
1908
|
-
|
|
1909
|
-
|
|
1910
|
-
|
|
2206
|
+
const parshiot = [
|
|
2207
|
+
'Bereshit',
|
|
2208
|
+
'Noach',
|
|
2209
|
+
'Lech-Lecha',
|
|
2210
|
+
'Vayera',
|
|
2211
|
+
'Chayei Sara',
|
|
2212
|
+
'Toldot',
|
|
2213
|
+
'Vayetzei',
|
|
2214
|
+
'Vayishlach',
|
|
2215
|
+
'Vayeshev',
|
|
2216
|
+
'Miketz',
|
|
2217
|
+
'Vayigash',
|
|
2218
|
+
'Vayechi',
|
|
2219
|
+
'Shemot',
|
|
2220
|
+
'Vaera',
|
|
2221
|
+
'Bo',
|
|
2222
|
+
'Beshalach',
|
|
2223
|
+
'Yitro',
|
|
2224
|
+
'Mishpatim',
|
|
2225
|
+
'Terumah',
|
|
2226
|
+
'Tetzaveh',
|
|
2227
|
+
'Ki Tisa',
|
|
2228
|
+
'Vayakhel',
|
|
2229
|
+
'Pekudei',
|
|
2230
|
+
'Vayikra',
|
|
2231
|
+
'Tzav',
|
|
2232
|
+
'Shmini',
|
|
2233
|
+
'Tazria',
|
|
2234
|
+
'Metzora',
|
|
2235
|
+
'Achrei Mot',
|
|
2236
|
+
'Kedoshim',
|
|
2237
|
+
'Emor',
|
|
2238
|
+
'Behar',
|
|
2239
|
+
'Bechukotai',
|
|
2240
|
+
'Bamidbar',
|
|
2241
|
+
'Nasso',
|
|
2242
|
+
'Beha\'alotcha',
|
|
2243
|
+
'Sh\'lach',
|
|
2244
|
+
'Korach',
|
|
2245
|
+
'Chukat',
|
|
2246
|
+
'Balak',
|
|
2247
|
+
'Pinchas',
|
|
2248
|
+
'Matot',
|
|
2249
|
+
'Masei',
|
|
2250
|
+
'Devarim',
|
|
2251
|
+
'Vaetchanan',
|
|
2252
|
+
'Eikev',
|
|
2253
|
+
'Re\'eh',
|
|
2254
|
+
'Shoftim',
|
|
2255
|
+
'Ki Teitzei',
|
|
2256
|
+
'Ki Tavo',
|
|
2257
|
+
'Nitzavim',
|
|
2258
|
+
'Vayeilech',
|
|
2259
|
+
'Ha\'azinu',
|
|
2260
|
+
];
|
|
2261
|
+
const parsha2id = new Map();
|
|
2262
|
+
for (let id = 0; id < parshiot.length; id++) {
|
|
2263
|
+
const name = parshiot[id];
|
|
2264
|
+
parsha2id.set(name, id);
|
|
1911
2265
|
}
|
|
1912
|
-
|
|
1913
2266
|
/**
|
|
1914
2267
|
* @private
|
|
1915
|
-
* @param {
|
|
2268
|
+
* @param {number} id
|
|
2269
|
+
* @return {boolean}
|
|
1916
2270
|
*/
|
|
1917
|
-
function
|
|
1918
|
-
|
|
1919
|
-
|
|
1920
|
-
|
|
1921
|
-
|
|
1922
|
-
|
|
1923
|
-
|
|
1924
|
-
|
|
1925
|
-
|
|
1926
|
-
|
|
1927
|
-
if (date.mm === months.ELUL) {
|
|
1928
|
-
date.yy += 1;
|
|
1929
|
-
}
|
|
1930
|
-
date.dd -= daysInMonth(date.mm, date.yy);
|
|
1931
|
-
if (date.mm === monthsInYear(date.yy)) {
|
|
1932
|
-
date.mm = 1; // rollover to NISAN
|
|
1933
|
-
} else {
|
|
1934
|
-
date.mm += 1;
|
|
2271
|
+
function isValidDouble(id) {
|
|
2272
|
+
switch (id) {
|
|
2273
|
+
case -21: // Vayakhel-Pekudei
|
|
2274
|
+
case -26: // Tazria-Metzora
|
|
2275
|
+
case -28: // Achrei Mot-Kedoshim
|
|
2276
|
+
case -31: // Behar-Bechukotai
|
|
2277
|
+
case -38: // Chukat-Balak
|
|
2278
|
+
case -41: // Matot-Masei
|
|
2279
|
+
case -50: // Nitzavim-Vayeilech
|
|
2280
|
+
return true;
|
|
1935
2281
|
}
|
|
1936
|
-
|
|
1937
|
-
}
|
|
1938
|
-
fixMonth(date);
|
|
2282
|
+
return false;
|
|
1939
2283
|
}
|
|
1940
|
-
|
|
1941
2284
|
/**
|
|
2285
|
+
* parsha doubler/undoubler
|
|
1942
2286
|
* @private
|
|
1943
|
-
* @param {
|
|
2287
|
+
* @param {number} p
|
|
2288
|
+
* @return {number}
|
|
1944
2289
|
*/
|
|
1945
|
-
function
|
|
1946
|
-
|
|
1947
|
-
date.mm -= 1; // to Adar I
|
|
1948
|
-
fix(date);
|
|
1949
|
-
} else if (date.mm < 1) {
|
|
1950
|
-
date.mm += monthsInYear(date.yy);
|
|
1951
|
-
date.yy -= 1;
|
|
1952
|
-
fix(date);
|
|
1953
|
-
} else if (date.mm > monthsInYear(date.yy)) {
|
|
1954
|
-
date.mm -= monthsInYear(date.yy);
|
|
1955
|
-
date.yy += 1;
|
|
1956
|
-
fix(date);
|
|
1957
|
-
}
|
|
1958
|
-
delete date.rd;
|
|
2290
|
+
function D$1(p) {
|
|
2291
|
+
return -p;
|
|
1959
2292
|
}
|
|
1960
|
-
|
|
2293
|
+
const RH = 'Rosh Hashana'; // 0
|
|
2294
|
+
const YK = 'Yom Kippur'; // 1
|
|
2295
|
+
const SUKKOT = 'Sukkot'; // 0
|
|
2296
|
+
const CHMSUKOT = 'Sukkot Shabbat Chol ha-Moed'; // 0
|
|
2297
|
+
const SHMINI = 'Shmini Atzeret'; // 0
|
|
2298
|
+
const EOY = CHMSUKOT; // always Sukkot day 3, 5 or 6
|
|
2299
|
+
const PESACH = 'Pesach'; // 25
|
|
2300
|
+
const PESACH1 = 'Pesach I';
|
|
2301
|
+
const CHMPESACH = 'Pesach Shabbat Chol ha-Moed'; // 25
|
|
2302
|
+
const PESACH7 = 'Pesach VII'; // 25
|
|
2303
|
+
const PESACH8 = 'Pesach VIII';
|
|
2304
|
+
const SHAVUOT$1 = 'Shavuot'; // 33
|
|
1961
2305
|
/**
|
|
2306
|
+
* Returns an array from start to end
|
|
1962
2307
|
* @private
|
|
1963
|
-
* @param {number}
|
|
1964
|
-
* @param {
|
|
1965
|
-
* @
|
|
1966
|
-
* @return {HDate}
|
|
2308
|
+
* @param {number} start beginning number, inclusive
|
|
2309
|
+
* @param {number} stop ending number, inclusive
|
|
2310
|
+
* @return {number[]}
|
|
1967
2311
|
*/
|
|
1968
|
-
function
|
|
1969
|
-
|
|
2312
|
+
function range$1(start, stop) {
|
|
2313
|
+
return Array.from({ length: stop - start + 1 }, (v, k) => k + start);
|
|
1970
2314
|
}
|
|
2315
|
+
const empty = [];
|
|
2316
|
+
/**
|
|
2317
|
+
* The ordinary year types (keviot)
|
|
2318
|
+
* names are leap/nonleap - day - incomplete/regular/complete - diaspora/Israel
|
|
2319
|
+
* @private
|
|
2320
|
+
* @readonly
|
|
2321
|
+
* @type {Object.<string, NumberOrString[]>}
|
|
2322
|
+
*/
|
|
2323
|
+
const types = {
|
|
2324
|
+
/* Hebrew year that starts on Monday, is `incomplete' (Heshvan and
|
|
2325
|
+
* Kislev each have 29 days), and has Passover start on Tuesday. */
|
|
2326
|
+
// e.g. 5753
|
|
2327
|
+
'020': empty.concat(51, 52, EOY, range$1(0, 20), D$1(21), 23, 24, PESACH, 25, D$1(26), D$1(28), 30, D$1(31), range$1(33, 40), D$1(41), range$1(43, 49), D$1(50)),
|
|
2328
|
+
/* Hebrew year that starts on Monday, is `complete' (Heshvan and
|
|
2329
|
+
* Kislev each have 30 days), and has Passover start on Thursday. */
|
|
2330
|
+
// e.g. 5756
|
|
2331
|
+
'0220': empty.concat(51, 52, EOY, range$1(0, 20), D$1(21), 23, 24, PESACH, 25, D$1(26), D$1(28), 30, D$1(31), 33, SHAVUOT$1, range$1(34, 37), D$1(38), 40, D$1(41), range$1(43, 49), D$1(50)),
|
|
2332
|
+
/* Hebrew year that starts on Thursday, is `regular' (Heshvan has 29
|
|
2333
|
+
* days and Kislev has 30 days), and has Passover start on Saturday. */
|
|
2334
|
+
// e.g. 5701
|
|
2335
|
+
'0510': empty.concat(52, YK, EOY, range$1(0, 20), D$1(21), 23, 24, PESACH1, PESACH8, 25, D$1(26), D$1(28), 30, D$1(31), range$1(33, 40), D$1(41), range$1(43, 50)),
|
|
2336
|
+
/* Hebrew year that starts on Thursday, is `regular' (Heshvan has 29
|
|
2337
|
+
* days and Kislev has 30 days), and has Passover start on Saturday. */
|
|
2338
|
+
// e.g. 5745
|
|
2339
|
+
'0511': empty.concat(52, YK, EOY, range$1(0, 20), D$1(21), 23, 24, PESACH, 25, D$1(26), D$1(28), range$1(30, 40), D$1(41), range$1(43, 50)),
|
|
2340
|
+
/* Hebrew year that starts on Thursday, is `complete' (Heshvan and
|
|
2341
|
+
* Kislev each have 30 days), and has Passover start on Sunday. */
|
|
2342
|
+
// e.g. 5754
|
|
2343
|
+
'052': empty.concat(52, YK, CHMSUKOT, range$1(0, 24), PESACH7, 25, D$1(26), D$1(28), 30, D$1(31), range$1(33, 40), D$1(41), range$1(43, 50)),
|
|
2344
|
+
/* Hebrew year that starts on Saturday, is `incomplete' (Heshvan and Kislev
|
|
2345
|
+
* each have 29 days), and has Passover start on Sunday. */
|
|
2346
|
+
// e.g. 5761
|
|
2347
|
+
'070': empty.concat(RH, 52, SUKKOT, SHMINI, range$1(0, 20), D$1(21), 23, 24, PESACH7, 25, D$1(26), D$1(28), 30, D$1(31), range$1(33, 40), D$1(41), range$1(43, 50)),
|
|
2348
|
+
/* Hebrew year that starts on Saturday, is `complete' (Heshvan and
|
|
2349
|
+
* Kislev each have 30 days), and has Passover start on Tuesday. */
|
|
2350
|
+
// e.g. 5716
|
|
2351
|
+
'072': empty.concat(RH, 52, SUKKOT, SHMINI, range$1(0, 20), D$1(21), 23, 24, CHMPESACH, 25, D$1(26), D$1(28), 30, D$1(31), range$1(33, 40), D$1(41), range$1(43, 49), D$1(50)),
|
|
2352
|
+
/* -- The leap year types (keviot) -- */
|
|
2353
|
+
/* Hebrew year that starts on Monday, is `incomplete' (Heshvan and
|
|
2354
|
+
* Kislev each have 29 days), and has Passover start on Thursday. */
|
|
2355
|
+
// e.g. 5746
|
|
2356
|
+
'1200': empty.concat(51, 52, CHMSUKOT, range$1(0, 27), CHMPESACH, range$1(28, 33), SHAVUOT$1, range$1(34, 37), D$1(38), 40, D$1(41), range$1(43, 49), D$1(50)),
|
|
2357
|
+
/* Hebrew year that starts on Monday, is `incomplete' (Heshvan and
|
|
2358
|
+
* Kislev each have 29 days), and has Passover start on Thursday. */
|
|
2359
|
+
// e.g. 5746
|
|
2360
|
+
'1201': empty.concat(51, 52, CHMSUKOT, range$1(0, 27), CHMPESACH, range$1(28, 40), D$1(41), range$1(43, 49), D$1(50)),
|
|
2361
|
+
/* Hebrew year that starts on Monday, is `complete' (Heshvan and
|
|
2362
|
+
* Kislev each have 30 days), and has Passover start on Saturday. */
|
|
2363
|
+
// e.g.5752
|
|
2364
|
+
'1220': empty.concat(51, 52, CHMSUKOT, range$1(0, 27), PESACH1, PESACH8, range$1(28, 40), D$1(41), range$1(43, 50)),
|
|
2365
|
+
/* Hebrew year that starts on Monday, is `complete' (Heshvan and
|
|
2366
|
+
* Kislev each have 30 days), and has Passover start on Saturday. */
|
|
2367
|
+
// e.g.5752
|
|
2368
|
+
'1221': empty.concat(51, 52, CHMSUKOT, range$1(0, 27), PESACH, range$1(28, 50)),
|
|
2369
|
+
/* Hebrew year that starts on Thursday, is `incomplete' (Heshvan and
|
|
2370
|
+
* Kislev both have 29 days), and has Passover start on Sunday. */
|
|
2371
|
+
// e.g. 5768
|
|
2372
|
+
'150': empty.concat(52, YK, CHMSUKOT, range$1(0, 28), PESACH7, range$1(29, 50)),
|
|
2373
|
+
/* Hebrew year that starts on Thursday, is `complete' (Heshvan and
|
|
2374
|
+
* Kislev both have 30 days), and has Passover start on Tuesday. */
|
|
2375
|
+
// eg. 5771
|
|
2376
|
+
'152': empty.concat(52, YK, CHMSUKOT, range$1(0, 28), CHMPESACH, range$1(29, 49), D$1(50)),
|
|
2377
|
+
/* Hebrew year that starts on Saturday, is `incomplete' (Heshvan and
|
|
2378
|
+
* Kislev each have 29 days), and has Passover start on Tuesday. */
|
|
2379
|
+
// e.g.5757
|
|
2380
|
+
'170': empty.concat(RH, 52, SUKKOT, SHMINI, range$1(0, 27), CHMPESACH, range$1(28, 40), D$1(41), range$1(43, 49), D$1(50)),
|
|
2381
|
+
/* Hebrew year that starts on Saturday, is `complete' (Heshvan and
|
|
2382
|
+
* Kislev each have 30 days), and has Passover start on Thursday. */
|
|
2383
|
+
'1720': empty.concat(RH, 52, SUKKOT, SHMINI, range$1(0, 27), CHMPESACH, range$1(28, 33), SHAVUOT$1, range$1(34, 37), D$1(38), 40, D$1(41), range$1(43, 49), D$1(50)),
|
|
2384
|
+
};
|
|
2385
|
+
/* Hebrew year that starts on Monday, is `complete' (Heshvan and
|
|
2386
|
+
* Kislev each have 30 days), and has Passover start on Thursday. */
|
|
2387
|
+
types['0221'] = types['020'];
|
|
2388
|
+
/* Hebrew year that starts on Tuesday, is `regular' (Heshvan has 29
|
|
2389
|
+
* days and Kislev has 30 days), and has Passover start on Thursday. */
|
|
2390
|
+
// e.g. 5715
|
|
2391
|
+
types['0310'] = types['0220'];
|
|
2392
|
+
/* Hebrew year that starts on Tuesday, is `regular' (Heshvan has 29
|
|
2393
|
+
* days and Kislev has 30 days), and has Passover start on Thursday. */
|
|
2394
|
+
types['0311'] = types['020'];
|
|
2395
|
+
/* Hebrew year that starts on Tuesday, is `regular' (Heshvan has 29
|
|
2396
|
+
* days and Kislev has 30 days), and has Passover start on Saturday. */
|
|
2397
|
+
// e.g. 5715
|
|
2398
|
+
types['1310'] = types['1220'];
|
|
2399
|
+
/* Hebrew year that starts on Tuesday, is `regular' (Heshvan has 29
|
|
2400
|
+
* days and Kislev has 30 days), and has Passover start on Saturday. */
|
|
2401
|
+
types['1311'] = types['1221'];
|
|
2402
|
+
/* Hebrew year that starts on Saturday, is `complete' (Heshvan and
|
|
2403
|
+
* Kislev each have 30 days), and has Passover start on Thursday. */
|
|
2404
|
+
types['1721'] = types['170'];
|
|
1971
2405
|
|
|
1972
2406
|
/**
|
|
1973
2407
|
* Holiday flags for Event
|
|
@@ -2052,7 +2486,7 @@ class Event {
|
|
|
2052
2486
|
this.date = date;
|
|
2053
2487
|
this.desc = desc;
|
|
2054
2488
|
this.mask = +mask;
|
|
2055
|
-
if (typeof attrs === 'object' && attrs
|
|
2489
|
+
if (typeof attrs === 'object' && attrs != null) {
|
|
2056
2490
|
Object.assign(this, attrs);
|
|
2057
2491
|
}
|
|
2058
2492
|
}
|
|
@@ -2300,7 +2734,7 @@ function Jn(e, n = Map) {
|
|
|
2300
2734
|
};
|
|
2301
2735
|
}
|
|
2302
2736
|
|
|
2303
|
-
function D
|
|
2737
|
+
function D(e) {
|
|
2304
2738
|
return p({
|
|
2305
2739
|
name: e
|
|
2306
2740
|
}, 1);
|
|
@@ -5530,7 +5964,7 @@ function createSlotClass(e, t, n, o, r) {
|
|
|
5530
5964
|
function bindMethod(e, t) {
|
|
5531
5965
|
return Object.defineProperties((function(...t) {
|
|
5532
5966
|
return e.call(this, getSpecificSlots(this), ...t);
|
|
5533
|
-
}), D
|
|
5967
|
+
}), D(t));
|
|
5534
5968
|
}
|
|
5535
5969
|
function getSpecificSlots(t) {
|
|
5536
5970
|
const n = no(t);
|
|
@@ -5545,7 +5979,7 @@ function createSlotClass(e, t, n, o, r) {
|
|
|
5545
5979
|
...h("Temporal." + e)
|
|
5546
5980
|
}), Object.defineProperties(Class, {
|
|
5547
5981
|
...p(r),
|
|
5548
|
-
...D
|
|
5982
|
+
...D(e)
|
|
5549
5983
|
}), [ Class, e => {
|
|
5550
5984
|
const t = Object.create(Class.prototype);
|
|
5551
5985
|
return oo(t, e), t;
|
|
@@ -7462,7 +7896,7 @@ const timeFormatCache = new Map();
|
|
|
7462
7896
|
* @param {string} tzid
|
|
7463
7897
|
* @return {Intl.DateTimeFormat}
|
|
7464
7898
|
*/
|
|
7465
|
-
function getFormatter
|
|
7899
|
+
function getFormatter(tzid) {
|
|
7466
7900
|
const fmt = timeFormatCache.get(tzid);
|
|
7467
7901
|
if (fmt) return fmt;
|
|
7468
7902
|
const f = new Intl.DateTimeFormat('en-US', {
|
|
@@ -7548,7 +7982,7 @@ class Location extends GeoLocation {
|
|
|
7548
7982
|
* @return {Intl.DateTimeFormat}
|
|
7549
7983
|
*/
|
|
7550
7984
|
getTimeFormatter() {
|
|
7551
|
-
return getFormatter
|
|
7985
|
+
return getFormatter(this.getTimeZone());
|
|
7552
7986
|
}
|
|
7553
7987
|
|
|
7554
7988
|
/** @return {string} */
|
|
@@ -7661,97 +8095,12 @@ for (const city of classicCities0) {
|
|
|
7661
8095
|
Location.addLocation(location.getName(), location);
|
|
7662
8096
|
}
|
|
7663
8097
|
|
|
7664
|
-
const _formatters = new Map();
|
|
7665
|
-
|
|
7666
|
-
/**
|
|
7667
|
-
* @private
|
|
7668
|
-
* @param {string} tzid
|
|
7669
|
-
* @return {Intl.DateTimeFormat}
|
|
7670
|
-
*/
|
|
7671
|
-
function getFormatter(tzid) {
|
|
7672
|
-
const fmt = _formatters.get(tzid);
|
|
7673
|
-
if (fmt) return fmt;
|
|
7674
|
-
const f = new Intl.DateTimeFormat('en-US', {
|
|
7675
|
-
year: 'numeric',
|
|
7676
|
-
month: '2-digit',
|
|
7677
|
-
day: '2-digit',
|
|
7678
|
-
hour: '2-digit',
|
|
7679
|
-
minute: '2-digit',
|
|
7680
|
-
second: '2-digit',
|
|
7681
|
-
hour12: false,
|
|
7682
|
-
timeZone: tzid
|
|
7683
|
-
});
|
|
7684
|
-
_formatters.set(tzid, f);
|
|
7685
|
-
return f;
|
|
7686
|
-
}
|
|
7687
|
-
const dateFormatRegex = /^(\d+).(\d+).(\d+),?\s+(\d+).(\d+).(\d+)/;
|
|
7688
|
-
|
|
7689
|
-
/**
|
|
7690
|
-
* @private
|
|
7691
|
-
* @param {string} tzid
|
|
7692
|
-
* @param {Date} date
|
|
7693
|
-
* @return {string}
|
|
7694
|
-
*/
|
|
7695
|
-
function getPseudoISO(tzid, date) {
|
|
7696
|
-
const str = getFormatter(tzid).format(date);
|
|
7697
|
-
const m = dateFormatRegex.exec(str);
|
|
7698
|
-
let hour = m[4];
|
|
7699
|
-
if (hour == '24') hour = '00';
|
|
7700
|
-
m[3] = pad4(m[3]);
|
|
7701
|
-
return `${m[3]}-${m[1]}-${m[2]}T${hour}:${m[5]}:${m[6]}Z`;
|
|
7702
|
-
}
|
|
7703
|
-
|
|
7704
|
-
/**
|
|
7705
|
-
* @private
|
|
7706
|
-
* @param {string} tzid
|
|
7707
|
-
* @param {Date} date
|
|
7708
|
-
* @return {number}
|
|
7709
|
-
*/
|
|
7710
|
-
function getTimezoneOffset(tzid, date) {
|
|
7711
|
-
const utcStr = getPseudoISO('UTC', date);
|
|
7712
|
-
const localStr = getPseudoISO(tzid, date);
|
|
7713
|
-
const diffMs = new Date(utcStr).getTime() - new Date(localStr).getTime();
|
|
7714
|
-
return Math.ceil(diffMs / 1000 / 60);
|
|
7715
|
-
}
|
|
7716
|
-
|
|
7717
|
-
/**
|
|
7718
|
-
* @private
|
|
7719
|
-
* @param {number} number
|
|
7720
|
-
* @return {string}
|
|
7721
|
-
*/
|
|
7722
|
-
function pad4(number) {
|
|
7723
|
-
if (number < 0) {
|
|
7724
|
-
return '-00' + pad4(-number);
|
|
7725
|
-
} else if (number < 10) {
|
|
7726
|
-
return '000' + number;
|
|
7727
|
-
} else if (number < 100) {
|
|
7728
|
-
return '00' + number;
|
|
7729
|
-
} else if (number < 1000) {
|
|
7730
|
-
return '0' + number;
|
|
7731
|
-
}
|
|
7732
|
-
return String(number);
|
|
7733
|
-
}
|
|
7734
|
-
|
|
7735
|
-
/**
|
|
7736
|
-
* @private
|
|
7737
|
-
* @param {number} number
|
|
7738
|
-
* @return {string}
|
|
7739
|
-
*/
|
|
7740
|
-
function pad2(number) {
|
|
7741
|
-
if (number < 10) {
|
|
7742
|
-
return '0' + number;
|
|
7743
|
-
}
|
|
7744
|
-
return String(number);
|
|
7745
|
-
}
|
|
7746
|
-
|
|
7747
8098
|
/**
|
|
7748
|
-
* Returns YYYY-MM-DD in the local timezone
|
|
7749
8099
|
* @private
|
|
7750
|
-
* @param {
|
|
7751
|
-
* @return {string}
|
|
8100
|
+
* @param {string} msg
|
|
7752
8101
|
*/
|
|
7753
|
-
function
|
|
7754
|
-
|
|
8102
|
+
function throwTypeError(msg) {
|
|
8103
|
+
throw new TypeError(msg);
|
|
7755
8104
|
}
|
|
7756
8105
|
|
|
7757
8106
|
Object.defineProperties(globalThis, p({
|
|
@@ -8762,22 +9111,81 @@ class OmerEvent extends Event {
|
|
|
8762
9111
|
* @param {string} locale
|
|
8763
9112
|
* @return {string}
|
|
8764
9113
|
*/
|
|
8765
|
-
getTodayIs(locale) {
|
|
8766
|
-
locale = locale || Locale.getLocaleName();
|
|
8767
|
-
if (typeof locale === 'string') {
|
|
8768
|
-
locale = locale.toLowerCase();
|
|
8769
|
-
}
|
|
8770
|
-
if (locale === 'he') {
|
|
8771
|
-
return omerTodayIs(this.omer, 'he');
|
|
8772
|
-
} else if (locale === 'he-x-nonikud') {
|
|
8773
|
-
const str = omerTodayIs(this.omer, 'he');
|
|
8774
|
-
return Locale.hebrewStripNikkud(str);
|
|
9114
|
+
getTodayIs(locale) {
|
|
9115
|
+
locale = locale || Locale.getLocaleName();
|
|
9116
|
+
if (typeof locale === 'string') {
|
|
9117
|
+
locale = locale.toLowerCase();
|
|
9118
|
+
}
|
|
9119
|
+
if (locale === 'he') {
|
|
9120
|
+
return omerTodayIs(this.omer, 'he');
|
|
9121
|
+
} else if (locale === 'he-x-nonikud') {
|
|
9122
|
+
const str = omerTodayIs(this.omer, 'he');
|
|
9123
|
+
return Locale.hebrewStripNikkud(str);
|
|
9124
|
+
}
|
|
9125
|
+
return omerTodayIs(this.omer, 'en');
|
|
9126
|
+
}
|
|
9127
|
+
/** @return {string} */
|
|
9128
|
+
url() {
|
|
9129
|
+
return `https://www.hebcal.com/omer/${this.getDate().getFullYear()}/${this.omer}`;
|
|
9130
|
+
}
|
|
9131
|
+
}
|
|
9132
|
+
|
|
9133
|
+
/**
|
|
9134
|
+
* Represents one of 54 weekly Torah portions, always on a Saturday
|
|
9135
|
+
*/
|
|
9136
|
+
class ParshaEvent extends Event {
|
|
9137
|
+
/**
|
|
9138
|
+
* @param {HDate} date
|
|
9139
|
+
* @param {string[]} parsha - untranslated name of single or double parsha,
|
|
9140
|
+
* such as ['Bereshit'] or ['Achrei Mot', 'Kedoshim']
|
|
9141
|
+
* @param {boolean} il
|
|
9142
|
+
* @param {number|number[]} num
|
|
9143
|
+
*/
|
|
9144
|
+
constructor(date, parsha, il, num) {
|
|
9145
|
+
if (!Array.isArray(parsha) || parsha.length === 0 || parsha.length > 2) {
|
|
9146
|
+
throw new TypeError('Bad parsha argument');
|
|
9147
|
+
}
|
|
9148
|
+
const desc = 'Parashat ' + parsha.join('-');
|
|
9149
|
+
super(date, desc, flags.PARSHA_HASHAVUA);
|
|
9150
|
+
this.parsha = parsha;
|
|
9151
|
+
this.il = Boolean(il);
|
|
9152
|
+
this.num = num || -1;
|
|
9153
|
+
}
|
|
9154
|
+
/**
|
|
9155
|
+
* @param {string} [locale] Optional locale name (i.e: `'he'`, `'fr'`). Defaults to active locale.
|
|
9156
|
+
* @return {string}
|
|
9157
|
+
*/
|
|
9158
|
+
render(locale) {
|
|
9159
|
+
const locale0 = locale || Locale.getLocaleName();
|
|
9160
|
+
const parsha = this.parsha;
|
|
9161
|
+
let name = Locale.gettext(parsha[0], locale);
|
|
9162
|
+
if (parsha.length == 2) {
|
|
9163
|
+
const hyphen = locale0 == 'he' ? '־' : '-';
|
|
9164
|
+
name += hyphen + Locale.gettext(parsha[1], locale);
|
|
8775
9165
|
}
|
|
8776
|
-
|
|
9166
|
+
name = name.replace(/'/g, '’');
|
|
9167
|
+
const str = Locale.gettext('Parashat', locale) + ' ' + name;
|
|
9168
|
+
return str.normalize();
|
|
9169
|
+
}
|
|
9170
|
+
/** @return {string} */
|
|
9171
|
+
basename() {
|
|
9172
|
+
return this.parsha.join('-');
|
|
8777
9173
|
}
|
|
8778
9174
|
/** @return {string} */
|
|
8779
9175
|
url() {
|
|
8780
|
-
|
|
9176
|
+
const year = this.getDate().greg().getFullYear();
|
|
9177
|
+
if (year < 100) {
|
|
9178
|
+
return undefined;
|
|
9179
|
+
}
|
|
9180
|
+
const dt = this.urlDateSuffix();
|
|
9181
|
+
const url = 'https://www.hebcal.com/sedrot/' + this.basename().toLowerCase().replace(/'/g, '').replace(/ /g, '-') + '-' + dt;
|
|
9182
|
+
return this.il ? url + '?i=on' : url;
|
|
9183
|
+
}
|
|
9184
|
+
|
|
9185
|
+
/** @return {string} */
|
|
9186
|
+
urlDateSuffix() {
|
|
9187
|
+
const isoDate = isoDateString(this.getDate().greg());
|
|
9188
|
+
return isoDate.replace(/-/g, '');
|
|
8781
9189
|
}
|
|
8782
9190
|
}
|
|
8783
9191
|
|
|
@@ -8989,556 +9397,90 @@ class QuickLRU extends Map {
|
|
|
8989
9397
|
for (const [, value] of this) {
|
|
8990
9398
|
yield value;
|
|
8991
9399
|
}
|
|
8992
|
-
}
|
|
8993
|
-
|
|
8994
|
-
* [Symbol.iterator]() {
|
|
8995
|
-
for (const item of this.#cache) {
|
|
8996
|
-
const [key, value] = item;
|
|
8997
|
-
const deleted = this.#deleteIfExpired(key, value);
|
|
8998
|
-
if (deleted === false) {
|
|
8999
|
-
yield [key, value.value];
|
|
9000
|
-
}
|
|
9001
|
-
}
|
|
9002
|
-
|
|
9003
|
-
for (const item of this.#oldCache) {
|
|
9004
|
-
const [key, value] = item;
|
|
9005
|
-
if (!this.#cache.has(key)) {
|
|
9006
|
-
const deleted = this.#deleteIfExpired(key, value);
|
|
9007
|
-
if (deleted === false) {
|
|
9008
|
-
yield [key, value.value];
|
|
9009
|
-
}
|
|
9010
|
-
}
|
|
9011
|
-
}
|
|
9012
|
-
}
|
|
9013
|
-
|
|
9014
|
-
* entriesDescending() {
|
|
9015
|
-
let items = [...this.#cache];
|
|
9016
|
-
for (let i = items.length - 1; i >= 0; --i) {
|
|
9017
|
-
const item = items[i];
|
|
9018
|
-
const [key, value] = item;
|
|
9019
|
-
const deleted = this.#deleteIfExpired(key, value);
|
|
9020
|
-
if (deleted === false) {
|
|
9021
|
-
yield [key, value.value];
|
|
9022
|
-
}
|
|
9023
|
-
}
|
|
9024
|
-
|
|
9025
|
-
items = [...this.#oldCache];
|
|
9026
|
-
for (let i = items.length - 1; i >= 0; --i) {
|
|
9027
|
-
const item = items[i];
|
|
9028
|
-
const [key, value] = item;
|
|
9029
|
-
if (!this.#cache.has(key)) {
|
|
9030
|
-
const deleted = this.#deleteIfExpired(key, value);
|
|
9031
|
-
if (deleted === false) {
|
|
9032
|
-
yield [key, value.value];
|
|
9033
|
-
}
|
|
9034
|
-
}
|
|
9035
|
-
}
|
|
9036
|
-
}
|
|
9037
|
-
|
|
9038
|
-
* entriesAscending() {
|
|
9039
|
-
for (const [key, value] of this.#entriesAscending()) {
|
|
9040
|
-
yield [key, value.value];
|
|
9041
|
-
}
|
|
9042
|
-
}
|
|
9043
|
-
|
|
9044
|
-
get size() {
|
|
9045
|
-
if (!this.#size) {
|
|
9046
|
-
return this.#oldCache.size;
|
|
9047
|
-
}
|
|
9048
|
-
|
|
9049
|
-
let oldCacheSize = 0;
|
|
9050
|
-
for (const key of this.#oldCache.keys()) {
|
|
9051
|
-
if (!this.#cache.has(key)) {
|
|
9052
|
-
oldCacheSize++;
|
|
9053
|
-
}
|
|
9054
|
-
}
|
|
9055
|
-
|
|
9056
|
-
return Math.min(this.#size + oldCacheSize, this.#maxSize);
|
|
9057
|
-
}
|
|
9058
|
-
|
|
9059
|
-
get maxSize() {
|
|
9060
|
-
return this.#maxSize;
|
|
9061
|
-
}
|
|
9062
|
-
|
|
9063
|
-
entries() {
|
|
9064
|
-
return this.entriesAscending();
|
|
9065
|
-
}
|
|
9066
|
-
|
|
9067
|
-
forEach(callbackFunction, thisArgument = this) {
|
|
9068
|
-
for (const [key, value] of this.entriesAscending()) {
|
|
9069
|
-
callbackFunction.call(thisArgument, value, key, this);
|
|
9070
|
-
}
|
|
9071
|
-
}
|
|
9072
|
-
|
|
9073
|
-
get [Symbol.toStringTag]() {
|
|
9074
|
-
return JSON.stringify([...this.entriesAscending()]);
|
|
9075
|
-
}
|
|
9076
|
-
}
|
|
9077
|
-
|
|
9078
|
-
/* eslint-disable new-cap */
|
|
9079
|
-
/*
|
|
9080
|
-
Hebcal - A Jewish Calendar Generator
|
|
9081
|
-
Copyright (c) 1994-2020 Danny Sadinoff
|
|
9082
|
-
Portions copyright Eyal Schachter and Michael J. Radwin
|
|
9083
|
-
|
|
9084
|
-
https://github.com/hebcal/hebcal-es6
|
|
9085
|
-
|
|
9086
|
-
This program is free software; you can redistribute it and/or
|
|
9087
|
-
modify it under the terms of the GNU General Public License
|
|
9088
|
-
as published by the Free Software Foundation; either version 2
|
|
9089
|
-
of the License, or (at your option) any later version.
|
|
9090
|
-
|
|
9091
|
-
This program is distributed in the hope that it will be useful,
|
|
9092
|
-
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
9093
|
-
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
9094
|
-
GNU General Public License for more details.
|
|
9095
|
-
|
|
9096
|
-
You should have received a copy of the GNU General Public License
|
|
9097
|
-
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
9098
|
-
*/
|
|
9099
|
-
|
|
9100
|
-
const INCOMPLETE = 0;
|
|
9101
|
-
const REGULAR = 1;
|
|
9102
|
-
const COMPLETE = 2;
|
|
9103
|
-
|
|
9104
|
-
// eslint-disable-next-line require-jsdoc
|
|
9105
|
-
function throwError(errorMessage) {
|
|
9106
|
-
throw new TypeError(errorMessage);
|
|
9107
|
-
}
|
|
9108
|
-
|
|
9109
|
-
/**
|
|
9110
|
-
* Result of Sedra.lookup
|
|
9111
|
-
* @typedef {Object} SedraResult
|
|
9112
|
-
* @property {string[]} parsha Name of the parsha (or parshiyot) read on
|
|
9113
|
-
* Hebrew date, e.g. `['Noach']` or `['Matot', 'Masei']`
|
|
9114
|
-
* @property {boolean} chag True if this is a regular parasha HaShavua
|
|
9115
|
-
* Torah reading, false if it's a special holiday reading
|
|
9116
|
-
* @property {number|number[]} num the parsha number (or numbers) using 1-indexing.
|
|
9117
|
-
* A `number` for a regular (single) parsha, and a `number[]` for a doubled parsha.
|
|
9118
|
-
* For Parashat *Bereshit*, `num` would be equal to `1`, and for
|
|
9119
|
-
* *Matot-Masei* it would be `[42, 43]`
|
|
9120
|
-
*/
|
|
9121
|
-
|
|
9122
|
-
/**
|
|
9123
|
-
* Represents Parashah HaShavua for an entire Hebrew year
|
|
9124
|
-
*/
|
|
9125
|
-
class Sedra {
|
|
9126
|
-
/**
|
|
9127
|
-
* Caculates the Parashah HaShavua for an entire Hebrew year
|
|
9128
|
-
* @param {number} hebYr - Hebrew year (e.g. 5749)
|
|
9129
|
-
* @param {boolean} il - Use Israel sedra schedule (false for Diaspora)
|
|
9130
|
-
*/
|
|
9131
|
-
constructor(hebYr, il) {
|
|
9132
|
-
// the Hebrew year
|
|
9133
|
-
hebYr = +hebYr;
|
|
9134
|
-
const longC = HDate.longCheshvan(hebYr);
|
|
9135
|
-
const shortK = HDate.shortKislev(hebYr);
|
|
9136
|
-
const type = this.type = longC && !shortK ? COMPLETE : !longC && shortK ? INCOMPLETE : REGULAR;
|
|
9137
|
-
this.year = hebYr;
|
|
9138
|
-
const rh0 = new HDate(1, months.TISHREI, hebYr);
|
|
9139
|
-
const rh = rh0.abs();
|
|
9140
|
-
const rhDay = this.roshHashanaDay = rh0.getDay() + 1;
|
|
9141
|
-
|
|
9142
|
-
// find the first Saturday on or after Rosh Hashana
|
|
9143
|
-
this.firstSaturday = HDate.dayOnOrBefore(6, rh + 6);
|
|
9144
|
-
const leap = this.leap = +HDate.isLeapYear(hebYr);
|
|
9145
|
-
this.il = Boolean(il);
|
|
9146
|
-
const key = `${leap}${rhDay}${type}`;
|
|
9147
|
-
if (types[key]) {
|
|
9148
|
-
this.key = key;
|
|
9149
|
-
this.theSedraArray = types[key];
|
|
9150
|
-
} else {
|
|
9151
|
-
const key2 = this.key = key + +this.il; // cast to num, then concat
|
|
9152
|
-
this.theSedraArray = types[key2];
|
|
9153
|
-
}
|
|
9154
|
-
if (!this.theSedraArray) {
|
|
9155
|
-
throw new Error(`improper sedra year type ${this.key} calculated for ${hebYr}`);
|
|
9156
|
-
}
|
|
9157
|
-
}
|
|
9158
|
-
|
|
9159
|
-
/**
|
|
9160
|
-
* Returns the parsha (or parshiyot) read on Hebrew date
|
|
9161
|
-
* @param {HDate|number} hDate Hebrew date or R.D. days
|
|
9162
|
-
* @return {string[]}
|
|
9163
|
-
*/
|
|
9164
|
-
get(hDate) {
|
|
9165
|
-
return this.lookup(hDate).parsha;
|
|
9166
|
-
}
|
|
9167
|
-
|
|
9168
|
-
/**
|
|
9169
|
-
* Looks up parsha for the date, then returns a translated or transliterated string
|
|
9170
|
-
* @param {HDate|number} hDate Hebrew date or R.D. days
|
|
9171
|
-
* @param {string} [locale] Optional locale name (i.e: `'he'`, `'fr'`). Defaults to active locale
|
|
9172
|
-
* @return {string}
|
|
9173
|
-
*/
|
|
9174
|
-
getString(hDate, locale) {
|
|
9175
|
-
const parsha = this.get(hDate);
|
|
9176
|
-
const locale0 = locale || Locale.getLocaleName();
|
|
9177
|
-
let name = Locale.gettext(parsha[0], locale0);
|
|
9178
|
-
if (parsha.length == 2) {
|
|
9179
|
-
const hyphen = locale0 == 'he' ? '־' : '-';
|
|
9180
|
-
name += hyphen + Locale.gettext(parsha[1], locale0);
|
|
9181
|
-
}
|
|
9182
|
-
name = name.replace(/'/g, '’');
|
|
9183
|
-
return Locale.gettext('Parashat', locale0) + ' ' + name;
|
|
9184
|
-
}
|
|
9185
|
-
|
|
9186
|
-
/**
|
|
9187
|
-
* Checks to see if this day would be a regular parasha HaShavua
|
|
9188
|
-
* Torah reading or special holiday reading
|
|
9189
|
-
* @param {HDate|number} hDate Hebrew date or R.D. days
|
|
9190
|
-
* @return {boolean}
|
|
9191
|
-
*/
|
|
9192
|
-
isParsha(hDate) {
|
|
9193
|
-
return !this.lookup(hDate).chag;
|
|
9194
|
-
}
|
|
9195
|
-
|
|
9196
|
-
/**
|
|
9197
|
-
* Returns the date that a parsha occurs
|
|
9198
|
-
* @param {number|string|string[]} parsha
|
|
9199
|
-
* @return {HDate}
|
|
9200
|
-
*/
|
|
9201
|
-
find(parsha) {
|
|
9202
|
-
if (typeof parsha === 'number') {
|
|
9203
|
-
if (parsha > 53 || parsha < 0 && !isValidDouble(parsha)) {
|
|
9204
|
-
throw new RangeError(`Invalid parsha number: ${parsha}`);
|
|
9205
|
-
}
|
|
9206
|
-
const idx = this.theSedraArray.indexOf(parsha);
|
|
9207
|
-
if (idx === -1) {
|
|
9208
|
-
return null; // doesn't occur this year
|
|
9209
|
-
}
|
|
9210
|
-
return new HDate(this.firstSaturday + idx * 7);
|
|
9211
|
-
} else if (typeof parsha === 'string') {
|
|
9212
|
-
const num = parsha2id.get(parsha);
|
|
9213
|
-
if (typeof num === 'number') {
|
|
9214
|
-
return this.find(num);
|
|
9215
|
-
} else if (parsha.indexOf('-') !== -1) {
|
|
9216
|
-
return this.find(parsha.split('-'));
|
|
9217
|
-
} else {
|
|
9218
|
-
// try to find Saturday holiday like 'Yom Kippur'
|
|
9219
|
-
const idx = this.theSedraArray.indexOf(parsha);
|
|
9220
|
-
if (idx === -1) {
|
|
9221
|
-
return null; // doesn't occur this year
|
|
9222
|
-
}
|
|
9223
|
-
return new HDate(this.firstSaturday + idx * 7);
|
|
9224
|
-
}
|
|
9225
|
-
} else if (Array.isArray(parsha) && parsha.length === 1 && typeof parsha[0] === 'string') {
|
|
9226
|
-
return this.find(parsha[0]);
|
|
9227
|
-
} else if (Array.isArray(parsha) && parsha.length === 2 && typeof parsha[0] === 'string' && typeof parsha[1] === 'string') {
|
|
9228
|
-
const p1 = parsha[0];
|
|
9229
|
-
const p2 = parsha[1];
|
|
9230
|
-
const num1 = parsha2id.get(p1);
|
|
9231
|
-
const num2 = parsha2id.get(p2);
|
|
9232
|
-
if (num2 === num1 + 1) {
|
|
9233
|
-
return this.find(-num1);
|
|
9234
|
-
} else {
|
|
9235
|
-
throw new RangeError(`Unrecognized parsha name: ${p1}-${p2}`);
|
|
9236
|
-
}
|
|
9237
|
-
} else {
|
|
9238
|
-
throw new TypeError(`Invalid parsha argument: ${parsha}`);
|
|
9239
|
-
}
|
|
9240
|
-
}
|
|
9241
|
-
|
|
9242
|
-
/**
|
|
9243
|
-
* @return {Object[]}
|
|
9244
|
-
*/
|
|
9245
|
-
getSedraArray() {
|
|
9246
|
-
return this.theSedraArray;
|
|
9247
|
-
}
|
|
9248
|
-
|
|
9249
|
-
/**
|
|
9250
|
-
* R.D. date of the first Saturday on or after Rosh Hashana
|
|
9251
|
-
* @return {number}
|
|
9252
|
-
*/
|
|
9253
|
-
getFirstSaturday() {
|
|
9254
|
-
return this.firstSaturday;
|
|
9255
|
-
}
|
|
9256
|
-
|
|
9257
|
-
/** @return {number} */
|
|
9258
|
-
getYear() {
|
|
9259
|
-
return this.year;
|
|
9260
|
-
}
|
|
9261
|
-
|
|
9262
|
-
/**
|
|
9263
|
-
* Returns an object describing the parsha on the first Saturday on or after absdate
|
|
9264
|
-
* @param {HDate|number} hDate Hebrew date or R.D. days
|
|
9265
|
-
* @return {SedraResult}
|
|
9266
|
-
*/
|
|
9267
|
-
lookup(hDate) {
|
|
9268
|
-
const absDate = typeof hDate === 'number' ? hDate : HDate.isHDate(hDate) ? hDate.abs() : throwError(`Bad date argument: ${hDate}`);
|
|
9269
|
-
|
|
9270
|
-
// find the first saturday on or after today's date
|
|
9271
|
-
const saturday = HDate.dayOnOrBefore(6, absDate + 6);
|
|
9272
|
-
const weekNum = (saturday - this.firstSaturday) / 7;
|
|
9273
|
-
const index = this.theSedraArray[weekNum];
|
|
9274
|
-
if (typeof index === 'undefined') {
|
|
9275
|
-
const sedra = getSedra_(this.year + 1, this.il);
|
|
9276
|
-
return sedra.lookup(saturday); // must be next year
|
|
9277
|
-
}
|
|
9278
|
-
if (typeof index === 'string') {
|
|
9279
|
-
// Shabbat has a chag. Return a description
|
|
9280
|
-
return {
|
|
9281
|
-
parsha: [index],
|
|
9282
|
-
chag: true
|
|
9283
|
-
};
|
|
9284
|
-
}
|
|
9285
|
-
if (index >= 0) {
|
|
9286
|
-
return {
|
|
9287
|
-
parsha: [parshiot[index]],
|
|
9288
|
-
chag: false,
|
|
9289
|
-
num: index + 1
|
|
9290
|
-
};
|
|
9291
|
-
}
|
|
9292
|
-
const p1 = D(index); // undouble the parsha
|
|
9293
|
-
return {
|
|
9294
|
-
parsha: [parshiot[p1], parshiot[p1 + 1]],
|
|
9295
|
-
chag: false,
|
|
9296
|
-
num: [p1 + 1, p1 + 2]
|
|
9297
|
-
};
|
|
9298
|
-
}
|
|
9299
|
-
}
|
|
9300
|
-
|
|
9301
|
-
/**
|
|
9302
|
-
* The 54 parshiyot of the Torah as transilterated strings
|
|
9303
|
-
* parshiot[0] == 'Bereshit', parshiot[1] == 'Noach', parshiot[53] == "Ha'azinu".
|
|
9304
|
-
* @readonly
|
|
9305
|
-
* @type {string[]}
|
|
9306
|
-
*/
|
|
9307
|
-
const parshiot = ['Bereshit', 'Noach', 'Lech-Lecha', 'Vayera', 'Chayei Sara', 'Toldot', 'Vayetzei', 'Vayishlach', 'Vayeshev', 'Miketz', 'Vayigash', 'Vayechi', 'Shemot', 'Vaera', 'Bo', 'Beshalach', 'Yitro', 'Mishpatim', 'Terumah', 'Tetzaveh', 'Ki Tisa', 'Vayakhel', 'Pekudei', 'Vayikra', 'Tzav', 'Shmini', 'Tazria', 'Metzora', 'Achrei Mot', 'Kedoshim', 'Emor', 'Behar', 'Bechukotai', 'Bamidbar', 'Nasso', 'Beha\'alotcha', 'Sh\'lach', 'Korach', 'Chukat', 'Balak', 'Pinchas', 'Matot', 'Masei', 'Devarim', 'Vaetchanan', 'Eikev', 'Re\'eh', 'Shoftim', 'Ki Teitzei', 'Ki Tavo', 'Nitzavim', 'Vayeilech', 'Ha\'azinu'];
|
|
9308
|
-
const parsha2id = new Map();
|
|
9309
|
-
for (let id = 0; id < parshiot.length; id++) {
|
|
9310
|
-
const name = parshiot[id];
|
|
9311
|
-
parsha2id.set(name, id);
|
|
9312
|
-
}
|
|
9313
|
-
|
|
9314
|
-
/**
|
|
9315
|
-
* @private
|
|
9316
|
-
* @param {number} id
|
|
9317
|
-
* @return {boolean}
|
|
9318
|
-
*/
|
|
9319
|
-
function isValidDouble(id) {
|
|
9320
|
-
switch (id) {
|
|
9321
|
-
case -21: // Vayakhel-Pekudei
|
|
9322
|
-
case -26: // Tazria-Metzora
|
|
9323
|
-
case -28: // Achrei Mot-Kedoshim
|
|
9324
|
-
case -31: // Behar-Bechukotai
|
|
9325
|
-
case -38: // Chukat-Balak
|
|
9326
|
-
case -41: // Matot-Masei
|
|
9327
|
-
case -50:
|
|
9328
|
-
// Nitzavim-Vayeilech
|
|
9329
|
-
return true;
|
|
9330
|
-
}
|
|
9331
|
-
return false;
|
|
9332
|
-
}
|
|
9333
|
-
|
|
9334
|
-
/**
|
|
9335
|
-
* @private
|
|
9336
|
-
* @param {number} p
|
|
9337
|
-
* @return {number}
|
|
9338
|
-
*/
|
|
9339
|
-
function D(p) {
|
|
9340
|
-
// parsha doubler/undoubler
|
|
9341
|
-
return -p;
|
|
9342
|
-
}
|
|
9343
|
-
const RH = 'Rosh Hashana'; // 0
|
|
9344
|
-
const YK = 'Yom Kippur'; // 1
|
|
9400
|
+
}
|
|
9345
9401
|
|
|
9346
|
-
|
|
9347
|
-
const
|
|
9348
|
-
const
|
|
9349
|
-
const
|
|
9402
|
+
* [Symbol.iterator]() {
|
|
9403
|
+
for (const item of this.#cache) {
|
|
9404
|
+
const [key, value] = item;
|
|
9405
|
+
const deleted = this.#deleteIfExpired(key, value);
|
|
9406
|
+
if (deleted === false) {
|
|
9407
|
+
yield [key, value.value];
|
|
9408
|
+
}
|
|
9409
|
+
}
|
|
9350
9410
|
|
|
9351
|
-
const
|
|
9352
|
-
const
|
|
9353
|
-
|
|
9354
|
-
const
|
|
9355
|
-
|
|
9356
|
-
|
|
9411
|
+
for (const item of this.#oldCache) {
|
|
9412
|
+
const [key, value] = item;
|
|
9413
|
+
if (!this.#cache.has(key)) {
|
|
9414
|
+
const deleted = this.#deleteIfExpired(key, value);
|
|
9415
|
+
if (deleted === false) {
|
|
9416
|
+
yield [key, value.value];
|
|
9417
|
+
}
|
|
9418
|
+
}
|
|
9419
|
+
}
|
|
9420
|
+
}
|
|
9357
9421
|
|
|
9358
|
-
|
|
9359
|
-
|
|
9360
|
-
|
|
9361
|
-
|
|
9362
|
-
|
|
9363
|
-
|
|
9364
|
-
|
|
9365
|
-
|
|
9366
|
-
|
|
9367
|
-
|
|
9368
|
-
}, (v, k) => k + start);
|
|
9369
|
-
}
|
|
9422
|
+
* entriesDescending() {
|
|
9423
|
+
let items = [...this.#cache];
|
|
9424
|
+
for (let i = items.length - 1; i >= 0; --i) {
|
|
9425
|
+
const item = items[i];
|
|
9426
|
+
const [key, value] = item;
|
|
9427
|
+
const deleted = this.#deleteIfExpired(key, value);
|
|
9428
|
+
if (deleted === false) {
|
|
9429
|
+
yield [key, value.value];
|
|
9430
|
+
}
|
|
9431
|
+
}
|
|
9370
9432
|
|
|
9371
|
-
|
|
9372
|
-
|
|
9373
|
-
|
|
9374
|
-
|
|
9375
|
-
|
|
9376
|
-
|
|
9377
|
-
|
|
9378
|
-
|
|
9379
|
-
|
|
9380
|
-
|
|
9381
|
-
|
|
9382
|
-
|
|
9383
|
-
/* Hebrew year that starts on Monday, is `complete' (Heshvan and
|
|
9384
|
-
* Kislev each have 30 days), and has Passover start on Thursday. */
|
|
9385
|
-
// e.g. 5756
|
|
9386
|
-
'0220': [51, 52].concat(EOY, range$1(0, 20), D(21), 23, 24, PESACH, 25, D(26), D(28), 30, D(31), 33, SHAVUOT$1, range$1(34, 37), D(38), 40, D(41), range$1(43, 49), D(50)),
|
|
9387
|
-
/* Hebrew year that starts on Thursday, is `regular' (Heshvan has 29
|
|
9388
|
-
* days and Kislev has 30 days), and has Passover start on Saturday. */
|
|
9389
|
-
// e.g. 5701
|
|
9390
|
-
'0510': [52].concat(YK, EOY, range$1(0, 20), D(21), 23, 24, PESACH1, PESACH8, 25, D(26), D(28), 30, D(31), range$1(33, 40), D(41), range$1(43, 50)),
|
|
9391
|
-
/* Hebrew year that starts on Thursday, is `regular' (Heshvan has 29
|
|
9392
|
-
* days and Kislev has 30 days), and has Passover start on Saturday. */
|
|
9393
|
-
// e.g. 5745
|
|
9394
|
-
'0511': [52].concat(YK, EOY, range$1(0, 20), D(21), 23, 24, PESACH, 25, D(26), D(28), range$1(30, 40), D(41), range$1(43, 50)),
|
|
9395
|
-
/* Hebrew year that starts on Thursday, is `complete' (Heshvan and
|
|
9396
|
-
* Kislev each have 30 days), and has Passover start on Sunday. */
|
|
9397
|
-
// e.g. 5754
|
|
9398
|
-
'052': [52].concat(YK, CHMSUKOT, range$1(0, 24), PESACH7, 25, D(26), D(28), 30, D(31), range$1(33, 40), D(41), range$1(43, 50)),
|
|
9399
|
-
/* Hebrew year that starts on Saturday, is `incomplete' (Heshvan and Kislev
|
|
9400
|
-
* each have 29 days), and has Passover start on Sunday. */
|
|
9401
|
-
// e.g. 5761
|
|
9402
|
-
'070': [].concat(RH, 52, SUKKOT, SHMINI, range$1(0, 20), D(21), 23, 24, PESACH7, 25, D(26), D(28), 30, D(31), range$1(33, 40), D(41), range$1(43, 50)),
|
|
9403
|
-
/* Hebrew year that starts on Saturday, is `complete' (Heshvan and
|
|
9404
|
-
* Kislev each have 30 days), and has Passover start on Tuesday. */
|
|
9405
|
-
// e.g. 5716
|
|
9406
|
-
'072': [].concat(RH, 52, SUKKOT, SHMINI, range$1(0, 20), D(21), 23, 24, CHMPESACH, 25, D(26), D(28), 30, D(31), range$1(33, 40), D(41), range$1(43, 49), D(50)),
|
|
9407
|
-
/* -- The leap year types (keviot) -- */
|
|
9408
|
-
/* Hebrew year that starts on Monday, is `incomplete' (Heshvan and
|
|
9409
|
-
* Kislev each have 29 days), and has Passover start on Thursday. */
|
|
9410
|
-
// e.g. 5746
|
|
9411
|
-
'1200': [51, 52].concat(CHMSUKOT, range$1(0, 27), CHMPESACH, range$1(28, 33), SHAVUOT$1, range$1(34, 37), D(38), 40, D(41), range$1(43, 49), D(50)),
|
|
9412
|
-
/* Hebrew year that starts on Monday, is `incomplete' (Heshvan and
|
|
9413
|
-
* Kislev each have 29 days), and has Passover start on Thursday. */
|
|
9414
|
-
// e.g. 5746
|
|
9415
|
-
'1201': [51, 52].concat(CHMSUKOT, range$1(0, 27), CHMPESACH, range$1(28, 40), D(41), range$1(43, 49), D(50)),
|
|
9416
|
-
/* Hebrew year that starts on Monday, is `complete' (Heshvan and
|
|
9417
|
-
* Kislev each have 30 days), and has Passover start on Saturday. */
|
|
9418
|
-
// e.g.5752
|
|
9419
|
-
'1220': [51, 52].concat(CHMSUKOT, range$1(0, 27), PESACH1, PESACH8, range$1(28, 40), D(41), range$1(43, 50)),
|
|
9420
|
-
/* Hebrew year that starts on Monday, is `complete' (Heshvan and
|
|
9421
|
-
* Kislev each have 30 days), and has Passover start on Saturday. */
|
|
9422
|
-
// e.g.5752
|
|
9423
|
-
'1221': [51, 52].concat(CHMSUKOT, range$1(0, 27), PESACH, range$1(28, 50)),
|
|
9424
|
-
/* Hebrew year that starts on Thursday, is `incomplete' (Heshvan and
|
|
9425
|
-
* Kislev both have 29 days), and has Passover start on Sunday. */
|
|
9426
|
-
// e.g. 5768
|
|
9427
|
-
'150': [52].concat(YK, CHMSUKOT, range$1(0, 28), PESACH7, range$1(29, 50)),
|
|
9428
|
-
/* Hebrew year that starts on Thursday, is `complete' (Heshvan and
|
|
9429
|
-
* Kislev both have 30 days), and has Passover start on Tuesday. */
|
|
9430
|
-
// eg. 5771
|
|
9431
|
-
'152': [52].concat(YK, CHMSUKOT, range$1(0, 28), CHMPESACH, range$1(29, 49), D(50)),
|
|
9432
|
-
/* Hebrew year that starts on Saturday, is `incomplete' (Heshvan and
|
|
9433
|
-
* Kislev each have 29 days), and has Passover start on Tuesday. */
|
|
9434
|
-
// e.g.5757
|
|
9435
|
-
'170': [].concat(RH, 52, SUKKOT, SHMINI, range$1(0, 27), CHMPESACH, range$1(28, 40), D(41), range$1(43, 49), D(50)),
|
|
9436
|
-
/* Hebrew year that starts on Saturday, is `complete' (Heshvan and
|
|
9437
|
-
* Kislev each have 30 days), and has Passover start on Thursday. */
|
|
9438
|
-
'1720': [].concat(RH, 52, SUKKOT, SHMINI, range$1(0, 27), CHMPESACH, range$1(28, 33), SHAVUOT$1, range$1(34, 37), D(38), 40, D(41), range$1(43, 49), D(50))
|
|
9439
|
-
};
|
|
9433
|
+
items = [...this.#oldCache];
|
|
9434
|
+
for (let i = items.length - 1; i >= 0; --i) {
|
|
9435
|
+
const item = items[i];
|
|
9436
|
+
const [key, value] = item;
|
|
9437
|
+
if (!this.#cache.has(key)) {
|
|
9438
|
+
const deleted = this.#deleteIfExpired(key, value);
|
|
9439
|
+
if (deleted === false) {
|
|
9440
|
+
yield [key, value.value];
|
|
9441
|
+
}
|
|
9442
|
+
}
|
|
9443
|
+
}
|
|
9444
|
+
}
|
|
9440
9445
|
|
|
9441
|
-
|
|
9442
|
-
|
|
9443
|
-
|
|
9446
|
+
* entriesAscending() {
|
|
9447
|
+
for (const [key, value] of this.#entriesAscending()) {
|
|
9448
|
+
yield [key, value.value];
|
|
9449
|
+
}
|
|
9450
|
+
}
|
|
9444
9451
|
|
|
9445
|
-
|
|
9446
|
-
|
|
9447
|
-
|
|
9448
|
-
|
|
9452
|
+
get size() {
|
|
9453
|
+
if (!this.#size) {
|
|
9454
|
+
return this.#oldCache.size;
|
|
9455
|
+
}
|
|
9449
9456
|
|
|
9450
|
-
|
|
9451
|
-
|
|
9452
|
-
|
|
9457
|
+
let oldCacheSize = 0;
|
|
9458
|
+
for (const key of this.#oldCache.keys()) {
|
|
9459
|
+
if (!this.#cache.has(key)) {
|
|
9460
|
+
oldCacheSize++;
|
|
9461
|
+
}
|
|
9462
|
+
}
|
|
9453
9463
|
|
|
9454
|
-
|
|
9455
|
-
|
|
9456
|
-
// e.g. 5715
|
|
9457
|
-
types['1310'] = types['1220'];
|
|
9458
|
-
/* Hebrew year that starts on Tuesday, is `regular' (Heshvan has 29
|
|
9459
|
-
* days and Kislev has 30 days), and has Passover start on Saturday. */
|
|
9460
|
-
types['1311'] = types['1221'];
|
|
9464
|
+
return Math.min(this.#size + oldCacheSize, this.#maxSize);
|
|
9465
|
+
}
|
|
9461
9466
|
|
|
9462
|
-
|
|
9463
|
-
|
|
9464
|
-
|
|
9465
|
-
const sedraCache = new QuickLRU({
|
|
9466
|
-
maxSize: 400
|
|
9467
|
-
});
|
|
9467
|
+
get maxSize() {
|
|
9468
|
+
return this.#maxSize;
|
|
9469
|
+
}
|
|
9468
9470
|
|
|
9469
|
-
|
|
9470
|
-
|
|
9471
|
-
|
|
9472
|
-
* @param {boolean} il
|
|
9473
|
-
* @return {Sedra}
|
|
9474
|
-
*/
|
|
9475
|
-
function getSedra_(hyear, il) {
|
|
9476
|
-
const cacheKey = `${hyear}-${il ? 1 : 0}`;
|
|
9477
|
-
let sedra = sedraCache.get(cacheKey);
|
|
9478
|
-
if (!sedra) {
|
|
9479
|
-
sedra = new Sedra(hyear, il);
|
|
9480
|
-
sedraCache.set(cacheKey, sedra);
|
|
9481
|
-
}
|
|
9482
|
-
return sedra;
|
|
9483
|
-
}
|
|
9471
|
+
entries() {
|
|
9472
|
+
return this.entriesAscending();
|
|
9473
|
+
}
|
|
9484
9474
|
|
|
9485
|
-
|
|
9486
|
-
|
|
9487
|
-
|
|
9488
|
-
|
|
9489
|
-
|
|
9490
|
-
* @param {HDate} date
|
|
9491
|
-
* @param {string[]} parsha - untranslated name of single or double parsha,
|
|
9492
|
-
* such as ['Bereshit'] or ['Achrei Mot', 'Kedoshim']
|
|
9493
|
-
* @param {boolean} il
|
|
9494
|
-
* @param {number|number[]} num
|
|
9495
|
-
*/
|
|
9496
|
-
constructor(date, parsha, il, num) {
|
|
9497
|
-
if (!Array.isArray(parsha) || parsha.length === 0 || parsha.length > 2) {
|
|
9498
|
-
throw new TypeError('Bad parsha argument');
|
|
9499
|
-
}
|
|
9500
|
-
const desc = 'Parashat ' + parsha.join('-');
|
|
9501
|
-
super(date, desc, flags.PARSHA_HASHAVUA);
|
|
9502
|
-
this.parsha = parsha;
|
|
9503
|
-
this.il = Boolean(il);
|
|
9504
|
-
this.num = num || -1;
|
|
9505
|
-
}
|
|
9506
|
-
/**
|
|
9507
|
-
* @param {string} [locale] Optional locale name (i.e: `'he'`, `'fr'`). Defaults to active locale.
|
|
9508
|
-
* @return {string}
|
|
9509
|
-
*/
|
|
9510
|
-
render(locale) {
|
|
9511
|
-
const locale0 = locale || Locale.getLocaleName();
|
|
9512
|
-
const parsha = this.parsha;
|
|
9513
|
-
let name = Locale.gettext(parsha[0], locale);
|
|
9514
|
-
if (parsha.length == 2) {
|
|
9515
|
-
const hyphen = locale0 == 'he' ? '־' : '-';
|
|
9516
|
-
name += hyphen + Locale.gettext(parsha[1], locale);
|
|
9517
|
-
}
|
|
9518
|
-
name = name.replace(/'/g, '’');
|
|
9519
|
-
const str = Locale.gettext('Parashat', locale) + ' ' + name;
|
|
9520
|
-
return str.normalize();
|
|
9521
|
-
}
|
|
9522
|
-
/** @return {string} */
|
|
9523
|
-
basename() {
|
|
9524
|
-
return this.parsha.join('-');
|
|
9525
|
-
}
|
|
9526
|
-
/** @return {string} */
|
|
9527
|
-
url() {
|
|
9528
|
-
const year = this.getDate().greg().getFullYear();
|
|
9529
|
-
if (year < 100) {
|
|
9530
|
-
return undefined;
|
|
9531
|
-
}
|
|
9532
|
-
const dt = this.urlDateSuffix();
|
|
9533
|
-
const url = 'https://www.hebcal.com/sedrot/' + this.basename().toLowerCase().replace(/'/g, '').replace(/ /g, '-') + '-' + dt;
|
|
9534
|
-
return this.il ? url + '?i=on' : url;
|
|
9535
|
-
}
|
|
9475
|
+
forEach(callbackFunction, thisArgument = this) {
|
|
9476
|
+
for (const [key, value] of this.entriesAscending()) {
|
|
9477
|
+
callbackFunction.call(thisArgument, value, key, this);
|
|
9478
|
+
}
|
|
9479
|
+
}
|
|
9536
9480
|
|
|
9537
|
-
|
|
9538
|
-
|
|
9539
|
-
|
|
9540
|
-
return isoDate.replace(/-/g, '');
|
|
9541
|
-
}
|
|
9481
|
+
get [Symbol.toStringTag]() {
|
|
9482
|
+
return JSON.stringify([...this.entriesAscending()]);
|
|
9483
|
+
}
|
|
9542
9484
|
}
|
|
9543
9485
|
|
|
9544
9486
|
const SUN$1 = 0;
|
|
@@ -9599,6 +9541,26 @@ function dateYomHaZikaron(year) {
|
|
|
9599
9541
|
return new HDate(day, IYYAR, year);
|
|
9600
9542
|
}
|
|
9601
9543
|
|
|
9544
|
+
const sedraCache = new QuickLRU({
|
|
9545
|
+
maxSize: 400
|
|
9546
|
+
});
|
|
9547
|
+
|
|
9548
|
+
/**
|
|
9549
|
+
* @private
|
|
9550
|
+
* @param {number} hyear
|
|
9551
|
+
* @param {boolean} il
|
|
9552
|
+
* @return {Sedra}
|
|
9553
|
+
*/
|
|
9554
|
+
function getSedra_(hyear, il) {
|
|
9555
|
+
const cacheKey = `${hyear}-${il ? 1 : 0}`;
|
|
9556
|
+
let sedra = sedraCache.get(cacheKey);
|
|
9557
|
+
if (!sedra) {
|
|
9558
|
+
sedra = new Sedra(hyear, il);
|
|
9559
|
+
sedraCache.set(cacheKey, sedra);
|
|
9560
|
+
}
|
|
9561
|
+
return sedra;
|
|
9562
|
+
}
|
|
9563
|
+
|
|
9602
9564
|
const Nisan = months.NISAN;
|
|
9603
9565
|
const Iyyar = months.IYYAR;
|
|
9604
9566
|
const Sivan = months.SIVAN;
|
|
@@ -10760,7 +10722,7 @@ class DailyLearning {
|
|
|
10760
10722
|
}
|
|
10761
10723
|
|
|
10762
10724
|
// DO NOT EDIT THIS AUTO-GENERATED FILE!
|
|
10763
|
-
const version = '5.
|
|
10725
|
+
const version = '5.4.0';
|
|
10764
10726
|
|
|
10765
10727
|
const NONE$1 = 0;
|
|
10766
10728
|
const HALF = 1;
|
|
@@ -10802,398 +10764,6 @@ function hallel_(events, hdate) {
|
|
|
10802
10764
|
return NONE$1;
|
|
10803
10765
|
}
|
|
10804
10766
|
|
|
10805
|
-
var poAshkenazi = {
|
|
10806
|
-
"headers": {
|
|
10807
|
-
"plural-forms": "nplurals=2; plural=(n > 1);"
|
|
10808
|
-
},
|
|
10809
|
-
"contexts": {
|
|
10810
|
-
"": {
|
|
10811
|
-
"Shabbat": ["Shabbos"],
|
|
10812
|
-
"Achrei Mot": ["Achrei Mos"],
|
|
10813
|
-
"Bechukotai": ["Bechukosai"],
|
|
10814
|
-
"Beha'alotcha": ["Beha’aloscha"],
|
|
10815
|
-
"Bereshit": ["Bereshis"],
|
|
10816
|
-
"Chukat": ["Chukas"],
|
|
10817
|
-
"Erev Shavuot": ["Erev Shavuos"],
|
|
10818
|
-
"Erev Sukkot": ["Erev Sukkos"],
|
|
10819
|
-
"Ki Tavo": ["Ki Savo"],
|
|
10820
|
-
"Ki Teitzei": ["Ki Seitzei"],
|
|
10821
|
-
"Ki Tisa": ["Ki Sisa"],
|
|
10822
|
-
"Matot": ["Matos"],
|
|
10823
|
-
"Purim Katan": ["Purim Koton"],
|
|
10824
|
-
"Shabbat Chazon": ["Shabbos Chazon"],
|
|
10825
|
-
"Shabbat HaChodesh": ["Shabbos HaChodesh"],
|
|
10826
|
-
"Shabbat HaGadol": ["Shabbos HaGadol"],
|
|
10827
|
-
"Shabbat Nachamu": ["Shabbos Nachamu"],
|
|
10828
|
-
"Shabbat Parah": ["Shabbos Parah"],
|
|
10829
|
-
"Shabbat Shekalim": ["Shabbos Shekalim"],
|
|
10830
|
-
"Shabbat Shuva": ["Shabbos Shuvah"],
|
|
10831
|
-
"Shabbat Zachor": ["Shabbos Zachor"],
|
|
10832
|
-
"Shavuot": ["Shavuos"],
|
|
10833
|
-
"Shavuot I": ["Shavuos I"],
|
|
10834
|
-
"Shavuot II": ["Shavuos II"],
|
|
10835
|
-
"Shemot": ["Shemos"],
|
|
10836
|
-
"Shmini Atzeret": ["Shmini Atzeres"],
|
|
10837
|
-
"Simchat Torah": ["Simchas Torah"],
|
|
10838
|
-
"Sukkot": ["Sukkos"],
|
|
10839
|
-
"Sukkot I": ["Sukkos I"],
|
|
10840
|
-
"Sukkot II": ["Sukkos II"],
|
|
10841
|
-
"Sukkot II (CH''M)": ["Sukkos II (CH’’M)"],
|
|
10842
|
-
"Sukkot III (CH''M)": ["Sukkos III (CH’’M)"],
|
|
10843
|
-
"Sukkot IV (CH''M)": ["Sukkos IV (CH’’M)"],
|
|
10844
|
-
"Sukkot V (CH''M)": ["Sukkos V (CH’’M)"],
|
|
10845
|
-
"Sukkot VI (CH''M)": ["Sukkos VI (CH’’M)"],
|
|
10846
|
-
"Sukkot VII (Hoshana Raba)": ["Sukkos VII (Hoshana Raba)"],
|
|
10847
|
-
"Ta'anit Bechorot": ["Ta’anis Bechoros"],
|
|
10848
|
-
"Ta'anit Esther": ["Ta’anis Esther"],
|
|
10849
|
-
"Toldot": ["Toldos"],
|
|
10850
|
-
"Vaetchanan": ["Vaeschanan"],
|
|
10851
|
-
"Yitro": ["Yisro"],
|
|
10852
|
-
"Vezot Haberakhah": ["Vezos Haberakhah"],
|
|
10853
|
-
"Parashat": ["Parshas"],
|
|
10854
|
-
"Leil Selichot": ["Leil Selichos"],
|
|
10855
|
-
"Shabbat Mevarchim Chodesh": ["Shabbos Mevorchim Chodesh"],
|
|
10856
|
-
"Shabbat Shirah": ["Shabbos Shirah"],
|
|
10857
|
-
"Tevet": ["Teves"],
|
|
10858
|
-
"Asara B'Tevet": ["Asara B’Teves"],
|
|
10859
|
-
"Alot HaShachar": ["Alos HaShachar"],
|
|
10860
|
-
"Kriat Shema, sof zeman": ["Krias Shema, sof zman"],
|
|
10861
|
-
"Tefilah, sof zeman": ["Tefilah, sof zman"],
|
|
10862
|
-
"Kriat Shema, sof zeman (MGA)": ["Krias Shema, sof zman (MGA)"],
|
|
10863
|
-
"Tefilah, sof zeman (MGA)": ["Tefilah, sof zman (MGA)"],
|
|
10864
|
-
"Chatzot HaLailah": ["Chatzos HaLailah"],
|
|
10865
|
-
"Chatzot hayom": ["Chatzos"],
|
|
10866
|
-
"Tzeit HaKochavim": ["Tzeis HaKochavim"],
|
|
10867
|
-
"Birkat Hachamah": ["Birkas Hachamah"],
|
|
10868
|
-
"Shushan Purim Katan": ["Shushan Purim Koton"]
|
|
10869
|
-
}
|
|
10870
|
-
}
|
|
10871
|
-
};
|
|
10872
|
-
|
|
10873
|
-
Locale.addLocale('ashkenazi', poAshkenazi);
|
|
10874
|
-
Locale.addLocale('a', poAshkenazi);
|
|
10875
|
-
|
|
10876
|
-
var poHe = {
|
|
10877
|
-
"headers": {
|
|
10878
|
-
"plural-forms": "nplurals=2; plural=(n > 1);"
|
|
10879
|
-
},
|
|
10880
|
-
"contexts": {
|
|
10881
|
-
"": {
|
|
10882
|
-
"Shabbat": ["שַׁבָּת"],
|
|
10883
|
-
"Daf Yomi": ["דַף יוֹמִי"],
|
|
10884
|
-
"Parashat": ["פָּרָשַׁת"],
|
|
10885
|
-
"Achrei Mot": ["אַחֲרֵי מוֹת"],
|
|
10886
|
-
"Balak": ["בָּלָק"],
|
|
10887
|
-
"Bamidbar": ["בְּמִדְבַּר"],
|
|
10888
|
-
"Bechukotai": ["בְּחֻקֹּתַי"],
|
|
10889
|
-
"Beha'alotcha": ["בְּהַעֲלֹתְךָ"],
|
|
10890
|
-
"Behar": ["בְּהַר"],
|
|
10891
|
-
"Bereshit": ["בְּרֵאשִׁית"],
|
|
10892
|
-
"Beshalach": ["בְּשַׁלַּח"],
|
|
10893
|
-
"Bo": ["בֹּא"],
|
|
10894
|
-
"Chayei Sara": ["חַיֵּי שָֹרָה"],
|
|
10895
|
-
"Chukat": ["חֻקַּת"],
|
|
10896
|
-
"Devarim": ["דְּבָרִים"],
|
|
10897
|
-
"Eikev": ["עֵקֶב"],
|
|
10898
|
-
"Emor": ["אֱמוֹר"],
|
|
10899
|
-
"Ha'azinu": ["הַאֲזִינוּ"],
|
|
10900
|
-
"Kedoshim": ["קְדשִׁים"],
|
|
10901
|
-
"Ki Tavo": ["כִּי־תָבוֹא"],
|
|
10902
|
-
"Ki Teitzei": ["כִּי־תֵצֵא"],
|
|
10903
|
-
"Ki Tisa": ["כִּי תִשָּׂא"],
|
|
10904
|
-
"Korach": ["קוֹרַח"],
|
|
10905
|
-
"Lech-Lecha": ["לֶךְ־לְךָ"],
|
|
10906
|
-
"Masei": ["מַסְעֵי"],
|
|
10907
|
-
"Matot": ["מַּטּוֹת"],
|
|
10908
|
-
"Metzora": ["מְּצֹרָע"],
|
|
10909
|
-
"Miketz": ["מִקֵּץ"],
|
|
10910
|
-
"Mishpatim": ["מִּשְׁפָּטִים"],
|
|
10911
|
-
"Nasso": ["נָשׂא"],
|
|
10912
|
-
"Nitzavim": ["נִצָּבִים"],
|
|
10913
|
-
"Noach": ["נֹחַ"],
|
|
10914
|
-
"Pekudei": ["פְקוּדֵי"],
|
|
10915
|
-
"Pinchas": ["פִּינְחָס"],
|
|
10916
|
-
"Re'eh": ["רְאֵה"],
|
|
10917
|
-
"Sh'lach": ["שְׁלַח־לְךָ"],
|
|
10918
|
-
"Shemot": ["שְׁמוֹת"],
|
|
10919
|
-
"Shmini": ["שְּׁמִינִי"],
|
|
10920
|
-
"Shoftim": ["שׁוֹפְטִים"],
|
|
10921
|
-
"Tazria": ["תַזְרִיעַ"],
|
|
10922
|
-
"Terumah": ["תְּרוּמָה"],
|
|
10923
|
-
"Tetzaveh": ["תְּצַוֶּה"],
|
|
10924
|
-
"Toldot": ["תּוֹלְדוֹת"],
|
|
10925
|
-
"Tzav": ["צַו"],
|
|
10926
|
-
"Vaera": ["וָאֵרָא"],
|
|
10927
|
-
"Vaetchanan": ["וָאֶתְחַנַּן"],
|
|
10928
|
-
"Vayakhel": ["וַיַּקְהֵל"],
|
|
10929
|
-
"Vayechi": ["וַיְחִי"],
|
|
10930
|
-
"Vayeilech": ["וַיֵּלֶךְ"],
|
|
10931
|
-
"Vayera": ["וַיֵּרָא"],
|
|
10932
|
-
"Vayeshev": ["וַיֵּשֶׁב"],
|
|
10933
|
-
"Vayetzei": ["וַיֵּצֵא"],
|
|
10934
|
-
"Vayigash": ["וַיִּגַּשׁ"],
|
|
10935
|
-
"Vayikra": ["וַיִּקְרָא"],
|
|
10936
|
-
"Vayishlach": ["וַיִּשְׁלַח"],
|
|
10937
|
-
"Vezot Haberakhah": ["וְזֹאת הַבְּרָכָה"],
|
|
10938
|
-
"Yitro": ["יִתְרוֹ"],
|
|
10939
|
-
"Asara B'Tevet": ["עֲשָׂרָה בְּטֵבֵת"],
|
|
10940
|
-
"Candle lighting": ["הַדְלָקַת נֵרוֹת"],
|
|
10941
|
-
"Chanukah": ["חֲנוּכָּה"],
|
|
10942
|
-
"Chanukah: 1 Candle": ["חֲנוּכָּה: א׳ נֵר"],
|
|
10943
|
-
"Chanukah: 2 Candles": ["חֲנוּכָּה: ב׳ נֵרוֹת"],
|
|
10944
|
-
"Chanukah: 3 Candles": ["חֲנוּכָּה: ג׳ נֵרוֹת"],
|
|
10945
|
-
"Chanukah: 4 Candles": ["חֲנוּכָּה: ד׳ נֵרוֹת"],
|
|
10946
|
-
"Chanukah: 5 Candles": ["חֲנוּכָּה: ה׳ נֵרוֹת"],
|
|
10947
|
-
"Chanukah: 6 Candles": ["חֲנוּכָּה: ו׳ נֵרוֹת"],
|
|
10948
|
-
"Chanukah: 7 Candles": ["חֲנוּכָּה: ז׳ נֵרוֹת"],
|
|
10949
|
-
"Chanukah: 8 Candles": ["חֲנוּכָּה: ח׳ נֵרוֹת"],
|
|
10950
|
-
"Chanukah: 8th Day": ["חֲנוּכָּה: יוֹם ח׳"],
|
|
10951
|
-
"Days of the Omer": ["סְפִירַת הָעוֹמֶר"],
|
|
10952
|
-
"Omer": ["עוֹמֶר"],
|
|
10953
|
-
"day of the Omer": ["בָּעוֹמֶר"],
|
|
10954
|
-
"Erev Pesach": ["עֶרֶב פֶּסַח"],
|
|
10955
|
-
"Erev Purim": ["עֶרֶב פּוּרִים"],
|
|
10956
|
-
"Erev Rosh Hashana": ["עֶרֶב רֹאשׁ הַשָּׁנָה"],
|
|
10957
|
-
"Erev Shavuot": ["עֶרֶב שָׁבוּעוֹת"],
|
|
10958
|
-
"Erev Simchat Torah": ["עֶרֶב שִׂמְחַת תּוֹרָה"],
|
|
10959
|
-
"Erev Sukkot": ["עֶרֶב סוּכּוֹת"],
|
|
10960
|
-
"Erev Tish'a B'Av": ["עֶרֶב תִּשְׁעָה בְּאָב"],
|
|
10961
|
-
"Erev Yom Kippur": ["עֶרֶב יוֹם כִּפּוּר"],
|
|
10962
|
-
"Havdalah": ["הַבְדָּלָה"],
|
|
10963
|
-
"Lag BaOmer": ["ל״ג בָּעוֹמֶר"],
|
|
10964
|
-
"Leil Selichot": ["סליחות"],
|
|
10965
|
-
"Pesach": ["פֶּסַח"],
|
|
10966
|
-
"Pesach I": ["פֶּסַח א׳"],
|
|
10967
|
-
"Pesach II": ["פֶּסַח ב׳"],
|
|
10968
|
-
"Pesach II (CH''M)": ["פֶּסַח ב׳ (חוה״מ)"],
|
|
10969
|
-
"Pesach III (CH''M)": ["פֶּסַח ג׳ (חוה״מ)"],
|
|
10970
|
-
"Pesach IV (CH''M)": ["פֶּסַח ד׳ (חוה״מ)"],
|
|
10971
|
-
"Pesach Sheni": ["פֶּסַח שני"],
|
|
10972
|
-
"Pesach V (CH''M)": ["פֶּסַח ה׳ (חוה״מ)"],
|
|
10973
|
-
"Pesach VI (CH''M)": ["פֶּסַח ו׳ (חוה״מ)"],
|
|
10974
|
-
"Pesach VII": ["פֶּסַח ז׳"],
|
|
10975
|
-
"Pesach VIII": ["פֶּסַח ח׳"],
|
|
10976
|
-
"Purim": ["פּוּרִים"],
|
|
10977
|
-
"Purim Katan": ["פּוּרִים קָטָן"],
|
|
10978
|
-
"Rosh Chodesh %s": ["רֹאשׁ חוֹדֶשׁ %s"],
|
|
10979
|
-
"Rosh Chodesh": ["רֹאשׁ חוֹדֶשׁ"],
|
|
10980
|
-
"Adar": ["אַדָר"],
|
|
10981
|
-
"Adar I": ["אַדָר א׳"],
|
|
10982
|
-
"Adar II": ["אַדָר ב׳"],
|
|
10983
|
-
"Av": ["אָב"],
|
|
10984
|
-
"Cheshvan": ["חֶשְׁוָן"],
|
|
10985
|
-
"Elul": ["אֱלוּל"],
|
|
10986
|
-
"Iyyar": ["אִיָיר"],
|
|
10987
|
-
"Kislev": ["כִּסְלֵו"],
|
|
10988
|
-
"Nisan": ["נִיסָן"],
|
|
10989
|
-
"Sh'vat": ["שְׁבָט"],
|
|
10990
|
-
"Sivan": ["סִיוָן"],
|
|
10991
|
-
"Tamuz": ["תַּמּוּז"],
|
|
10992
|
-
"Tevet": ["טֵבֵת"],
|
|
10993
|
-
"Tishrei": ["תִּשְׁרֵי"],
|
|
10994
|
-
"Rosh Hashana": ["רֹאשׁ הַשָּׁנָה"],
|
|
10995
|
-
"Rosh Hashana I": ["רֹאשׁ הַשָּׁנָה א׳"],
|
|
10996
|
-
"Rosh Hashana II": ["רֹאשׁ הַשָּׁנָה ב׳"],
|
|
10997
|
-
"Shabbat Chazon": ["שַׁבָּת חֲזוֹן"],
|
|
10998
|
-
"Shabbat HaChodesh": ["שַׁבָּת הַחֹדֶשׁ"],
|
|
10999
|
-
"Shabbat HaGadol": ["שַׁבָּת הַגָּדוֹל"],
|
|
11000
|
-
"Shabbat Machar Chodesh": ["שַׁבָּת מָחָר חוֹדֶשׁ"],
|
|
11001
|
-
"Shabbat Nachamu": ["שַׁבָּת נַחֲמוּ"],
|
|
11002
|
-
"Shabbat Parah": ["שַׁבָּת פּרה"],
|
|
11003
|
-
"Shabbat Rosh Chodesh": ["שַׁבָּת רֹאשׁ חוֹדֶשׁ"],
|
|
11004
|
-
"Shabbat Shekalim": ["שַׁבָּת שְׁקָלִים"],
|
|
11005
|
-
"Shabbat Shuva": ["שַׁבָּת שׁוּבָה"],
|
|
11006
|
-
"Shabbat Zachor": ["שַׁבָּת זָכוֹר"],
|
|
11007
|
-
"Shavuot": ["שָׁבוּעוֹת"],
|
|
11008
|
-
"Shavuot I": ["שָׁבוּעוֹת א׳"],
|
|
11009
|
-
"Shavuot II": ["שָׁבוּעוֹת ב׳"],
|
|
11010
|
-
"Shmini Atzeret": ["שְׁמִינִי עֲצֶרֶת"],
|
|
11011
|
-
"Shushan Purim": ["שׁוּשָׁן פּוּרִים"],
|
|
11012
|
-
"Sigd": ["סיגד"],
|
|
11013
|
-
"Simchat Torah": ["שִׂמְחַת תּוֹרָה"],
|
|
11014
|
-
"Sukkot": ["סוּכּוֹת"],
|
|
11015
|
-
"Sukkot I": ["סוּכּוֹת א׳"],
|
|
11016
|
-
"Sukkot II": ["סוּכּוֹת ב׳"],
|
|
11017
|
-
"Sukkot II (CH''M)": ["סוּכּוֹת ב׳ (חוה״מ)"],
|
|
11018
|
-
"Sukkot III (CH''M)": ["סוּכּוֹת ג׳ (חוה״מ)"],
|
|
11019
|
-
"Sukkot IV (CH''M)": ["סוּכּוֹת ד׳ (חוה״מ)"],
|
|
11020
|
-
"Sukkot V (CH''M)": ["סוּכּוֹת ה׳ (חוה״מ)"],
|
|
11021
|
-
"Sukkot VI (CH''M)": ["סוּכּוֹת ו׳ (חוה״מ)"],
|
|
11022
|
-
"Sukkot VII (Hoshana Raba)": ["סוּכּוֹת ז׳ (הוֹשַׁעְנָא רַבָּה)"],
|
|
11023
|
-
"Ta'anit Bechorot": ["תַּעֲנִית בְּכוֹרוֹת"],
|
|
11024
|
-
"Ta'anit Esther": ["תַּעֲנִית אֶסְתֵּר"],
|
|
11025
|
-
"Tish'a B'Av": ["תִּשְׁעָה בְּאָב"],
|
|
11026
|
-
"Tu B'Av": ["טוּ בְּאָב"],
|
|
11027
|
-
"Tu BiShvat": ["טוּ בִּשְׁבָט"],
|
|
11028
|
-
"Tu B'Shvat": ["טוּ בִּשְׁבָט"],
|
|
11029
|
-
"Tzom Gedaliah": ["צוֹם גְּדַלְיָה"],
|
|
11030
|
-
"Tzom Tammuz": ["צוֹם תָּמוּז"],
|
|
11031
|
-
"Yom HaAtzma'ut": ["יוֹם הָעַצְמָאוּת"],
|
|
11032
|
-
"Yom HaShoah": ["יוֹם הַשּׁוֹאָה"],
|
|
11033
|
-
"Yom HaZikaron": ["יוֹם הַזִּכָּרוֹן"],
|
|
11034
|
-
"Yom Kippur": ["יוֹם כִּפּוּר"],
|
|
11035
|
-
"Yom Yerushalayim": ["יוֹם יְרוּשָׁלַיִם"],
|
|
11036
|
-
"Yom HaAliyah": ["יוֹם הַעֲלִיָּה"],
|
|
11037
|
-
"Yom HaAliyah School Observance": ["שְׁמִירָת בֵּית הַסֵפֶר לְיוֹם הַעֲלִיָּה"],
|
|
11038
|
-
"Pesach I (on Shabbat)": ["פֶּסַח יוֹם א׳ (בְּשַׁבָּת)"],
|
|
11039
|
-
"Pesach Chol ha-Moed Day 1": ["פֶּסַח חוֹל הַמּוֹעֵד יוֹם א׳"],
|
|
11040
|
-
"Pesach Chol ha-Moed Day 2": ["פֶּסַח חוֹל הַמּוֹעֵד יוֹם ב׳"],
|
|
11041
|
-
"Pesach Chol ha-Moed Day 3": ["פֶּסַח חוֹל הַמּוֹעֵד יוֹם ג׳"],
|
|
11042
|
-
"Pesach Chol ha-Moed Day 4": ["פֶּסַח חוֹל הַמּוֹעֵד יוֹם ד׳"],
|
|
11043
|
-
"Pesach Chol ha-Moed Day 5": ["פֶּסַח חוֹל הַמּוֹעֵד יוֹם ה׳"],
|
|
11044
|
-
"Pesach Shabbat Chol ha-Moed": ["פֶּסַח שַׁבָּת חוֹל הַמּוֹעֵד"],
|
|
11045
|
-
"Shavuot II (on Shabbat)": ["שָׁבוּעוֹת יוֹם ב׳ (בְּשַׁבָּת)"],
|
|
11046
|
-
"Rosh Hashana I (on Shabbat)": ["רֹאשׁ הַשָּׁנָה יוֹם א׳ (בְּשַׁבָּת)"],
|
|
11047
|
-
"Yom Kippur (on Shabbat)": ["יוֹם כִּפּוּר (בְּשַׁבָּת)"],
|
|
11048
|
-
"Yom Kippur (Mincha, Traditional)": ["יוֹם כִּפּוּר מִנחָה"],
|
|
11049
|
-
"Yom Kippur (Mincha, Alternate)": ["יוֹם כִּפּוּר מִנחָה"],
|
|
11050
|
-
"Sukkot I (on Shabbat)": ["סוּכּוֹת יוֹם א׳ (בְּשַׁבָּת)"],
|
|
11051
|
-
"Sukkot Chol ha-Moed Day 1": ["סוּכּוֹת חוֹל הַמּוֹעֵד יוֹם א׳"],
|
|
11052
|
-
"Sukkot Chol ha-Moed Day 2": ["סוּכּוֹת חוֹל הַמּוֹעֵד יוֹם ב׳"],
|
|
11053
|
-
"Sukkot Chol ha-Moed Day 3": ["סוּכּוֹת חוֹל הַמּוֹעֵד יוֹם ג׳"],
|
|
11054
|
-
"Sukkot Chol ha-Moed Day 4": ["סוּכּוֹת חוֹל הַמּוֹעֵד יוֹם ד׳"],
|
|
11055
|
-
"Sukkot Chol ha-Moed Day 5": ["סוּכּוֹת חוֹל הַמּוֹעֵד יוֹם ה׳"],
|
|
11056
|
-
"Sukkot Shabbat Chol ha-Moed": ["סוּכּוֹת שַׁבָּת חוֹל הַמּוֹעֵד"],
|
|
11057
|
-
"Sukkot Final Day (Hoshana Raba)": ["סוּכּוֹת ז׳ (הוֹשַׁעְנָא רַבָּה)"],
|
|
11058
|
-
"Rosh Chodesh Adar": ["רֹאשׁ חוֹדֶשׁ אַדָר"],
|
|
11059
|
-
"Rosh Chodesh Adar I": ["רֹאשׁ חוֹדֶשׁ אַדָר א׳"],
|
|
11060
|
-
"Rosh Chodesh Adar II": ["רֹאשׁ חוֹדֶשׁ אַדָר ב׳"],
|
|
11061
|
-
"Rosh Chodesh Av": ["רֹאשׁ חוֹדֶשׁ אָב"],
|
|
11062
|
-
"Rosh Chodesh Cheshvan": ["רֹאשׁ חוֹדֶשׁ חֶשְׁוָן"],
|
|
11063
|
-
"Rosh Chodesh Elul": ["רֹאשׁ חוֹדֶשׁ אֱלוּל"],
|
|
11064
|
-
"Rosh Chodesh Iyyar": ["רֹאשׁ חוֹדֶשׁ אִיָיר"],
|
|
11065
|
-
"Rosh Chodesh Kislev": ["רֹאשׁ חוֹדֶשׁ כִּסְלֵו"],
|
|
11066
|
-
"Rosh Chodesh Nisan": ["רֹאשׁ חוֹדֶשׁ נִיסָן"],
|
|
11067
|
-
"Rosh Chodesh Sh'vat": ["רֹאשׁ חוֹדֶשׁ שְׁבָט"],
|
|
11068
|
-
"Rosh Chodesh Sivan": ["רֹאשׁ חוֹדֶשׁ סִיוָן"],
|
|
11069
|
-
"Rosh Chodesh Tamuz": ["רֹאשׁ חוֹדֶשׁ תָּמוּז"],
|
|
11070
|
-
"Rosh Chodesh Tevet": ["רֹאשׁ חוֹדֶשׁ טֵבֵת"],
|
|
11071
|
-
"min": ["דַּקּוֹת"],
|
|
11072
|
-
"Fast begins": ["תחילת הַצוֹם"],
|
|
11073
|
-
"Fast ends": ["סִיּוּם הַצוֹם"],
|
|
11074
|
-
"Rosh Hashana LaBehemot": ["רֹאשׁ הַשָּׁנָה לְמַעְשַׂר בְּהֵמָה"],
|
|
11075
|
-
"Tish'a B'Av (observed)": ["תִּשְׁעָה בְּאָב נִדחֶה"],
|
|
11076
|
-
"Shabbat Mevarchim Chodesh": ["שַׁבָּת מְבָרְכִים חוֹדֶשׁ"],
|
|
11077
|
-
"Shabbat Shirah": ["שַׁבָּת שִׁירָה"],
|
|
11078
|
-
"Chatzot HaLailah": ["חֲצוֹת הַלַיְלָה"],
|
|
11079
|
-
"Alot haShachar": ["עֲלוֹת הַשַּׁחַר"],
|
|
11080
|
-
"Misheyakir": ["מִשֶּׁיַּכִּיר"],
|
|
11081
|
-
"Misheyakir Machmir": ["מִשֶּׁיַּכִּיר מַחמִיר"],
|
|
11082
|
-
"Dawn": ["דִּימְדּוּמֵי בּוֹקֵר"],
|
|
11083
|
-
"Sunrise": ["הַנֵץ הַחַמָּה"],
|
|
11084
|
-
"Kriat Shema, sof zeman": ["סוֹף זְמַן קְרִיאַת שְׁמַע גר״א"],
|
|
11085
|
-
"Tefilah, sof zeman": ["סוֹף זְמַן תְּפִלָּה גר״א"],
|
|
11086
|
-
"Kriat Shema, sof zeman (MGA)": ["סוֹף זְמַן קְרִיאַת שְׁמַע מג״א"],
|
|
11087
|
-
"Tefilah, sof zeman (MGA)": ["סוֹף זְמַן תְּפִלָּה מג״א"],
|
|
11088
|
-
"Chatzot hayom": ["חֲצוֹת הַיּוֹם"],
|
|
11089
|
-
"Mincha Gedolah": ["מִנְחָה גְּדוֹלָה"],
|
|
11090
|
-
"Mincha Ketanah": ["מִנְחָה קְטַנָּה"],
|
|
11091
|
-
"Plag HaMincha": ["פְּלַג הַמִּנְחָה"],
|
|
11092
|
-
"Dusk": ["דִּימְדּוּמֵי עֶרֶב"],
|
|
11093
|
-
"Sunset": ["שְׁקִיעָה"],
|
|
11094
|
-
"Nightfall - End of ordained fasts": ["לַיְלָה - גמר תעניות דרבנן"],
|
|
11095
|
-
"Tzeit HaKochavim": ["צֵאת הַכּוֹכָבִים"],
|
|
11096
|
-
"Lovingkindness": ["חֶֽסֶד"],
|
|
11097
|
-
"Might": ["גְבוּרָה"],
|
|
11098
|
-
"Beauty": ["תִּפאֶרֶת"],
|
|
11099
|
-
"Eternity": ["נֶּֽצַח"],
|
|
11100
|
-
"Splendor": ["הוֹד"],
|
|
11101
|
-
"Foundation": ["יְּסוֹד"],
|
|
11102
|
-
"Majesty": ["מַּלְכוּת"],
|
|
11103
|
-
"day": ["יוֹם"],
|
|
11104
|
-
"Chanukah Day 1": ["חֲנוּכָּה יוֹם א׳"],
|
|
11105
|
-
"Chanukah Day 2": ["חֲנוּכָּה יוֹם ב׳"],
|
|
11106
|
-
"Chanukah Day 3": ["חֲנוּכָּה יוֹם ג׳"],
|
|
11107
|
-
"Chanukah Day 4": ["חֲנוּכָּה יוֹם ד׳"],
|
|
11108
|
-
"Chanukah Day 5": ["חֲנוּכָּה יוֹם ה׳"],
|
|
11109
|
-
"Chanukah Day 6": ["חֲנוּכָּה יוֹם ו׳"],
|
|
11110
|
-
"Chanukah Day 7": ["חֲנוּכָּה יוֹם ז׳"],
|
|
11111
|
-
"Chanukah Day 7 (on Rosh Chodesh)": ["חֲנוּכָּה יוֹם ז׳ (רֹאשׁ חוֹדֶשׁ)"],
|
|
11112
|
-
"Chanukah Day 8": ["חֲנוּכָּה יוֹם ח׳"],
|
|
11113
|
-
"Chanukah Day 1 (on Shabbat)": ["חֲנוּכָּה יוֹם א׳ (בְּשַׁבָּת)"],
|
|
11114
|
-
"Chanukah Day 2 (on Shabbat)": ["חֲנוּכָּה יוֹם ב׳ (בְּשַׁבָּת)"],
|
|
11115
|
-
"Chanukah Day 3 (on Shabbat)": ["חֲנוּכָּה יוֹם ג׳ (בְּשַׁבָּת)"],
|
|
11116
|
-
"Chanukah Day 4 (on Shabbat)": ["חֲנוּכָּה יוֹם ד׳ (בְּשַׁבָּת)"],
|
|
11117
|
-
"Chanukah Day 5 (on Shabbat)": ["חֲנוּכָּה יוֹם ה׳ (בְּשַׁבָּת)"],
|
|
11118
|
-
"Chanukah Day 7 (on Shabbat)": ["חֲנוּכָּה יוֹם ז׳ (בְּשַׁבָּת)"],
|
|
11119
|
-
"Chanukah Day 8 (on Shabbat)": ["חֲנוּכָּה יוֹם ח׳ (בְּשַׁבָּת)"],
|
|
11120
|
-
"Shabbat Rosh Chodesh Chanukah": ["שַׁבָּת רֹאשׁ חוֹדֶשׁ חֲנוּכָּה"],
|
|
11121
|
-
"Yom Kippur Katan": ["יוֹם כִּפּוּר קָטָן"],
|
|
11122
|
-
"Family Day": ["יוֹם הַמִּשׁפָּחָה"],
|
|
11123
|
-
"Yitzhak Rabin Memorial Day": ["יוֹם הַזִּכָּרוֹן ליצחק רבין"],
|
|
11124
|
-
"Jabotinsky Day": ["יוֹם ז׳בוטינסקי"],
|
|
11125
|
-
"Herzl Day": ["יוֹם הרצל"],
|
|
11126
|
-
"Ben-Gurion Day": ["יוֹם בן־גוריון"],
|
|
11127
|
-
"Hebrew Language Day": ["יוֹם הַשָׂפָה הַעִברִית"],
|
|
11128
|
-
"Birkat Hachamah": ["בִרְכַּת הַחַמָּה"],
|
|
11129
|
-
"Shushan Purim Katan": ["שׁוּשָׁן פּוּרִים קָטָן"],
|
|
11130
|
-
"Purim Meshulash": ["פּוּרִים מְשׁוּלָּשׁ"],
|
|
11131
|
-
"after sunset": ["לְאַחַר הַשְׁקִיעָה"],
|
|
11132
|
-
"Yerushalmi": ["יְרוּשַׁלְמִי"],
|
|
11133
|
-
"Chag HaBanot": ["חַג הַבָּנוֹת"],
|
|
11134
|
-
"Joshua": ["יְהוֹשׁוּעַ"],
|
|
11135
|
-
"Judges": ["שׁוֹפְטִים"],
|
|
11136
|
-
"I Samuel": ["שְׁמוּאֵל רִאשׁוֹן"],
|
|
11137
|
-
"II Samuel": ["שְׁמוּאֵל שֵׁנִי"],
|
|
11138
|
-
"I Kings": ["מְלָכִים רִאשׁוֹן"],
|
|
11139
|
-
"II Kings": ["מְלָכִים שֵׁנִי"],
|
|
11140
|
-
"Isaiah": ["יְשַׁעְיָהוּ"],
|
|
11141
|
-
"Jeremiah": ["יִרְמְיָהוּ"],
|
|
11142
|
-
"Ezekiel": ["יְחֶזְקֵאל"],
|
|
11143
|
-
"Hosea": ["הוֹשֵׁעַ"],
|
|
11144
|
-
"Joel": ["יוֹאֵל"],
|
|
11145
|
-
"Amos": ["עָמוּס"],
|
|
11146
|
-
"Obadiah": ["עוֹבַדְיָה"],
|
|
11147
|
-
"Jonah": ["יוֹנָה"],
|
|
11148
|
-
"Micah": ["מִיכָה"],
|
|
11149
|
-
"Nachum": ["נַחוּם"],
|
|
11150
|
-
"Habakkuk": ["חֲבַקּוּק"],
|
|
11151
|
-
"Zephaniah": ["צְפַנְיָה"],
|
|
11152
|
-
"Haggai": ["חַגַּי"],
|
|
11153
|
-
"Zechariah": ["זְכַרְיָה"],
|
|
11154
|
-
"Malachi": ["מַלְאָכִי"],
|
|
11155
|
-
"Psalms": ["תְּהִלִּים"],
|
|
11156
|
-
"Proverbs": ["מִשְׁלֵי"],
|
|
11157
|
-
"Job": ["אִיּוֹב"],
|
|
11158
|
-
"Song of Songs": ["שִׁיר הַשִּׁירִים"],
|
|
11159
|
-
"Ruth": ["רוּת"],
|
|
11160
|
-
"Lamentations": ["אֵיכָה"],
|
|
11161
|
-
"Ecclesiastes": ["קֹהֶלֶת"],
|
|
11162
|
-
"Esther": ["אֶסְתֵּר"],
|
|
11163
|
-
"Daniel": ["דָּנִיֵּאל"],
|
|
11164
|
-
"Ezra": ["עֶזְרָא"],
|
|
11165
|
-
"Nehemiah": ["נְחֶמְיָה"],
|
|
11166
|
-
"I Chronicles": ["דִברֵי הַיָמִים רִאשׁוֹן"],
|
|
11167
|
-
"II Chronicles": ["דִברֵי הַיָמִים שֵׁנִי"],
|
|
11168
|
-
"Yom Kippur (Mincha)": ["יוֹם כִּפּוּר מִנחָה"],
|
|
11169
|
-
"Tish'a B'Av (Mincha)": ["תִּשְׁעָה בְּאָב מִנחָה"],
|
|
11170
|
-
"Asara B'Tevet (Mincha)": ["עֲשָׂרָה בְּטֵבֵת מִנחָה"],
|
|
11171
|
-
"Ta'anit Bechorot (Mincha)": ["תַּעֲנִית בְּכוֹרוֹת מִנחָה"],
|
|
11172
|
-
"Ta'anit Esther (Mincha)": ["תַּעֲנִית אֶסְתֵּר מִנחָה"],
|
|
11173
|
-
"Tzom Gedaliah (Mincha)": ["צוֹם גְּדַלְיָה מִנחָה"],
|
|
11174
|
-
"Tzom Tammuz (Mincha)": ["צוֹם תָּמוּז מִנחָה"],
|
|
11175
|
-
"Molad": ["מוֹלָד הָלְּבָנָה"],
|
|
11176
|
-
"chalakim": ["חֲלָקִים"],
|
|
11177
|
-
"Pirkei Avot": ["פִּרְקֵי אָבוֹת"]
|
|
11178
|
-
}
|
|
11179
|
-
}
|
|
11180
|
-
};
|
|
11181
|
-
|
|
11182
|
-
Locale.addLocale('he', poHe);
|
|
11183
|
-
Locale.addLocale('h', poHe);
|
|
11184
|
-
const heStrs = poHe.contexts[''];
|
|
11185
|
-
const heNoNikud = {};
|
|
11186
|
-
for (const [key, val] of Object.entries(heStrs)) {
|
|
11187
|
-
heNoNikud[key] = [Locale.hebrewStripNikkud(val[0])];
|
|
11188
|
-
}
|
|
11189
|
-
const poHeNoNikud = {
|
|
11190
|
-
headers: poHe.headers,
|
|
11191
|
-
contexts: {
|
|
11192
|
-
'': heNoNikud
|
|
11193
|
-
}
|
|
11194
|
-
};
|
|
11195
|
-
Locale.addLocale('he-x-NoNikud', poHeNoNikud);
|
|
11196
|
-
|
|
11197
10767
|
/**
|
|
11198
10768
|
* @private
|
|
11199
10769
|
* @param {number} start
|
|
@@ -12141,6 +11711,25 @@ class HebrewCalendar {
|
|
|
12141
11711
|
return filtered;
|
|
12142
11712
|
}
|
|
12143
11713
|
|
|
11714
|
+
/**
|
|
11715
|
+
* Eruv Tavshilin
|
|
11716
|
+
* @param {Date | HDate} date
|
|
11717
|
+
* @param {boolean} il
|
|
11718
|
+
* @return {boolean}
|
|
11719
|
+
*/
|
|
11720
|
+
static eruvTavshilin(date, il) {
|
|
11721
|
+
if (date.getDay() < 3 || date.getDay() > 4) {
|
|
11722
|
+
return false;
|
|
11723
|
+
}
|
|
11724
|
+
const today = new HDate(date);
|
|
11725
|
+
const friday = today.after(5);
|
|
11726
|
+
const tomorrow = today.next();
|
|
11727
|
+
if (!isChag(friday, il) || isChag(today, il) || !isChag(tomorrow, il)) {
|
|
11728
|
+
return false;
|
|
11729
|
+
}
|
|
11730
|
+
return true;
|
|
11731
|
+
}
|
|
11732
|
+
|
|
12144
11733
|
/**
|
|
12145
11734
|
* Helper function to format a 23-hour (00:00-23:59) time in US format ("8:13pm") or
|
|
12146
11735
|
* keep as "20:13" for any other locale/country. Uses {@link CalOptions} to determine
|
|
@@ -12220,6 +11809,18 @@ class HebrewCalendar {
|
|
|
12220
11809
|
}
|
|
12221
11810
|
}
|
|
12222
11811
|
|
|
11812
|
+
/**
|
|
11813
|
+
* @private
|
|
11814
|
+
* @param {HDate} date
|
|
11815
|
+
* @param {boolean} il
|
|
11816
|
+
* @return {boolean}
|
|
11817
|
+
*/
|
|
11818
|
+
function isChag(date, il) {
|
|
11819
|
+
const events = HebrewCalendar.getHolidaysOnDate(date, il);
|
|
11820
|
+
const chag = events.filter(ev => ev.getFlags() & flags.CHAG);
|
|
11821
|
+
return chag.length !== 0;
|
|
11822
|
+
}
|
|
11823
|
+
|
|
12223
11824
|
/**
|
|
12224
11825
|
* Appends the Event `ev` to the `events` array. Also may add related
|
|
12225
11826
|
* timed events like candle-lighting or fast start/end
|