@hebcal/core 5.0.8 → 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.8 */
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
 
@@ -8401,6 +8405,7 @@ class ParshaEvent extends Event {
8401
8405
  const hyphen = locale0 == 'he' ? '־' : '-';
8402
8406
  name += hyphen + Locale.gettext(parsha[1], locale);
8403
8407
  }
8408
+ name = name.replace(/'/g, '’');
8404
8409
  const str = Locale.gettext('Parashat', locale) + ' ' + name;
8405
8410
  return str.normalize();
8406
8411
  }
@@ -9767,17 +9772,22 @@ class MevarchimChodeshEvent extends Event {
9767
9772
  * Constructs Mevarchim haChodesh event
9768
9773
  * @param {HDate} date Hebrew date event occurs
9769
9774
  * @param {string} monthName Hebrew month name (not translated)
9775
+ * @param {string} [memo]
9770
9776
  */
9771
- constructor(date, monthName) {
9777
+ constructor(date, monthName, memo) {
9772
9778
  super(date, `${mevarchimChodeshStr} ${monthName}`, flags.SHABBAT_MEVARCHIM);
9773
9779
  this.monthName = monthName;
9774
- const hyear = date.getFullYear();
9775
- const hmonth = date.getMonth();
9776
- const monNext = hmonth == HDate.monthsInYear(hyear) ? NISAN$1 : hmonth + 1;
9777
- const molad = new Molad(hyear, monNext);
9778
- this.memo = molad.render('en', {
9779
- hour12: false
9780
- });
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
+ }
9781
9791
  }
9782
9792
  /** @return {string} */
9783
9793
  basename() {
@@ -9877,7 +9887,6 @@ const SAT$1 = 6;
9877
9887
  const NISAN$1 = months.NISAN;
9878
9888
  const TAMUZ = months.TAMUZ;
9879
9889
  const AV = months.AV;
9880
- const ELUL$1 = months.ELUL;
9881
9890
  const TISHREI$1 = months.TISHREI;
9882
9891
  const KISLEV = months.KISLEV;
9883
9892
  const TEVET = months.TEVET;
@@ -10039,13 +10048,6 @@ function getHolidaysForYear_(year) {
10039
10048
  } else if (month !== TISHREI$1) {
10040
10049
  add(new RoshChodeshEvent(new HDate(1, month, year), monthName));
10041
10050
  }
10042
- if (month == ELUL$1) {
10043
- continue;
10044
- }
10045
-
10046
- // Don't worry about month overrun; will get "Nisan" for month=14
10047
- const nextMonthName = HDate.getMonthName(month + 1, year);
10048
- add(new MevarchimChodeshEvent(new HDate(29, month, year).onOrBefore(SAT$1), nextMonthName));
10049
10051
  }
10050
10052
 
10051
10053
  // Begin: Yom Kippur Katan
@@ -10148,7 +10150,7 @@ class DailyLearning {
10148
10150
  }
10149
10151
 
10150
10152
  // DO NOT EDIT THIS AUTO-GENERATED FILE!
10151
- const version = '5.0.8';
10153
+ const version = '5.1.0';
10152
10154
 
10153
10155
  var objectGetOwnPropertyDescriptor = {};
10154
10156
 
@@ -11831,12 +11833,14 @@ class HebrewCalendar {
11831
11833
  }
11832
11834
  const prevEventsLength = evts.length;
11833
11835
  const dow = hd.getDay();
11836
+ const isFriday = dow === FRI;
11837
+ const isSaturday = dow === SAT;
11834
11838
  let candlesEv;
11835
11839
  const ev = holidaysYear.get(hd.toString()) || [];
11836
11840
  for (const e of ev) {
11837
- candlesEv = appendHolidayAndRelated(evts, e, options, candlesEv, dow);
11841
+ candlesEv = appendHolidayAndRelated(candlesEv, evts, e, options, isFriday, isSaturday);
11838
11842
  }
11839
- if (options.sedrot && dow === SAT) {
11843
+ if (options.sedrot && isSaturday) {
11840
11844
  const parsha0 = sedra.lookup(abs);
11841
11845
  if (!parsha0.chag) {
11842
11846
  evts.push(new ParshaEvent(hd, parsha0.parsha, il, parsha0.num));
@@ -11867,14 +11871,23 @@ class HebrewCalendar {
11867
11871
  evts.push(omerEv);
11868
11872
  }
11869
11873
  const hmonth = hd.getMonth();
11870
- 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) {
11871
11876
  const monNext = hmonth == HDate.monthsInYear(hyear) ? NISAN : hmonth + 1;
11872
- 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
+ }
11873
11886
  }
11874
- if (!candlesEv && options.candlelighting && (dow == FRI || dow == SAT)) {
11875
- candlesEv = makeCandleEvent(undefined, hd, dow, options);
11876
- if (dow === FRI && candlesEv && sedra) {
11877
- 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);
11878
11891
  }
11879
11892
  }
11880
11893
  // suppress Havdalah when options.havdalahMins=0 or options.havdalahDeg=0
@@ -12110,14 +12123,15 @@ class HebrewCalendar {
12110
12123
  * Appends the Event `ev` to the `events` array. Also may add related
12111
12124
  * timed events like candle-lighting or fast start/end
12112
12125
  * @private
12126
+ * @param {Event} candlesEv
12113
12127
  * @param {Event[]} events
12114
12128
  * @param {Event} ev
12115
12129
  * @param {CalOptions} options
12116
- * @param {Event} candlesEv
12117
- * @param {number} dow
12130
+ * @param {boolean} isFriday
12131
+ * @param {boolean} isSaturday
12118
12132
  * @return {Event}
12119
12133
  */
12120
- function appendHolidayAndRelated(events, ev, options, candlesEv, dow) {
12134
+ function appendHolidayAndRelated(candlesEv, events, ev, options, isFriday, isSaturday) {
12121
12135
  const il = options.il;
12122
12136
  if (!ev.observedIn(il)) {
12123
12137
  return candlesEv; // holiday isn't observed here; bail out early
@@ -12138,9 +12152,9 @@ function appendHolidayAndRelated(events, ev, options, candlesEv, dow) {
12138
12152
  if (eFlags & options.mask || !eFlags && !options.userMask) {
12139
12153
  if (options.candlelighting && eFlags & MASK_LIGHT_CANDLES) {
12140
12154
  const hd = ev.getDate();
12141
- candlesEv = makeCandleEvent(ev, hd, dow, options);
12155
+ candlesEv = makeCandleEvent(ev, hd, options, isFriday, isSaturday);
12142
12156
  if (eFlags & CHANUKAH_CANDLES && candlesEv && !options.noHolidays) {
12143
- const chanukahEv = dow === FRI || dow === SAT ? candlesEv : makeWeekdayChanukahCandleLighting(ev, hd, options);
12157
+ const chanukahEv = isFriday || isSaturday ? candlesEv : makeWeekdayChanukahCandleLighting(ev, hd, options);
12144
12158
  const attrs = {
12145
12159
  eventTime: chanukahEv.eventTime,
12146
12160
  eventTimeStr: chanukahEv.eventTimeStr,
@@ -12150,7 +12164,7 @@ function appendHolidayAndRelated(events, ev, options, candlesEv, dow) {
12150
12164
  if (ev.emoji) attrs.emoji = ev.emoji;
12151
12165
  // Replace Chanukah event with a clone that includes candle lighting time.
12152
12166
  // For clarity, allow a "duplicate" candle lighting event to remain for Shabbat
12153
- ev = new HolidayEvent(ev.getDate(), ev.getDesc(), eFlags, attrs);
12167
+ ev = new HolidayEvent(hd, ev.getDesc(), eFlags, attrs);
12154
12168
  candlesEv = undefined;
12155
12169
  }
12156
12170
  }