@hebcal/core 5.0.9 → 5.1.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/dist/bundle.js CHANGED
@@ -1,4 +1,4 @@
1
- /*! @hebcal/core v5.0.9 */
1
+ /*! @hebcal/core v5.1.0 */
2
2
  var hebcal = (function (exports) {
3
3
  'use strict';
4
4
 
@@ -142,7 +142,7 @@ const IYYAR$1 = 2;
142
142
  // const SIVAN = 3;
143
143
  const TAMUZ$1 = 4;
144
144
  // const AV = 5;
145
- const ELUL$2 = 6;
145
+ const ELUL$1 = 6;
146
146
  const TISHREI$2 = 7;
147
147
  const CHESHVAN$1 = 8;
148
148
  const KISLEV$2 = 9;
@@ -293,7 +293,7 @@ function daysInMonth(month, year) {
293
293
  switch (month) {
294
294
  case IYYAR$1:
295
295
  case TAMUZ$1:
296
- case ELUL$2:
296
+ case ELUL$1:
297
297
  case TEVET$2:
298
298
  case ADAR_II$2:
299
299
  return 29;
@@ -7135,24 +7135,23 @@ function reformatTimeStr(timeStr, suffix, options) {
7135
7135
  }
7136
7136
 
7137
7137
  /* eslint-disable max-len */
7138
- const FRI$3 = 5;
7139
- const SAT$3 = 6;
7140
7138
 
7141
7139
  /**
7142
7140
  * @private
7143
7141
  * @param {Event} e
7144
7142
  * @param {HDate} hd
7145
- * @param {number} dow
7146
7143
  * @param {CalOptions} options
7144
+ * @param {boolean} isFriday
7145
+ * @param {boolean} isSaturday
7147
7146
  * @return {Event}
7148
7147
  */
7149
- function makeCandleEvent(e, hd, dow, options) {
7148
+ function makeCandleEvent(e, hd, options, isFriday, isSaturday) {
7150
7149
  let havdalahTitle = false;
7151
- let useHavdalahOffset = dow === SAT$3;
7150
+ let useHavdalahOffset = isSaturday;
7152
7151
  let mask = e ? e.getFlags() : flags.LIGHT_CANDLES;
7153
7152
  if (typeof e !== 'undefined') {
7154
7153
  // if linked event && dow == FRI, use Candle lighting time & title
7155
- if (dow !== FRI$3) {
7154
+ if (!isFriday) {
7156
7155
  if (mask & (flags.LIGHT_CANDLES_TZEIS | flags.CHANUKAH_CANDLES)) {
7157
7156
  useHavdalahOffset = true;
7158
7157
  } else if (mask & flags.YOM_TOV_ENDS) {
@@ -7160,7 +7159,7 @@ function makeCandleEvent(e, hd, dow, options) {
7160
7159
  useHavdalahOffset = true;
7161
7160
  }
7162
7161
  }
7163
- } else if (dow === SAT$3) {
7162
+ } else if (isSaturday) {
7164
7163
  havdalahTitle = true;
7165
7164
  mask = flags.LIGHT_CANDLES_TZEIS;
7166
7165
  }
@@ -7472,7 +7471,11 @@ class Molad {
7472
7471
  const chalakimStr = Locale.gettext('chalakim', locale);
7473
7472
  if (isHebrewLocale) {
7474
7473
  const ampm = hour < 5 ? night : hour < 12 ? morning : hour < 17 ? afternoon : hour < 21 ? evening : night;
7475
- return `${moladStr} ${monthName} יִהְיֶה בַּיּוֹם ${dow} בשָׁבוּעַ, ` + `בְּשָׁעָה ${hour} ${ampm}, ` + `ו-${minutes} ${minutesStr} ` + `ו-${chalakim} ${chalakimStr}`;
7474
+ const result = `${moladStr} ${monthName} יִהְיֶה בַּיּוֹם ${dow} בשָׁבוּעַ, ` + `בְּשָׁעָה ${hour} ${ampm}, ` + `ו-${minutes} ${minutesStr} ` + `ו-${chalakim} ${chalakimStr}`;
7475
+ if (locale === 'he-x-nonikud') {
7476
+ return Locale.hebrewStripNikkud(result);
7477
+ }
7478
+ return result;
7476
7479
  }
7477
7480
  const fmtTime = reformatTimeStr(`${hour}:00`, 'pm', options);
7478
7481
  const month = monthName.replace(/'/g, '’');
@@ -8066,6 +8069,7 @@ class Sedra {
8066
8069
  const hyphen = locale0 == 'he' ? '־' : '-';
8067
8070
  name += hyphen + Locale.gettext(parsha[1], locale0);
8068
8071
  }
8072
+ name = name.replace(/'/g, '’');
8069
8073
  return Locale.gettext('Parashat', locale0) + ' ' + name;
8070
8074
  }
8071
8075
 
@@ -9768,17 +9772,22 @@ class MevarchimChodeshEvent extends Event {
9768
9772
  * Constructs Mevarchim haChodesh event
9769
9773
  * @param {HDate} date Hebrew date event occurs
9770
9774
  * @param {string} monthName Hebrew month name (not translated)
9775
+ * @param {string} [memo]
9771
9776
  */
9772
- constructor(date, monthName) {
9777
+ constructor(date, monthName, memo) {
9773
9778
  super(date, `${mevarchimChodeshStr} ${monthName}`, flags.SHABBAT_MEVARCHIM);
9774
9779
  this.monthName = monthName;
9775
- const hyear = date.getFullYear();
9776
- const hmonth = date.getMonth();
9777
- const monNext = hmonth == HDate.monthsInYear(hyear) ? NISAN$1 : hmonth + 1;
9778
- const molad = new Molad(hyear, monNext);
9779
- this.memo = molad.render('en', {
9780
- hour12: false
9781
- });
9780
+ if (memo) {
9781
+ this.memo = memo;
9782
+ } else {
9783
+ const hyear = date.getFullYear();
9784
+ const hmonth = date.getMonth();
9785
+ const monNext = hmonth == HDate.monthsInYear(hyear) ? NISAN$1 : hmonth + 1;
9786
+ const molad = new Molad(hyear, monNext);
9787
+ this.memo = molad.render('en', {
9788
+ hour12: false
9789
+ });
9790
+ }
9782
9791
  }
9783
9792
  /** @return {string} */
9784
9793
  basename() {
@@ -9878,7 +9887,6 @@ const SAT$1 = 6;
9878
9887
  const NISAN$1 = months.NISAN;
9879
9888
  const TAMUZ = months.TAMUZ;
9880
9889
  const AV = months.AV;
9881
- const ELUL$1 = months.ELUL;
9882
9890
  const TISHREI$1 = months.TISHREI;
9883
9891
  const KISLEV = months.KISLEV;
9884
9892
  const TEVET = months.TEVET;
@@ -10040,13 +10048,6 @@ function getHolidaysForYear_(year) {
10040
10048
  } else if (month !== TISHREI$1) {
10041
10049
  add(new RoshChodeshEvent(new HDate(1, month, year), monthName));
10042
10050
  }
10043
- if (month == ELUL$1) {
10044
- continue;
10045
- }
10046
-
10047
- // Don't worry about month overrun; will get "Nisan" for month=14
10048
- const nextMonthName = HDate.getMonthName(month + 1, year);
10049
- add(new MevarchimChodeshEvent(new HDate(29, month, year).onOrBefore(SAT$1), nextMonthName));
10050
10051
  }
10051
10052
 
10052
10053
  // Begin: Yom Kippur Katan
@@ -10149,7 +10150,7 @@ class DailyLearning {
10149
10150
  }
10150
10151
 
10151
10152
  // DO NOT EDIT THIS AUTO-GENERATED FILE!
10152
- const version = '5.0.9';
10153
+ const version = '5.1.0';
10153
10154
 
10154
10155
  var objectGetOwnPropertyDescriptor = {};
10155
10156
 
@@ -11832,12 +11833,14 @@ class HebrewCalendar {
11832
11833
  }
11833
11834
  const prevEventsLength = evts.length;
11834
11835
  const dow = hd.getDay();
11836
+ const isFriday = dow === FRI;
11837
+ const isSaturday = dow === SAT;
11835
11838
  let candlesEv;
11836
11839
  const ev = holidaysYear.get(hd.toString()) || [];
11837
11840
  for (const e of ev) {
11838
- candlesEv = appendHolidayAndRelated(evts, e, options, candlesEv, dow);
11841
+ candlesEv = appendHolidayAndRelated(candlesEv, evts, e, options, isFriday, isSaturday);
11839
11842
  }
11840
- if (options.sedrot && dow === SAT) {
11843
+ if (options.sedrot && isSaturday) {
11841
11844
  const parsha0 = sedra.lookup(abs);
11842
11845
  if (!parsha0.chag) {
11843
11846
  evts.push(new ParshaEvent(hd, parsha0.parsha, il, parsha0.num));
@@ -11868,14 +11871,23 @@ class HebrewCalendar {
11868
11871
  evts.push(omerEv);
11869
11872
  }
11870
11873
  const hmonth = hd.getMonth();
11871
- if (options.molad && dow == SAT && hmonth != ELUL && hd.getDate() >= 23 && hd.getDate() <= 29) {
11874
+ const hdate = hd.getDate();
11875
+ if (isSaturday && (options.molad || options.shabbatMevarchim) && hmonth != ELUL && hdate >= 23 && hdate <= 29) {
11872
11876
  const monNext = hmonth == HDate.monthsInYear(hyear) ? NISAN : hmonth + 1;
11873
- evts.push(new MoladEvent(hd, hyear, monNext, options));
11877
+ if (options.molad) {
11878
+ evts.push(new MoladEvent(hd, hyear, monNext, options));
11879
+ }
11880
+ if (options.shabbatMevarchim) {
11881
+ const nextMonthName = HDate.getMonthName(monNext, hyear);
11882
+ const molad = new Molad(hyear, monNext);
11883
+ const memo = molad.render(options.locale || 'en', options);
11884
+ evts.push(new MevarchimChodeshEvent(hd, nextMonthName, memo));
11885
+ }
11874
11886
  }
11875
- if (!candlesEv && options.candlelighting && (dow == FRI || dow == SAT)) {
11876
- candlesEv = makeCandleEvent(undefined, hd, dow, options);
11877
- if (dow === FRI && candlesEv && sedra) {
11878
- candlesEv.memo = sedra.getString(abs);
11887
+ if (!candlesEv && options.candlelighting && (isFriday || isSaturday)) {
11888
+ candlesEv = makeCandleEvent(undefined, hd, options, isFriday, isSaturday);
11889
+ if (isFriday && candlesEv && sedra) {
11890
+ candlesEv.memo = sedra.getString(abs, options.locale);
11879
11891
  }
11880
11892
  }
11881
11893
  // suppress Havdalah when options.havdalahMins=0 or options.havdalahDeg=0
@@ -12111,14 +12123,15 @@ class HebrewCalendar {
12111
12123
  * Appends the Event `ev` to the `events` array. Also may add related
12112
12124
  * timed events like candle-lighting or fast start/end
12113
12125
  * @private
12126
+ * @param {Event} candlesEv
12114
12127
  * @param {Event[]} events
12115
12128
  * @param {Event} ev
12116
12129
  * @param {CalOptions} options
12117
- * @param {Event} candlesEv
12118
- * @param {number} dow
12130
+ * @param {boolean} isFriday
12131
+ * @param {boolean} isSaturday
12119
12132
  * @return {Event}
12120
12133
  */
12121
- function appendHolidayAndRelated(events, ev, options, candlesEv, dow) {
12134
+ function appendHolidayAndRelated(candlesEv, events, ev, options, isFriday, isSaturday) {
12122
12135
  const il = options.il;
12123
12136
  if (!ev.observedIn(il)) {
12124
12137
  return candlesEv; // holiday isn't observed here; bail out early
@@ -12139,9 +12152,9 @@ function appendHolidayAndRelated(events, ev, options, candlesEv, dow) {
12139
12152
  if (eFlags & options.mask || !eFlags && !options.userMask) {
12140
12153
  if (options.candlelighting && eFlags & MASK_LIGHT_CANDLES) {
12141
12154
  const hd = ev.getDate();
12142
- candlesEv = makeCandleEvent(ev, hd, dow, options);
12155
+ candlesEv = makeCandleEvent(ev, hd, options, isFriday, isSaturday);
12143
12156
  if (eFlags & CHANUKAH_CANDLES && candlesEv && !options.noHolidays) {
12144
- const chanukahEv = dow === FRI || dow === SAT ? candlesEv : makeWeekdayChanukahCandleLighting(ev, hd, options);
12157
+ const chanukahEv = isFriday || isSaturday ? candlesEv : makeWeekdayChanukahCandleLighting(ev, hd, options);
12145
12158
  const attrs = {
12146
12159
  eventTime: chanukahEv.eventTime,
12147
12160
  eventTimeStr: chanukahEv.eventTimeStr,
@@ -12151,7 +12164,7 @@ function appendHolidayAndRelated(events, ev, options, candlesEv, dow) {
12151
12164
  if (ev.emoji) attrs.emoji = ev.emoji;
12152
12165
  // Replace Chanukah event with a clone that includes candle lighting time.
12153
12166
  // For clarity, allow a "duplicate" candle lighting event to remain for Shabbat
12154
- ev = new HolidayEvent(ev.getDate(), ev.getDesc(), eFlags, attrs);
12167
+ ev = new HolidayEvent(hd, ev.getDesc(), eFlags, attrs);
12155
12168
  candlesEv = undefined;
12156
12169
  }
12157
12170
  }