@hebcal/core 3.33.3 → 3.33.4
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 +415 -415
- package/dist/bundle.js +534 -489
- package/dist/bundle.min.js +2 -2
- package/dist/hdate-bundle.js +119 -24
- package/dist/hdate-bundle.min.js +2 -2
- package/dist/hdate.js +119 -24
- package/dist/hdate.mjs +118 -25
- package/dist/index.js +202 -148
- package/dist/index.mjs +202 -148
- package/package.json +8 -8
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! @hebcal/core v3.33.
|
|
1
|
+
/*! @hebcal/core v3.33.4 */
|
|
2
2
|
'use strict';
|
|
3
3
|
|
|
4
4
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
@@ -553,7 +553,7 @@ Locale.useLocale('en');
|
|
|
553
553
|
You should have received a copy of the GNU General Public License
|
|
554
554
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
555
555
|
*/
|
|
556
|
-
const NISAN$
|
|
556
|
+
const NISAN$3 = 1;
|
|
557
557
|
const IYYAR$1 = 2;
|
|
558
558
|
const SIVAN$2 = 3;
|
|
559
559
|
const TAMUZ$1 = 4;
|
|
@@ -907,7 +907,7 @@ class HDate {
|
|
|
907
907
|
tempabs += HDate.daysInMonth(m, year);
|
|
908
908
|
}
|
|
909
909
|
|
|
910
|
-
for (let m = NISAN$
|
|
910
|
+
for (let m = NISAN$3; m < month; m++) {
|
|
911
911
|
tempabs += HDate.daysInMonth(m, year);
|
|
912
912
|
}
|
|
913
913
|
} else {
|
|
@@ -1053,7 +1053,7 @@ class HDate {
|
|
|
1053
1053
|
* @example
|
|
1054
1054
|
* import {HDate, months} from '@hebcal/core';
|
|
1055
1055
|
* const hd = new HDate(15, months.CHESHVAN, 5769);
|
|
1056
|
-
* console.log(
|
|
1056
|
+
* console.log(hd.renderGematriya()); // 'ט״ו חֶשְׁוָן תשס״ט'
|
|
1057
1057
|
* @return {string}
|
|
1058
1058
|
*/
|
|
1059
1059
|
|
|
@@ -1453,7 +1453,7 @@ class HDate {
|
|
|
1453
1453
|
/* this catches "november" */
|
|
1454
1454
|
}
|
|
1455
1455
|
|
|
1456
|
-
return NISAN$
|
|
1456
|
+
return NISAN$3;
|
|
1457
1457
|
|
|
1458
1458
|
case 'i':
|
|
1459
1459
|
return IYYAR$1;
|
|
@@ -4390,7 +4390,7 @@ const TUE = 2; // const WED = 3;
|
|
|
4390
4390
|
const THU = 4;
|
|
4391
4391
|
const FRI$1 = 5;
|
|
4392
4392
|
const SAT$1 = 6;
|
|
4393
|
-
const NISAN$
|
|
4393
|
+
const NISAN$2 = months.NISAN;
|
|
4394
4394
|
const IYYAR = months.IYYAR;
|
|
4395
4395
|
const SIVAN$1 = months.SIVAN;
|
|
4396
4396
|
const TAMUZ = months.TAMUZ;
|
|
@@ -4467,7 +4467,7 @@ const sedraCache = new SimpleMap();
|
|
|
4467
4467
|
* @return {Sedra}
|
|
4468
4468
|
*/
|
|
4469
4469
|
|
|
4470
|
-
function
|
|
4470
|
+
function getSedra_(hyear, il) {
|
|
4471
4471
|
const cacheKey = `${hyear}-${il ? 1 : 0}`;
|
|
4472
4472
|
let sedra = sedraCache.get(cacheKey);
|
|
4473
4473
|
|
|
@@ -4492,7 +4492,7 @@ const yearCache = Object.create(null);
|
|
|
4492
4492
|
* @return {Map<string,Event[]>}
|
|
4493
4493
|
*/
|
|
4494
4494
|
|
|
4495
|
-
function
|
|
4495
|
+
function getHolidaysForYear_(year) {
|
|
4496
4496
|
if (typeof year !== 'number') {
|
|
4497
4497
|
throw new TypeError(`bad Hebrew year: ${year}`);
|
|
4498
4498
|
} else if (year < 1 || year > 32658) {
|
|
@@ -4506,7 +4506,7 @@ function getHolidaysForYear(year) {
|
|
|
4506
4506
|
}
|
|
4507
4507
|
|
|
4508
4508
|
const RH = new HDate(1, TISHREI$1, year);
|
|
4509
|
-
const pesach = new HDate(15, NISAN$
|
|
4509
|
+
const pesach = new HDate(15, NISAN$2, year);
|
|
4510
4510
|
const h = new SimpleMap(); // eslint-disable-next-line require-jsdoc
|
|
4511
4511
|
|
|
4512
4512
|
function add(...events) {
|
|
@@ -4598,27 +4598,27 @@ function getHolidaysForYear(year) {
|
|
|
4598
4598
|
add(new HolidayEvent(new HDate(pesachAbs - (pesach.getDay() == SUN ? 28 : 29)), 'Shushan Purim', MINOR_HOLIDAY$1, {
|
|
4599
4599
|
emoji: '🎭️📜'
|
|
4600
4600
|
}), new HolidayEvent(new HDate(HDate.dayOnOrBefore(SAT$1, pesachAbs - 14) - 7), 'Shabbat Parah', SPECIAL_SHABBAT$1), new HolidayEvent(new HDate(HDate.dayOnOrBefore(SAT$1, pesachAbs - 14)), 'Shabbat HaChodesh', SPECIAL_SHABBAT$1), new HolidayEvent(new HDate(HDate.dayOnOrBefore(SAT$1, pesachAbs - 1)), 'Shabbat HaGadol', SPECIAL_SHABBAT$1), new HolidayEvent( // if the fast falls on Shabbat, move to Thursday
|
|
4601
|
-
pesach.prev().getDay() == SAT$1 ? pesach.onOrBefore(THU) : new HDate(14, NISAN$
|
|
4602
|
-
addEvents(year, [[14, NISAN$
|
|
4603
|
-
[15, NISAN$
|
|
4601
|
+
pesach.prev().getDay() == SAT$1 ? pesach.onOrBefore(THU) : new HDate(14, NISAN$2, year), 'Ta\'anit Bechorot', MINOR_FAST$1));
|
|
4602
|
+
addEvents(year, [[14, NISAN$2, 'Erev Pesach', EREV$1 | LIGHT_CANDLES$1], // Attributes for Israel and Diaspora are different
|
|
4603
|
+
[15, NISAN$2, 'Pesach I', CHAG | YOM_TOV_ENDS$1 | IL_ONLY$1], [16, NISAN$2, 'Pesach II (CH\'\'M)', IL_ONLY$1 | CHOL_HAMOED$1, {
|
|
4604
4604
|
cholHaMoedDay: 1
|
|
4605
|
-
}], [17, NISAN$
|
|
4605
|
+
}], [17, NISAN$2, 'Pesach III (CH\'\'M)', IL_ONLY$1 | CHOL_HAMOED$1, {
|
|
4606
4606
|
cholHaMoedDay: 2
|
|
4607
|
-
}], [18, NISAN$
|
|
4607
|
+
}], [18, NISAN$2, 'Pesach IV (CH\'\'M)', IL_ONLY$1 | CHOL_HAMOED$1, {
|
|
4608
4608
|
cholHaMoedDay: 3
|
|
4609
|
-
}], [19, NISAN$
|
|
4609
|
+
}], [19, NISAN$2, 'Pesach V (CH\'\'M)', IL_ONLY$1 | CHOL_HAMOED$1, {
|
|
4610
4610
|
cholHaMoedDay: 4
|
|
4611
|
-
}], [20, NISAN$
|
|
4611
|
+
}], [20, NISAN$2, 'Pesach VI (CH\'\'M)', LIGHT_CANDLES$1 | IL_ONLY$1 | CHOL_HAMOED$1, {
|
|
4612
4612
|
cholHaMoedDay: 5
|
|
4613
|
-
}], [21, NISAN$
|
|
4613
|
+
}], [21, NISAN$2, 'Pesach VII', CHAG | YOM_TOV_ENDS$1 | IL_ONLY$1], [15, NISAN$2, 'Pesach I', CHAG | LIGHT_CANDLES_TZEIS$1 | CHUL_ONLY$1], [16, NISAN$2, 'Pesach II', CHAG | YOM_TOV_ENDS$1 | CHUL_ONLY$1], [17, NISAN$2, 'Pesach III (CH\'\'M)', CHUL_ONLY$1 | CHOL_HAMOED$1, {
|
|
4614
4614
|
cholHaMoedDay: 1
|
|
4615
|
-
}], [18, NISAN$
|
|
4615
|
+
}], [18, NISAN$2, 'Pesach IV (CH\'\'M)', CHUL_ONLY$1 | CHOL_HAMOED$1, {
|
|
4616
4616
|
cholHaMoedDay: 2
|
|
4617
|
-
}], [19, NISAN$
|
|
4617
|
+
}], [19, NISAN$2, 'Pesach V (CH\'\'M)', CHUL_ONLY$1 | CHOL_HAMOED$1, {
|
|
4618
4618
|
cholHaMoedDay: 3
|
|
4619
|
-
}], [20, NISAN$
|
|
4619
|
+
}], [20, NISAN$2, 'Pesach VI (CH\'\'M)', LIGHT_CANDLES$1 | CHUL_ONLY$1 | CHOL_HAMOED$1, {
|
|
4620
4620
|
cholHaMoedDay: 4
|
|
4621
|
-
}], [21, NISAN$
|
|
4621
|
+
}], [21, NISAN$2, 'Pesach VII', CHAG | LIGHT_CANDLES_TZEIS$1 | CHUL_ONLY$1], [22, NISAN$2, 'Pesach VIII', CHAG | YOM_TOV_ENDS$1 | CHUL_ONLY$1], [14, IYYAR, 'Pesach Sheni', MINOR_HOLIDAY$1], [18, IYYAR, 'Lag BaOmer', MINOR_HOLIDAY$1, {
|
|
4622
4622
|
emoji: '🔥'
|
|
4623
4623
|
}], [5, SIVAN$1, 'Erev Shavuot', EREV$1 | LIGHT_CANDLES$1, {
|
|
4624
4624
|
emoji: '⛰️🌸'
|
|
@@ -4648,7 +4648,7 @@ function getHolidaysForYear(year) {
|
|
|
4648
4648
|
|
|
4649
4649
|
if (year >= 5711) {
|
|
4650
4650
|
// Yom HaShoah first observed in 1951
|
|
4651
|
-
let nisan27dt = new HDate(27, NISAN$
|
|
4651
|
+
let nisan27dt = new HDate(27, NISAN$2, year);
|
|
4652
4652
|
/* When the actual date of Yom Hashoah falls on a Friday, the
|
|
4653
4653
|
* state of Israel observes Yom Hashoah on the preceding
|
|
4654
4654
|
* Thursday. When it falls on a Sunday, Yom Hashoah is observed
|
|
@@ -4657,9 +4657,9 @@ function getHolidaysForYear(year) {
|
|
|
4657
4657
|
*/
|
|
4658
4658
|
|
|
4659
4659
|
if (nisan27dt.getDay() == FRI$1) {
|
|
4660
|
-
nisan27dt = new HDate(26, NISAN$
|
|
4660
|
+
nisan27dt = new HDate(26, NISAN$2, year);
|
|
4661
4661
|
} else if (nisan27dt.getDay() == SUN) {
|
|
4662
|
-
nisan27dt = new HDate(28, NISAN$
|
|
4662
|
+
nisan27dt = new HDate(28, NISAN$2, year);
|
|
4663
4663
|
}
|
|
4664
4664
|
|
|
4665
4665
|
add(new HolidayEvent(nisan27dt, 'Yom HaShoah', MODERN_HOLIDAY$1));
|
|
@@ -4694,7 +4694,7 @@ function getHolidaysForYear(year) {
|
|
|
4694
4694
|
}
|
|
4695
4695
|
|
|
4696
4696
|
if (year >= 5777) {
|
|
4697
|
-
add(new HolidayEvent(new HDate(7, CHESHVAN$1, year), 'Yom HaAliyah School Observance', MODERN_HOLIDAY$1, emojiIsraelFlag), new HolidayEvent(new HDate(10, NISAN$
|
|
4697
|
+
add(new HolidayEvent(new HDate(7, CHESHVAN$1, year), 'Yom HaAliyah School Observance', MODERN_HOLIDAY$1, emojiIsraelFlag), new HolidayEvent(new HDate(10, NISAN$2, year), 'Yom HaAliyah', MODERN_HOLIDAY$1, emojiIsraelFlag));
|
|
4698
4698
|
}
|
|
4699
4699
|
|
|
4700
4700
|
let tamuz17 = new HDate(17, TAMUZ, year);
|
|
@@ -4727,7 +4727,7 @@ function getHolidaysForYear(year) {
|
|
|
4727
4727
|
for (let month = 1; month <= monthsInYear; month++) {
|
|
4728
4728
|
const monthName = HDate.getMonthName(month, year);
|
|
4729
4729
|
|
|
4730
|
-
if ((month == NISAN$
|
|
4730
|
+
if ((month == NISAN$2 ? HDate.daysInMonth(HDate.monthsInYear(year - 1), year - 1) : HDate.daysInMonth(month - 1, year)) == 30) {
|
|
4731
4731
|
add(new RoshChodeshEvent(new HDate(1, month, year), monthName));
|
|
4732
4732
|
add(new RoshChodeshEvent(new HDate(30, month - 1, year), monthName));
|
|
4733
4733
|
} else if (month !== TISHREI$1) {
|
|
@@ -4743,7 +4743,7 @@ function getHolidaysForYear(year) {
|
|
|
4743
4743
|
add(new MevarchimChodeshEvent(new HDate(29, month, year).onOrBefore(SAT$1), nextMonthName));
|
|
4744
4744
|
}
|
|
4745
4745
|
|
|
4746
|
-
const sedra =
|
|
4746
|
+
const sedra = getSedra_(year, false);
|
|
4747
4747
|
const beshalachHd = sedra.find(15);
|
|
4748
4748
|
add(new HolidayEvent(beshalachHd, 'Shabbat Shirah', SPECIAL_SHABBAT$1));
|
|
4749
4749
|
yearCache[year] = h;
|
|
@@ -4909,7 +4909,100 @@ class MishnaYomiEvent extends Event {
|
|
|
4909
4909
|
|
|
4910
4910
|
}
|
|
4911
4911
|
|
|
4912
|
-
|
|
4912
|
+
const NISAN$1 = months.NISAN;
|
|
4913
|
+
const CHESHVAN = months.CHESHVAN;
|
|
4914
|
+
const KISLEV = months.KISLEV;
|
|
4915
|
+
const TEVET = months.TEVET;
|
|
4916
|
+
const SHVAT = months.SHVAT;
|
|
4917
|
+
const ADAR_I = months.ADAR_I;
|
|
4918
|
+
const ADAR_II = months.ADAR_II;
|
|
4919
|
+
/**
|
|
4920
|
+
* @private
|
|
4921
|
+
* @param {number} hyear Hebrew year
|
|
4922
|
+
* @param {Date|HDate} gdate Gregorian or Hebrew date of death
|
|
4923
|
+
* @return {HDate} anniversary occurring in hyear
|
|
4924
|
+
*/
|
|
4925
|
+
|
|
4926
|
+
function getYahrzeit_(hyear, gdate) {
|
|
4927
|
+
const orig = HDate.isHDate(gdate) ? gdate : new HDate(gdate);
|
|
4928
|
+
let hDeath = {
|
|
4929
|
+
yy: orig.getFullYear(),
|
|
4930
|
+
mm: orig.getMonth(),
|
|
4931
|
+
dd: orig.getDate()
|
|
4932
|
+
};
|
|
4933
|
+
|
|
4934
|
+
if (hyear <= hDeath.yy) {
|
|
4935
|
+
// `Hebrew year ${hyear} occurs on or before original date in ${hDeath.yy}`
|
|
4936
|
+
return undefined;
|
|
4937
|
+
}
|
|
4938
|
+
|
|
4939
|
+
if (hDeath.mm == CHESHVAN && hDeath.dd == 30 && !HDate.longCheshvan(hDeath.yy + 1)) {
|
|
4940
|
+
// If it's Heshvan 30 it depends on the first anniversary;
|
|
4941
|
+
// if that was not Heshvan 30, use the day before Kislev 1.
|
|
4942
|
+
hDeath = HDate.abs2hebrew(HDate.hebrew2abs(hyear, KISLEV, 1) - 1);
|
|
4943
|
+
} else if (hDeath.mm == KISLEV && hDeath.dd == 30 && HDate.shortKislev(hDeath.yy + 1)) {
|
|
4944
|
+
// If it's Kislev 30 it depends on the first anniversary;
|
|
4945
|
+
// if that was not Kislev 30, use the day before Teveth 1.
|
|
4946
|
+
hDeath = HDate.abs2hebrew(HDate.hebrew2abs(hyear, TEVET, 1) - 1);
|
|
4947
|
+
} else if (hDeath.mm == ADAR_II) {
|
|
4948
|
+
// If it's Adar II, use the same day in last month of year (Adar or Adar II).
|
|
4949
|
+
hDeath.mm = HDate.monthsInYear(hyear);
|
|
4950
|
+
} else if (hDeath.mm == ADAR_I && hDeath.dd == 30 && !HDate.isLeapYear(hyear)) {
|
|
4951
|
+
// If it's the 30th in Adar I and year is not a leap year
|
|
4952
|
+
// (so Adar has only 29 days), use the last day in Shevat.
|
|
4953
|
+
hDeath.dd = 30;
|
|
4954
|
+
hDeath.mm = SHVAT;
|
|
4955
|
+
} // In all other cases, use the normal anniversary of the date of death.
|
|
4956
|
+
// advance day to rosh chodesh if needed
|
|
4957
|
+
|
|
4958
|
+
|
|
4959
|
+
if (hDeath.mm == CHESHVAN && hDeath.dd == 30 && !HDate.longCheshvan(hyear)) {
|
|
4960
|
+
hDeath.mm = KISLEV;
|
|
4961
|
+
hDeath.dd = 1;
|
|
4962
|
+
} else if (hDeath.mm == KISLEV && hDeath.dd == 30 && HDate.shortKislev(hyear)) {
|
|
4963
|
+
hDeath.mm = TEVET;
|
|
4964
|
+
hDeath.dd = 1;
|
|
4965
|
+
}
|
|
4966
|
+
|
|
4967
|
+
return new HDate(hDeath.dd, hDeath.mm, hyear);
|
|
4968
|
+
}
|
|
4969
|
+
/**
|
|
4970
|
+
* @private
|
|
4971
|
+
* @param {number} hyear Hebrew year
|
|
4972
|
+
* @param {Date|HDate} gdate Gregorian or Hebrew date of event
|
|
4973
|
+
* @return {HDate} anniversary occurring in `hyear`
|
|
4974
|
+
*/
|
|
4975
|
+
|
|
4976
|
+
function getBirthdayOrAnniversary_(hyear, gdate) {
|
|
4977
|
+
const orig = HDate.isHDate(gdate) ? gdate : new HDate(gdate);
|
|
4978
|
+
const origYear = orig.getFullYear();
|
|
4979
|
+
|
|
4980
|
+
if (hyear <= origYear) {
|
|
4981
|
+
// `Hebrew year ${hyear} occurs on or before original date in ${origYear}`
|
|
4982
|
+
return undefined;
|
|
4983
|
+
}
|
|
4984
|
+
|
|
4985
|
+
const isOrigLeap = HDate.isLeapYear(origYear);
|
|
4986
|
+
let month = orig.getMonth();
|
|
4987
|
+
let day = orig.getDate();
|
|
4988
|
+
|
|
4989
|
+
if (month == ADAR_I && !isOrigLeap || month == ADAR_II && isOrigLeap) {
|
|
4990
|
+
month = HDate.monthsInYear(hyear);
|
|
4991
|
+
} else if (month == CHESHVAN && day == 30 && !HDate.longCheshvan(hyear)) {
|
|
4992
|
+
month = KISLEV;
|
|
4993
|
+
day = 1;
|
|
4994
|
+
} else if (month == KISLEV && day == 30 && HDate.shortKislev(hyear)) {
|
|
4995
|
+
month = TEVET;
|
|
4996
|
+
day = 1;
|
|
4997
|
+
} else if (month == ADAR_I && day == 30 && isOrigLeap && !HDate.isLeapYear(hyear)) {
|
|
4998
|
+
month = NISAN$1;
|
|
4999
|
+
day = 1;
|
|
5000
|
+
}
|
|
5001
|
+
|
|
5002
|
+
return new HDate(day, month, hyear);
|
|
5003
|
+
}
|
|
5004
|
+
|
|
5005
|
+
var version="3.33.4";
|
|
4913
5006
|
|
|
4914
5007
|
var headers$1={"plural-forms":"nplurals=2; plural=(n > 1);",language:"en_CA@ashkenazi"};var contexts$1={"":{Berachot:["Berachos"],Shabbat:["Shabbos"],Taanit:["Taanis"],Yevamot:["Yevamos"],Ketubot:["Kesubos"],"Baba Batra":["Baba Basra"],Makkot:["Makkos"],Shevuot:["Shevuos"],Horayot:["Horayos"],Menachot:["Menachos"],Bechorot:["Bechoros"],Keritot:["Kerisos"],Midot:["Midos"],"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"],Tazria:["Sazria"],"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"],Berakhot:["Berakhos"],Sheviit:["Sheviis"],Terumot:["Terumos"],Maasrot:["Maasros"],Eduyot:["Eduyos"],Avot:["Avos"],Bekhorot:["Bekhoros"],Middot:["Middos"],Oholot:["Oholos"],Tahorot:["Tahoros"],Mikvaot:["Mikvaos"]}};var poAshkenazi = {headers:headers$1,contexts:contexts$1};
|
|
4915
5008
|
|
|
@@ -4966,12 +5059,6 @@ const SIVAN = months.SIVAN; // const TAMUZ = months.TAMUZ;
|
|
|
4966
5059
|
|
|
4967
5060
|
const ELUL = months.ELUL;
|
|
4968
5061
|
const TISHREI = months.TISHREI;
|
|
4969
|
-
const CHESHVAN = months.CHESHVAN;
|
|
4970
|
-
const KISLEV = months.KISLEV;
|
|
4971
|
-
const TEVET = months.TEVET;
|
|
4972
|
-
const SHVAT = months.SHVAT;
|
|
4973
|
-
const ADAR_I = months.ADAR_I;
|
|
4974
|
-
const ADAR_II = months.ADAR_II;
|
|
4975
5062
|
const LIGHT_CANDLES = flags.LIGHT_CANDLES;
|
|
4976
5063
|
const YOM_TOV_ENDS = flags.YOM_TOV_ENDS;
|
|
4977
5064
|
const CHUL_ONLY = flags.CHUL_ONLY;
|
|
@@ -5300,18 +5387,49 @@ function getMaskFromOptions(options) {
|
|
|
5300
5387
|
}
|
|
5301
5388
|
|
|
5302
5389
|
const MASK_LIGHT_CANDLES = LIGHT_CANDLES | LIGHT_CANDLES_TZEIS | CHANUKAH_CANDLES | YOM_TOV_ENDS;
|
|
5390
|
+
const defaultLocation = new Location(0, 0, false, 'UTC');
|
|
5391
|
+
const hour12cc = {
|
|
5392
|
+
US: 1,
|
|
5393
|
+
CA: 1,
|
|
5394
|
+
BR: 1,
|
|
5395
|
+
AU: 1,
|
|
5396
|
+
NZ: 1,
|
|
5397
|
+
DO: 1,
|
|
5398
|
+
PR: 1,
|
|
5399
|
+
GR: 1,
|
|
5400
|
+
IN: 1,
|
|
5401
|
+
KR: 1,
|
|
5402
|
+
NP: 1,
|
|
5403
|
+
ZA: 1
|
|
5404
|
+
};
|
|
5405
|
+
/**
|
|
5406
|
+
* @private
|
|
5407
|
+
* @param {Event} ev
|
|
5408
|
+
* @return {boolean}
|
|
5409
|
+
*/
|
|
5410
|
+
|
|
5411
|
+
function observedInIsrael(ev) {
|
|
5412
|
+
return ev.observedInIsrael();
|
|
5413
|
+
}
|
|
5414
|
+
/**
|
|
5415
|
+
* @private
|
|
5416
|
+
* @param {Event} ev
|
|
5417
|
+
* @return {boolean}
|
|
5418
|
+
*/
|
|
5419
|
+
|
|
5420
|
+
|
|
5421
|
+
function observedInDiaspora(ev) {
|
|
5422
|
+
return ev.observedInDiaspora();
|
|
5423
|
+
}
|
|
5303
5424
|
/**
|
|
5304
|
-
* @namespace
|
|
5305
5425
|
* HebrewCalendar is the main interface to the `@hebcal/core` library.
|
|
5306
5426
|
* This namespace is used to calculate holidays, rosh chodesh, candle lighting & havdalah times,
|
|
5307
5427
|
* Parashat HaShavua, Daf Yomi, days of the omer, and the molad.
|
|
5308
5428
|
* Event names can be rendered in several languges using the `locale` option.
|
|
5309
5429
|
*/
|
|
5310
5430
|
|
|
5311
|
-
const HebrewCalendar = {
|
|
5312
|
-
/** @private */
|
|
5313
|
-
defaultLocation: new Location(0, 0, false, 'UTC'),
|
|
5314
5431
|
|
|
5432
|
+
class HebrewCalendar {
|
|
5315
5433
|
/**
|
|
5316
5434
|
* Calculates holidays and other Hebrew calendar events based on {@link HebrewCalendar.Options}.
|
|
5317
5435
|
*
|
|
@@ -5412,11 +5530,11 @@ const HebrewCalendar = {
|
|
|
5412
5530
|
* @param {HebrewCalendar.Options} [options={}]
|
|
5413
5531
|
* @return {Event[]}
|
|
5414
5532
|
*/
|
|
5415
|
-
calendar
|
|
5533
|
+
static calendar(options = {}) {
|
|
5416
5534
|
options = shallowCopy({}, options); // so we can modify freely
|
|
5417
5535
|
|
|
5418
5536
|
checkCandleOptions(options);
|
|
5419
|
-
const location = options.location = options.location ||
|
|
5537
|
+
const location = options.location = options.location || defaultLocation;
|
|
5420
5538
|
const il = options.il = options.il || location.il || false;
|
|
5421
5539
|
options.mask = getMaskFromOptions(options);
|
|
5422
5540
|
|
|
@@ -5466,7 +5584,7 @@ const HebrewCalendar = {
|
|
|
5466
5584
|
holidaysYear = HebrewCalendar.getHolidaysForYear(currentYear);
|
|
5467
5585
|
|
|
5468
5586
|
if (options.sedrot && currentYear >= 3762) {
|
|
5469
|
-
sedra =
|
|
5587
|
+
sedra = getSedra_(currentYear, il);
|
|
5470
5588
|
}
|
|
5471
5589
|
|
|
5472
5590
|
if (options.omer) {
|
|
@@ -5541,8 +5659,7 @@ const HebrewCalendar = {
|
|
|
5541
5659
|
}
|
|
5542
5660
|
|
|
5543
5661
|
return evts;
|
|
5544
|
-
}
|
|
5545
|
-
|
|
5662
|
+
}
|
|
5546
5663
|
/**
|
|
5547
5664
|
* Calculates a birthday or anniversary (non-yahrzeit).
|
|
5548
5665
|
* `hyear` must be after original `gdate` of anniversary.
|
|
@@ -5569,35 +5686,11 @@ const HebrewCalendar = {
|
|
|
5569
5686
|
* @param {Date|HDate} gdate Gregorian or Hebrew date of event
|
|
5570
5687
|
* @return {HDate} anniversary occurring in `hyear`
|
|
5571
5688
|
*/
|
|
5572
|
-
getBirthdayOrAnniversary: function (hyear, gdate) {
|
|
5573
|
-
const orig = HDate.isHDate(gdate) ? gdate : new HDate(gdate);
|
|
5574
|
-
const origYear = orig.getFullYear();
|
|
5575
5689
|
|
|
5576
|
-
if (hyear <= origYear) {
|
|
5577
|
-
// `Hebrew year ${hyear} occurs on or before original date in ${origYear}`
|
|
5578
|
-
return undefined;
|
|
5579
|
-
}
|
|
5580
|
-
|
|
5581
|
-
const isOrigLeap = HDate.isLeapYear(origYear);
|
|
5582
|
-
let month = orig.getMonth();
|
|
5583
|
-
let day = orig.getDate();
|
|
5584
|
-
|
|
5585
|
-
if (month == ADAR_I && !isOrigLeap || month == ADAR_II && isOrigLeap) {
|
|
5586
|
-
month = HDate.monthsInYear(hyear);
|
|
5587
|
-
} else if (month == CHESHVAN && day == 30 && !HDate.longCheshvan(hyear)) {
|
|
5588
|
-
month = KISLEV;
|
|
5589
|
-
day = 1;
|
|
5590
|
-
} else if (month == KISLEV && day == 30 && HDate.shortKislev(hyear)) {
|
|
5591
|
-
month = TEVET;
|
|
5592
|
-
day = 1;
|
|
5593
|
-
} else if (month == ADAR_I && day == 30 && isOrigLeap && !HDate.isLeapYear(hyear)) {
|
|
5594
|
-
month = NISAN;
|
|
5595
|
-
day = 1;
|
|
5596
|
-
}
|
|
5597
|
-
|
|
5598
|
-
return new HDate(day, month, hyear);
|
|
5599
|
-
},
|
|
5600
5690
|
|
|
5691
|
+
static getBirthdayOrAnniversary(hyear, gdate) {
|
|
5692
|
+
return getBirthdayOrAnniversary_(hyear, gdate);
|
|
5693
|
+
}
|
|
5601
5694
|
/**
|
|
5602
5695
|
* Calculates yahrzeit.
|
|
5603
5696
|
* `hyear` must be after original `gdate` of death.
|
|
@@ -5632,50 +5725,11 @@ const HebrewCalendar = {
|
|
|
5632
5725
|
* @param {Date|HDate} gdate Gregorian or Hebrew date of death
|
|
5633
5726
|
* @return {HDate} anniversary occurring in hyear
|
|
5634
5727
|
*/
|
|
5635
|
-
getYahrzeit: function (hyear, gdate) {
|
|
5636
|
-
const orig = HDate.isHDate(gdate) ? gdate : new HDate(gdate);
|
|
5637
|
-
let hDeath = {
|
|
5638
|
-
yy: orig.getFullYear(),
|
|
5639
|
-
mm: orig.getMonth(),
|
|
5640
|
-
dd: orig.getDate()
|
|
5641
|
-
};
|
|
5642
5728
|
|
|
5643
|
-
if (hyear <= hDeath.yy) {
|
|
5644
|
-
// `Hebrew year ${hyear} occurs on or before original date in ${hDeath.yy}`
|
|
5645
|
-
return undefined;
|
|
5646
|
-
}
|
|
5647
|
-
|
|
5648
|
-
if (hDeath.mm == CHESHVAN && hDeath.dd == 30 && !HDate.longCheshvan(hDeath.yy + 1)) {
|
|
5649
|
-
// If it's Heshvan 30 it depends on the first anniversary;
|
|
5650
|
-
// if that was not Heshvan 30, use the day before Kislev 1.
|
|
5651
|
-
hDeath = HDate.abs2hebrew(HDate.hebrew2abs(hyear, KISLEV, 1) - 1);
|
|
5652
|
-
} else if (hDeath.mm == KISLEV && hDeath.dd == 30 && HDate.shortKislev(hDeath.yy + 1)) {
|
|
5653
|
-
// If it's Kislev 30 it depends on the first anniversary;
|
|
5654
|
-
// if that was not Kislev 30, use the day before Teveth 1.
|
|
5655
|
-
hDeath = HDate.abs2hebrew(HDate.hebrew2abs(hyear, TEVET, 1) - 1);
|
|
5656
|
-
} else if (hDeath.mm == ADAR_II) {
|
|
5657
|
-
// If it's Adar II, use the same day in last month of year (Adar or Adar II).
|
|
5658
|
-
hDeath.mm = HDate.monthsInYear(hyear);
|
|
5659
|
-
} else if (hDeath.mm == ADAR_I && hDeath.dd == 30 && !HDate.isLeapYear(hyear)) {
|
|
5660
|
-
// If it's the 30th in Adar I and year is not a leap year
|
|
5661
|
-
// (so Adar has only 29 days), use the last day in Shevat.
|
|
5662
|
-
hDeath.dd = 30;
|
|
5663
|
-
hDeath.mm = SHVAT;
|
|
5664
|
-
} // In all other cases, use the normal anniversary of the date of death.
|
|
5665
|
-
// advance day to rosh chodesh if needed
|
|
5666
|
-
|
|
5667
|
-
|
|
5668
|
-
if (hDeath.mm == CHESHVAN && hDeath.dd == 30 && !HDate.longCheshvan(hyear)) {
|
|
5669
|
-
hDeath.mm = KISLEV;
|
|
5670
|
-
hDeath.dd = 1;
|
|
5671
|
-
} else if (hDeath.mm == KISLEV && hDeath.dd == 30 && HDate.shortKislev(hyear)) {
|
|
5672
|
-
hDeath.mm = TEVET;
|
|
5673
|
-
hDeath.dd = 1;
|
|
5674
|
-
}
|
|
5675
|
-
|
|
5676
|
-
return new HDate(hDeath.dd, hDeath.mm, hyear);
|
|
5677
|
-
},
|
|
5678
5729
|
|
|
5730
|
+
static getYahrzeit(hyear, gdate) {
|
|
5731
|
+
return getYahrzeit_(hyear, gdate);
|
|
5732
|
+
}
|
|
5679
5733
|
/**
|
|
5680
5734
|
* Lower-level holidays interface, which returns a `Map` of `Event`s indexed by
|
|
5681
5735
|
* `HDate.toString()`. These events must filtered especially for `flags.IL_ONLY`
|
|
@@ -5684,65 +5738,58 @@ const HebrewCalendar = {
|
|
|
5684
5738
|
* @param {number} year Hebrew year
|
|
5685
5739
|
* @return {Map<string,Event[]>}
|
|
5686
5740
|
*/
|
|
5687
|
-
getHolidaysForYear: getHolidaysForYear,
|
|
5688
5741
|
|
|
5742
|
+
|
|
5743
|
+
static getHolidaysForYear(year) {
|
|
5744
|
+
return getHolidaysForYear_(year);
|
|
5745
|
+
}
|
|
5689
5746
|
/**
|
|
5690
5747
|
* Returns an array of holidays for the year
|
|
5691
5748
|
* @param {number} year Hebrew year
|
|
5692
5749
|
* @param {boolean} il use the Israeli schedule for holidays
|
|
5693
5750
|
* @return {Event[]}
|
|
5694
5751
|
*/
|
|
5695
|
-
|
|
5696
|
-
|
|
5752
|
+
|
|
5753
|
+
|
|
5754
|
+
static getHolidaysForYearArray(year, il) {
|
|
5755
|
+
const yearMap = getHolidaysForYear_(year);
|
|
5697
5756
|
const startAbs = HDate.hebrew2abs(year, TISHREI, 1);
|
|
5698
5757
|
const endAbs = HDate.hebrew2abs(year + 1, TISHREI, 1) - 1;
|
|
5699
|
-
|
|
5758
|
+
let events = [];
|
|
5759
|
+
const myFilter = il ? observedInIsrael : observedInDiaspora;
|
|
5700
5760
|
|
|
5701
5761
|
for (let absDt = startAbs; absDt <= endAbs; absDt++) {
|
|
5702
5762
|
const hd = new HDate(absDt);
|
|
5703
5763
|
const holidays = yearMap.get(hd.toString());
|
|
5704
5764
|
|
|
5705
5765
|
if (holidays) {
|
|
5706
|
-
const filtered = holidays.filter(
|
|
5707
|
-
|
|
5766
|
+
const filtered = holidays.filter(myFilter);
|
|
5767
|
+
events = events.concat(filtered);
|
|
5708
5768
|
}
|
|
5709
5769
|
}
|
|
5710
5770
|
|
|
5711
5771
|
return events;
|
|
5712
|
-
}
|
|
5713
|
-
|
|
5772
|
+
}
|
|
5714
5773
|
/**
|
|
5715
5774
|
* Returns an array of Events on this date (or undefined if no events)
|
|
5716
5775
|
* @param {HDate|Date|number} date Hebrew Date, Gregorian date, or absolute R.D. day number
|
|
5717
5776
|
* @param {boolean} [il] use the Israeli schedule for holidays
|
|
5718
5777
|
* @return {Event[]}
|
|
5719
5778
|
*/
|
|
5720
|
-
|
|
5779
|
+
|
|
5780
|
+
|
|
5781
|
+
static getHolidaysOnDate(date, il) {
|
|
5721
5782
|
const hd = HDate.isHDate(date) ? date : new HDate(date);
|
|
5722
|
-
const yearMap =
|
|
5783
|
+
const yearMap = getHolidaysForYear_(hd.getFullYear());
|
|
5723
5784
|
const events = yearMap.get(hd.toString());
|
|
5724
5785
|
|
|
5725
5786
|
if (typeof il === 'undefined' || typeof events === 'undefined') {
|
|
5726
5787
|
return events;
|
|
5727
5788
|
}
|
|
5728
5789
|
|
|
5729
|
-
|
|
5730
|
-
|
|
5731
|
-
|
|
5732
|
-
US: 1,
|
|
5733
|
-
CA: 1,
|
|
5734
|
-
BR: 1,
|
|
5735
|
-
AU: 1,
|
|
5736
|
-
NZ: 1,
|
|
5737
|
-
DO: 1,
|
|
5738
|
-
PR: 1,
|
|
5739
|
-
GR: 1,
|
|
5740
|
-
IN: 1,
|
|
5741
|
-
KR: 1,
|
|
5742
|
-
NP: 1,
|
|
5743
|
-
ZA: 1
|
|
5744
|
-
},
|
|
5745
|
-
|
|
5790
|
+
const myFilter = il ? observedInIsrael : observedInDiaspora;
|
|
5791
|
+
return events.filter(myFilter);
|
|
5792
|
+
}
|
|
5746
5793
|
/**
|
|
5747
5794
|
* Helper function to format a 23-hour (00:00-23:59) time in US format ("8:13pm") or
|
|
5748
5795
|
* keep as "20:13" for any other locale/country. Uses `HebrewCalendar.Options` to determine
|
|
@@ -5752,11 +5799,13 @@ const HebrewCalendar = {
|
|
|
5752
5799
|
* @param {HebrewCalendar.Options} options
|
|
5753
5800
|
* @return {string}
|
|
5754
5801
|
*/
|
|
5755
|
-
|
|
5802
|
+
|
|
5803
|
+
|
|
5804
|
+
static reformatTimeStr(timeStr, suffix, options) {
|
|
5756
5805
|
if (typeof timeStr !== 'string') throw new TypeError(`Bad timeStr: ${timeStr}`);
|
|
5757
5806
|
const cc = options.location && options.location.cc || (options.il ? 'IL' : 'US');
|
|
5758
5807
|
|
|
5759
|
-
if (typeof
|
|
5808
|
+
if (typeof hour12cc[cc] === 'undefined') {
|
|
5760
5809
|
return timeStr;
|
|
5761
5810
|
}
|
|
5762
5811
|
|
|
@@ -5770,13 +5819,13 @@ const HebrewCalendar = {
|
|
|
5770
5819
|
}
|
|
5771
5820
|
|
|
5772
5821
|
return `${hour}:${hm[1]}${suffix}`;
|
|
5773
|
-
}
|
|
5774
|
-
|
|
5822
|
+
}
|
|
5775
5823
|
/** @return {string} */
|
|
5776
|
-
version: function () {
|
|
5777
|
-
return version;
|
|
5778
|
-
},
|
|
5779
5824
|
|
|
5825
|
+
|
|
5826
|
+
static version() {
|
|
5827
|
+
return version;
|
|
5828
|
+
}
|
|
5780
5829
|
/**
|
|
5781
5830
|
* Convenience function to create an instance of `Sedra` or reuse a previously
|
|
5782
5831
|
* created and cached instance.
|
|
@@ -5785,8 +5834,13 @@ const HebrewCalendar = {
|
|
|
5785
5834
|
* @param {boolean} il
|
|
5786
5835
|
* @return {Sedra}
|
|
5787
5836
|
*/
|
|
5788
|
-
|
|
5789
|
-
|
|
5837
|
+
|
|
5838
|
+
|
|
5839
|
+
static getSedra(hyear, il) {
|
|
5840
|
+
return getSedra_(hyear, il);
|
|
5841
|
+
}
|
|
5842
|
+
|
|
5843
|
+
}
|
|
5790
5844
|
/**
|
|
5791
5845
|
* Appends the Event `ev` to the `events` array. Also may add related
|
|
5792
5846
|
* timed events like candle-lighting or fast start/end
|