@hebcal/core 5.0.6 → 5.0.8

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/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- /*! @hebcal/core v5.0.6 */
1
+ /*! @hebcal/core v5.0.8 */
2
2
  /** @private */
3
3
  const lengths = [0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
4
4
  /** @private */
@@ -1270,7 +1270,8 @@ class HDate {
1270
1270
  render(locale = null, showYear = true) {
1271
1271
  const locale0 = locale || Locale.getLocaleName();
1272
1272
  const day = this.getDate();
1273
- const monthName = Locale.gettext(this.getMonthName(), locale0);
1273
+ const monthName0 = Locale.gettext(this.getMonthName(), locale0);
1274
+ const monthName = monthName0.replace(/'/g, '’');
1274
1275
  const nth = Locale.ordinal(day, locale0);
1275
1276
  const dayOf = HDate.getDayOfTranslation(locale0);
1276
1277
  const dateStr = `${nth}${dayOf} ${monthName}`;
@@ -3704,27 +3705,68 @@ class Zmanim {
3704
3705
  return this.getShaahZmanisBasedZman(4);
3705
3706
  }
3706
3707
  /**
3707
- * Latest Shema (MGA); Sunrise plus 3 halachic hours, according to Magen Avraham
3708
+ * Returns an array with alot (Date) and ms in hour (number)
3709
+ * @private
3710
+ * @return {any[]}
3711
+ */
3712
+ getTemporalHour72() {
3713
+ const alot72 = this.sunriseOffset(-72, false, true);
3714
+ const tzeit72 = this.sunsetOffset(72, false, true);
3715
+ const temporalHour = (tzeit72 - alot72) / 12;
3716
+ return [alot72, temporalHour];
3717
+ }
3718
+ /**
3719
+ * Returns an array with alot (Date) and ms in hour (number)
3720
+ * @private
3721
+ * @return {any[]}
3722
+ */
3723
+ getTemporalHour16Point1() {
3724
+ const alot16one = this.alotHaShachar();
3725
+ const tzeit16one = this.tzeit(16.1);
3726
+ const temporalHour = (tzeit16one - alot16one) / 12;
3727
+ return [alot16one, temporalHour];
3728
+ }
3729
+ /**
3730
+ * Latest Shema (MGA); Sunrise plus 3 halachic hours, according to Magen Avraham.
3731
+ * Based on the opinion of the MGA that the day is calculated from
3732
+ * dawn being fixed 72 minutes before sea-level sunrise, and nightfall is fixed
3733
+ * 72 minutes after sea-level sunset.
3708
3734
  * @return {Date}
3709
3735
  */
3710
3736
  sofZmanShmaMGA() {
3711
3737
  // Magen Avraham
3712
- const alot72 = this.sunriseOffset(-72, false, true);
3713
- const tzeit72 = this.sunsetOffset(72, false, true);
3714
- const temporalHour = (tzeit72 - alot72) / 12; // ms in hour
3738
+ const [alot72, temporalHour] = this.getTemporalHour72();
3715
3739
  return new Date(alot72.getTime() + 3 * temporalHour);
3716
3740
  }
3741
+ /**
3742
+ * Latest Shema (MGA); Sunrise plus 3 halachic hours, according to Magen Avraham.
3743
+ * Based on the opinion of the MGA that the day is calculated from
3744
+ * dawn to nightfall with both being 16.1° below the horizon.
3745
+ * @return {Date}
3746
+ */
3747
+ sofZmanShmaMGA16Point1() {
3748
+ const [alot, temporalHour] = this.getTemporalHour16Point1();
3749
+ return new Date(alot.getTime() + 3 * temporalHour);
3750
+ }
3717
3751
  /**
3718
3752
  * Latest Shacharit (MGA); Sunrise plus 4 halachic hours, according to Magen Avraham
3719
3753
  * @return {Date}
3720
3754
  */
3721
3755
  sofZmanTfillaMGA() {
3722
3756
  // Magen Avraham
3723
- const alot72 = this.sunriseOffset(-72, false, true);
3724
- const tzeit72 = this.sunsetOffset(72, false, true);
3725
- const temporalHour = (tzeit72 - alot72) / 12; // ms in hour
3757
+ const [alot72, temporalHour] = this.getTemporalHour72();
3726
3758
  return new Date(alot72.getTime() + 4 * temporalHour);
3727
3759
  }
3760
+ /**
3761
+ * Latest Shacharit (MGA); Sunrise plus 4 halachic hours, according to Magen Avraham.
3762
+ * Based on the opinion of the MGA that the day is calculated from
3763
+ * dawn to nightfall with both being 16.1° below the horizon.
3764
+ * @return {Date}
3765
+ */
3766
+ sofZmanTfillaMGA16Point1() {
3767
+ const [alot, temporalHour] = this.getTemporalHour16Point1();
3768
+ return new Date(alot.getTime() + 4 * temporalHour);
3769
+ }
3728
3770
  /**
3729
3771
  * Earliest Mincha – Mincha Gedola; Sunrise plus 6.5 halachic hours
3730
3772
  * @return {Date}
@@ -3877,6 +3919,54 @@ class Zmanim {
3877
3919
  }
3878
3920
  }
3879
3921
 
3922
+ const hour12cc = {
3923
+ US: 1,
3924
+ CA: 1,
3925
+ BR: 1,
3926
+ AU: 1,
3927
+ NZ: 1,
3928
+ DO: 1,
3929
+ PR: 1,
3930
+ GR: 1,
3931
+ IN: 1,
3932
+ KR: 1,
3933
+ NP: 1,
3934
+ ZA: 1
3935
+ };
3936
+
3937
+ /**
3938
+ * @private
3939
+ * @param {string} timeStr - original time like "20:30"
3940
+ * @param {string} suffix - "p" or "pm" or " P.M.". Add leading space if you want it
3941
+ * @param {CalOptions} options
3942
+ * @return {string}
3943
+ */
3944
+ function reformatTimeStr(timeStr, suffix, options) {
3945
+ var _options$location;
3946
+ if (typeof timeStr !== 'string') throw new TypeError(`Bad timeStr: ${timeStr}`);
3947
+ const cc = (options === null || options === void 0 || (_options$location = options.location) === null || _options$location === void 0 ? void 0 : _options$location.cc) || (options !== null && options !== void 0 && options.il ? 'IL' : 'US');
3948
+ const hour12 = options === null || options === void 0 ? void 0 : options.hour12;
3949
+ if (typeof hour12 !== 'undefined' && !hour12) {
3950
+ return timeStr;
3951
+ }
3952
+ if (!hour12 && typeof hour12cc[cc] === 'undefined') {
3953
+ return timeStr;
3954
+ }
3955
+ const hm = timeStr.split(':');
3956
+ let hour = parseInt(hm[0], 10);
3957
+ if (hour < 12 && suffix) {
3958
+ suffix = suffix.replace('p', 'a').replace('P', 'A');
3959
+ if (hour === 0) {
3960
+ hour = 12;
3961
+ }
3962
+ } else if (hour > 12) {
3963
+ hour = hour % 12;
3964
+ } else if (hour === 0) {
3965
+ hour = '00';
3966
+ }
3967
+ return `${hour}:${hm[1]}${suffix}`;
3968
+ }
3969
+
3880
3970
  /* eslint-disable max-len */
3881
3971
  const FRI$3 = 5;
3882
3972
  const SAT$3 = 6;
@@ -3886,11 +3976,10 @@ const SAT$3 = 6;
3886
3976
  * @param {Event} e
3887
3977
  * @param {HDate} hd
3888
3978
  * @param {number} dow
3889
- * @param {Location} location
3890
3979
  * @param {CalOptions} options
3891
3980
  * @return {Event}
3892
3981
  */
3893
- function makeCandleEvent(e, hd, dow, location, options) {
3982
+ function makeCandleEvent(e, hd, dow, options) {
3894
3983
  let havdalahTitle = false;
3895
3984
  let useHavdalahOffset = dow === SAT$3;
3896
3985
  let mask = e ? e.getFlags() : flags.LIGHT_CANDLES;
@@ -3910,15 +3999,16 @@ function makeCandleEvent(e, hd, dow, location, options) {
3910
3999
  }
3911
4000
  // if offset is 0 or undefined, we'll use tzeit time
3912
4001
  const offset = useHavdalahOffset ? options.havdalahMins : options.candleLightingMins;
4002
+ const location = options.location;
3913
4003
  const zmanim = new Zmanim(location, hd, options.useElevation);
3914
4004
  const time = offset ? zmanim.sunsetOffset(offset, true) : zmanim.tzeit(options.havdalahDeg);
3915
4005
  if (isNaN(time.getTime())) {
3916
4006
  return null; // no sunset
3917
4007
  }
3918
4008
  if (havdalahTitle) {
3919
- return new HavdalahEvent(hd, mask, time, location, options.havdalahMins, e);
4009
+ return new HavdalahEvent(hd, mask, time, location, options.havdalahMins, e, options);
3920
4010
  } else {
3921
- return new CandleLightingEvent(hd, mask, time, location, e);
4011
+ return new CandleLightingEvent(hd, mask, time, location, e, options);
3922
4012
  }
3923
4013
  }
3924
4014
 
@@ -3931,13 +4021,18 @@ class TimedEvent extends Event {
3931
4021
  * @param {Date} eventTime
3932
4022
  * @param {Location} location
3933
4023
  * @param {Event} linkedEvent
4024
+ * @param {CalOptions} options
3934
4025
  */
3935
- constructor(date, desc, mask, eventTime, location, linkedEvent) {
4026
+ constructor(date, desc, mask, eventTime, location, linkedEvent, options) {
3936
4027
  super(date, desc, mask);
3937
4028
  this.eventTime = Zmanim.roundTime(eventTime);
3938
4029
  this.location = location;
3939
4030
  const timeFormat = location.getTimeFormatter();
3940
4031
  this.eventTimeStr = Zmanim.formatTime(this.eventTime, timeFormat);
4032
+ const opts = Object.assign({
4033
+ location
4034
+ }, options);
4035
+ this.fmtTime = reformatTimeStr(this.eventTimeStr, 'pm', opts);
3941
4036
  if (typeof linkedEvent !== 'undefined') {
3942
4037
  this.linkedEvent = linkedEvent;
3943
4038
  }
@@ -3947,7 +4042,7 @@ class TimedEvent extends Event {
3947
4042
  * @return {string}
3948
4043
  */
3949
4044
  render(locale) {
3950
- return Locale.gettext(this.getDesc(), locale) + ': ' + this.eventTimeStr;
4045
+ return Locale.gettext(this.getDesc(), locale) + ': ' + this.fmtTime;
3951
4046
  }
3952
4047
  /**
3953
4048
  * Returns translation of "Candle lighting" without the time.
@@ -3984,9 +4079,10 @@ class HavdalahEvent extends TimedEvent {
3984
4079
  * @param {Location} location
3985
4080
  * @param {number} havdalahMins
3986
4081
  * @param {Event} linkedEvent
4082
+ * @param {CalOptions} options
3987
4083
  */
3988
- constructor(date, mask, eventTime, location, havdalahMins, linkedEvent) {
3989
- super(date, 'Havdalah', mask, eventTime, location, linkedEvent);
4084
+ constructor(date, mask, eventTime, location, havdalahMins, linkedEvent, options) {
4085
+ super(date, 'Havdalah', mask, eventTime, location, linkedEvent, options);
3990
4086
  if (havdalahMins) {
3991
4087
  this.havdalahMins = havdalahMins;
3992
4088
  }
@@ -3996,7 +4092,7 @@ class HavdalahEvent extends TimedEvent {
3996
4092
  * @return {string}
3997
4093
  */
3998
4094
  render(locale) {
3999
- return this.renderBrief(locale) + ': ' + this.eventTimeStr;
4095
+ return this.renderBrief(locale) + ': ' + this.fmtTime;
4000
4096
  }
4001
4097
  /**
4002
4098
  * Returns translation of "Havdalah" without the time.
@@ -4025,9 +4121,10 @@ class CandleLightingEvent extends TimedEvent {
4025
4121
  * @param {Date} eventTime
4026
4122
  * @param {Location} location
4027
4123
  * @param {Event} linkedEvent
4124
+ * @param {CalOptions} options
4028
4125
  */
4029
- constructor(date, mask, eventTime, location, linkedEvent) {
4030
- super(date, 'Candle lighting', mask, eventTime, location, linkedEvent);
4126
+ constructor(date, mask, eventTime, location, linkedEvent, options) {
4127
+ super(date, 'Candle lighting', mask, eventTime, location, linkedEvent, options);
4031
4128
  }
4032
4129
  /** @return {string} */
4033
4130
  getEmoji() {
@@ -4055,14 +4152,14 @@ function makeFastStartEnd(ev, options) {
4055
4152
  const zmanim = new Zmanim(location, dt, options.useElevation);
4056
4153
  if (desc === 'Erev Tish\'a B\'Av') {
4057
4154
  const sunset = zmanim.sunset();
4058
- ev.startEvent = makeTimedEvent(hd, sunset, 'Fast begins', ev, location);
4155
+ ev.startEvent = makeTimedEvent(hd, sunset, 'Fast begins', ev, options);
4059
4156
  } else if (desc.startsWith('Tish\'a B\'Av')) {
4060
- ev.endEvent = makeTimedEvent(hd, zmanim.tzeit(fastEndDeg), 'Fast ends', ev, location);
4157
+ ev.endEvent = makeTimedEvent(hd, zmanim.tzeit(fastEndDeg), 'Fast ends', ev, options);
4061
4158
  } else {
4062
4159
  const dawn = zmanim.alotHaShachar();
4063
- ev.startEvent = makeTimedEvent(hd, dawn, 'Fast begins', ev, location);
4160
+ ev.startEvent = makeTimedEvent(hd, dawn, 'Fast begins', ev, options);
4064
4161
  if (dt.getDay() !== 5 && !(hd.getDate() === 14 && hd.getMonth() === months.NISAN)) {
4065
- ev.endEvent = makeTimedEvent(hd, zmanim.tzeit(fastEndDeg), 'Fast ends', ev, location);
4162
+ ev.endEvent = makeTimedEvent(hd, zmanim.tzeit(fastEndDeg), 'Fast ends', ev, options);
4066
4163
  }
4067
4164
  }
4068
4165
  return ev;
@@ -4074,14 +4171,15 @@ function makeFastStartEnd(ev, options) {
4074
4171
  * @param {Date} time
4075
4172
  * @param {string} desc
4076
4173
  * @param {Event} ev
4077
- * @param {Location} location
4174
+ * @param {CalOptions} options
4078
4175
  * @return {TimedEvent}
4079
4176
  */
4080
- function makeTimedEvent(hd, time, desc, ev, location) {
4177
+ function makeTimedEvent(hd, time, desc, ev, options) {
4081
4178
  if (isNaN(time.getTime())) {
4082
4179
  return null;
4083
4180
  }
4084
- return new TimedEvent(hd, desc, ev.getFlags(), time, location, ev);
4181
+ const location = options.location;
4182
+ return new TimedEvent(hd, desc, ev.getFlags(), time, location, ev, options);
4085
4183
  }
4086
4184
 
4087
4185
  /**
@@ -4097,7 +4195,7 @@ function makeWeekdayChanukahCandleLighting(ev, hd, options) {
4097
4195
  const zmanim = new Zmanim(location, hd.greg(), options.useElevation);
4098
4196
  const candleLightingTime = zmanim.dusk();
4099
4197
  // const candleLightingTime = zmanim.tzeit(4.6667);
4100
- return makeTimedEvent(hd, candleLightingTime, ev.getDesc(), ev, location);
4198
+ return makeTimedEvent(hd, candleLightingTime, ev.getDesc(), ev, options);
4101
4199
  }
4102
4200
 
4103
4201
  /* eslint-disable camelcase */
@@ -4185,6 +4283,34 @@ class Molad {
4185
4283
  getChalakim() {
4186
4284
  return this.chalakim;
4187
4285
  }
4286
+ /**
4287
+ * @param {string} [locale] Optional locale name (defaults to active locale)
4288
+ * @param {CalOptions} options
4289
+ * @return {string}
4290
+ */
4291
+ render(locale, options) {
4292
+ locale = locale || Locale.getLocaleName();
4293
+ if (typeof locale === 'string') {
4294
+ locale = locale.toLowerCase();
4295
+ }
4296
+ const isHebrewLocale = locale === 'he' || locale === 'he-x-nonikud' || locale === 'h';
4297
+ const monthName = Locale.gettext(this.getMonthName(), locale);
4298
+ const dayNames = isHebrewLocale ? heDayNames : shortDayNames;
4299
+ const dow = dayNames[this.getDow()];
4300
+ const minutes = this.getMinutes();
4301
+ const hour = this.getHour();
4302
+ const chalakim = this.getChalakim();
4303
+ const moladStr = Locale.gettext('Molad', locale);
4304
+ const minutesStr = Locale.lookupTranslation('min', locale) || 'minutes';
4305
+ const chalakimStr = Locale.gettext('chalakim', locale);
4306
+ if (isHebrewLocale) {
4307
+ const ampm = hour < 5 ? night : hour < 12 ? morning : hour < 17 ? afternoon : hour < 21 ? evening : night;
4308
+ return `${moladStr} ${monthName} יִהְיֶה בַּיּוֹם ${dow} בשָׁבוּעַ, ` + `בְּשָׁעָה ${hour} ${ampm}, ` + `ו-${minutes} ${minutesStr} ` + `ו-${chalakim} ${chalakimStr}`;
4309
+ }
4310
+ const fmtTime = reformatTimeStr(`${hour}:00`, 'pm', options);
4311
+ const month = monthName.replace(/'/g, '’');
4312
+ return `${moladStr} ${month}: ${dow}, ${minutes} ${minutesStr} and ${chalakim} ${chalakimStr} after ${fmtTime}`;
4313
+ }
4188
4314
  }
4189
4315
 
4190
4316
  /** Represents a Molad announcement on Shabbat Mevarchim */
@@ -4193,38 +4319,21 @@ class MoladEvent extends Event {
4193
4319
  * @param {HDate} date Hebrew date event occurs
4194
4320
  * @param {number} hyear molad year
4195
4321
  * @param {number} hmonth molad month
4322
+ * @param {CalOptions} options
4196
4323
  */
4197
- constructor(date, hyear, hmonth) {
4324
+ constructor(date, hyear, hmonth, options) {
4198
4325
  const m = new Molad(hyear, hmonth);
4199
4326
  const monthName = m.getMonthName();
4200
4327
  super(date, `Molad ${monthName} ${hyear}`, flags.MOLAD);
4201
4328
  this.molad = m;
4329
+ this.options = options;
4202
4330
  }
4203
4331
  /**
4204
4332
  * @param {string} [locale] Optional locale name (defaults to active locale).
4205
4333
  * @return {string}
4206
4334
  */
4207
4335
  render(locale) {
4208
- const m = this.molad;
4209
- locale = locale || Locale.getLocaleName();
4210
- if (typeof locale === 'string') {
4211
- locale = locale.toLowerCase();
4212
- }
4213
- const isHebrewLocale = locale === 'he' || locale === 'he-x-nonikud' || locale === 'h';
4214
- const monthName = Locale.gettext(m.getMonthName(), locale);
4215
- const dayNames = isHebrewLocale ? heDayNames : shortDayNames;
4216
- const dow = dayNames[m.getDow()];
4217
- const minutes = m.getMinutes();
4218
- const hour = m.getHour();
4219
- const chalakim = m.getChalakim();
4220
- const moladStr = Locale.gettext('Molad', locale);
4221
- const minutesStr = Locale.lookupTranslation('min', locale) || 'minutes';
4222
- const chalakimStr = Locale.gettext('chalakim', locale);
4223
- if (isHebrewLocale) {
4224
- const ampm = hour < 5 ? night : hour < 12 ? morning : hour < 17 ? afternoon : hour < 21 ? evening : night;
4225
- return `${moladStr} ${monthName} יִהְיֶה בַּיּוֹם ${dow} בשָׁבוּעַ, ` + `בְּשָׁעָה ${hour} ${ampm}, ` + `ו-${minutes} ${minutesStr} ` + `ו-${chalakim} ${chalakimStr}`;
4226
- }
4227
- return `${moladStr} ${monthName}: ${dow}, ${minutes} ${minutesStr} and ${chalakim} ${chalakimStr} after ${hour}:00`;
4336
+ return this.molad.render(locale, this.options);
4228
4337
  }
4229
4338
  }
4230
4339
 
@@ -5748,6 +5857,26 @@ class HolidayEvent extends Event {
5748
5857
  return ['holiday', 'major'];
5749
5858
  }
5750
5859
  }
5860
+ /**
5861
+ * Returns (translated) description of this event
5862
+ * @param {string} [locale] Optional locale name (defaults to active locale).
5863
+ * @return {string}
5864
+ */
5865
+ render(locale) {
5866
+ const str = super.render(locale);
5867
+ return str.replace(/'/g, '’');
5868
+ }
5869
+ /**
5870
+ * Returns a brief (translated) description of this event.
5871
+ * For most events, this is the same as render(). For some events, it procudes
5872
+ * a shorter text (e.g. without a time or added description).
5873
+ * @param {string} [locale] Optional locale name (defaults to active locale).
5874
+ * @return {string}
5875
+ */
5876
+ renderBrief(locale) {
5877
+ const str = super.renderBrief(locale);
5878
+ return str.replace(/'/g, '’');
5879
+ }
5751
5880
  }
5752
5881
  const roshChodeshStr = 'Rosh Chodesh';
5753
5882
 
@@ -5768,7 +5897,9 @@ class RoshChodeshEvent extends HolidayEvent {
5768
5897
  */
5769
5898
  render(locale) {
5770
5899
  const monthName = this.getDesc().substring(roshChodeshStr.length + 1);
5771
- return Locale.gettext(roshChodeshStr, locale) + ' ' + Locale.gettext(monthName, locale);
5900
+ const monthName0 = Locale.gettext(monthName, locale);
5901
+ const monthName1 = monthName0.replace(/'/g, '’');
5902
+ return Locale.gettext(roshChodeshStr, locale) + ' ' + monthName1;
5772
5903
  }
5773
5904
  /** @return {string} */
5774
5905
  basename() {
@@ -5807,8 +5938,10 @@ class MevarchimChodeshEvent extends Event {
5807
5938
  const hyear = date.getFullYear();
5808
5939
  const hmonth = date.getMonth();
5809
5940
  const monNext = hmonth == HDate.monthsInYear(hyear) ? NISAN$1 : hmonth + 1;
5810
- const molad = new MoladEvent(date, hyear, monNext);
5811
- this.memo = molad.render('en');
5941
+ const molad = new Molad(hyear, monNext);
5942
+ this.memo = molad.render('en', {
5943
+ hour12: false
5944
+ });
5812
5945
  }
5813
5946
  /** @return {string} */
5814
5947
  basename() {
@@ -5820,7 +5953,19 @@ class MevarchimChodeshEvent extends Event {
5820
5953
  * @return {string}
5821
5954
  */
5822
5955
  render(locale) {
5823
- return Locale.gettext(mevarchimChodeshStr, locale) + ' ' + Locale.gettext(this.monthName, locale);
5956
+ const monthName0 = Locale.gettext(this.monthName, locale);
5957
+ const monthName = monthName0.replace(/'/g, '’');
5958
+ return Locale.gettext(mevarchimChodeshStr, locale) + ' ' + monthName;
5959
+ }
5960
+ /**
5961
+ * Returns (translated) description of this event
5962
+ * @param {string} [locale] Optional locale name (defaults to active locale).
5963
+ * @return {string}
5964
+ */
5965
+ renderBrief(locale) {
5966
+ const str = this.render(locale);
5967
+ const space = str.indexOf(' ');
5968
+ return str.substring(space + 1);
5824
5969
  }
5825
5970
  }
5826
5971
 
@@ -5872,7 +6017,9 @@ class YomKippurKatanEvent extends HolidayEvent {
5872
6017
  * @return {string}
5873
6018
  */
5874
6019
  render(locale) {
5875
- return Locale.gettext(ykk, locale) + ' ' + Locale.gettext(this.nextMonthName, locale);
6020
+ const monthName0 = Locale.gettext(this.nextMonthName, locale);
6021
+ const monthName = monthName0.replace(/'/g, '’');
6022
+ return Locale.gettext(ykk, locale) + ' ' + monthName;
5876
6023
  }
5877
6024
  /**
5878
6025
  * @param {string} [locale] Optional locale name (defaults to active locale).
@@ -6162,7 +6309,7 @@ class DailyLearning {
6162
6309
  }
6163
6310
 
6164
6311
  // DO NOT EDIT THIS AUTO-GENERATED FILE!
6165
- const version = '5.0.6';
6312
+ const version = '5.0.8';
6166
6313
 
6167
6314
  const NONE$1 = 0;
6168
6315
  const HALF = 1;
@@ -6213,7 +6360,7 @@ var poAshkenazi = {
6213
6360
  "Shabbat": ["Shabbos"],
6214
6361
  "Achrei Mot": ["Achrei Mos"],
6215
6362
  "Bechukotai": ["Bechukosai"],
6216
- "Beha'alotcha": ["Beha'aloscha"],
6363
+ "Beha'alotcha": ["Behaaloscha"],
6217
6364
  "Bereshit": ["Bereshis"],
6218
6365
  "Chukat": ["Chukas"],
6219
6366
  "Erev Shavuot": ["Erev Shavuos"],
@@ -6240,14 +6387,14 @@ var poAshkenazi = {
6240
6387
  "Sukkot": ["Sukkos"],
6241
6388
  "Sukkot I": ["Sukkos I"],
6242
6389
  "Sukkot II": ["Sukkos II"],
6243
- "Sukkot II (CH''M)": ["Sukkos II (CH''M)"],
6244
- "Sukkot III (CH''M)": ["Sukkos III (CH''M)"],
6245
- "Sukkot IV (CH''M)": ["Sukkos IV (CH''M)"],
6246
- "Sukkot V (CH''M)": ["Sukkos V (CH''M)"],
6247
- "Sukkot VI (CH''M)": ["Sukkos VI (CH''M)"],
6390
+ "Sukkot II (CH''M)": ["Sukkos II (CH’’M)"],
6391
+ "Sukkot III (CH''M)": ["Sukkos III (CH’’M)"],
6392
+ "Sukkot IV (CH''M)": ["Sukkos IV (CH’’M)"],
6393
+ "Sukkot V (CH''M)": ["Sukkos V (CH’’M)"],
6394
+ "Sukkot VI (CH''M)": ["Sukkos VI (CH’’M)"],
6248
6395
  "Sukkot VII (Hoshana Raba)": ["Sukkos VII (Hoshana Raba)"],
6249
- "Ta'anit Bechorot": ["Ta'anis Bechoros"],
6250
- "Ta'anit Esther": ["Ta'anis Esther"],
6396
+ "Ta'anit Bechorot": ["Taanis Bechoros"],
6397
+ "Ta'anit Esther": ["Taanis Esther"],
6251
6398
  "Toldot": ["Toldos"],
6252
6399
  "Vaetchanan": ["Vaeschanan"],
6253
6400
  "Yitro": ["Yisro"],
@@ -6257,7 +6404,7 @@ var poAshkenazi = {
6257
6404
  "Shabbat Mevarchim Chodesh": ["Shabbos Mevorchim Chodesh"],
6258
6405
  "Shabbat Shirah": ["Shabbos Shirah"],
6259
6406
  "Tevet": ["Teves"],
6260
- "Asara B'Tevet": ["Asara B'Teves"],
6407
+ "Asara B'Tevet": ["Asara BTeves"],
6261
6408
  "Alot HaShachar": ["Alos HaShachar"],
6262
6409
  "Kriat Shema, sof zeman": ["Krias Shema, sof zman"],
6263
6410
  "Tefilah, sof zeman": ["Tefilah, sof zman"],
@@ -7116,20 +7263,6 @@ function getMaskFromOptions(options) {
7116
7263
  }
7117
7264
  const MASK_LIGHT_CANDLES = LIGHT_CANDLES | LIGHT_CANDLES_TZEIS | CHANUKAH_CANDLES | YOM_TOV_ENDS;
7118
7265
  const defaultLocation = new Location(0, 0, false, 'UTC');
7119
- const hour12cc = {
7120
- US: 1,
7121
- CA: 1,
7122
- BR: 1,
7123
- AU: 1,
7124
- NZ: 1,
7125
- DO: 1,
7126
- PR: 1,
7127
- GR: 1,
7128
- IN: 1,
7129
- KR: 1,
7130
- NP: 1,
7131
- ZA: 1
7132
- };
7133
7266
 
7134
7267
  /**
7135
7268
  * @private
@@ -7384,10 +7517,10 @@ class HebrewCalendar {
7384
7517
  const hmonth = hd.getMonth();
7385
7518
  if (options.molad && dow == SAT && hmonth != ELUL && hd.getDate() >= 23 && hd.getDate() <= 29) {
7386
7519
  const monNext = hmonth == HDate.monthsInYear(hyear) ? NISAN : hmonth + 1;
7387
- evts.push(new MoladEvent(hd, hyear, monNext));
7520
+ evts.push(new MoladEvent(hd, hyear, monNext, options));
7388
7521
  }
7389
7522
  if (!candlesEv && options.candlelighting && (dow == FRI || dow == SAT)) {
7390
- candlesEv = makeCandleEvent(undefined, hd, dow, location, options);
7523
+ candlesEv = makeCandleEvent(undefined, hd, dow, options);
7391
7524
  if (dow === FRI && candlesEv && sedra) {
7392
7525
  candlesEv.memo = sedra.getString(abs);
7393
7526
  }
@@ -7554,28 +7687,7 @@ class HebrewCalendar {
7554
7687
  * @return {string}
7555
7688
  */
7556
7689
  static reformatTimeStr(timeStr, suffix, options) {
7557
- var _options$location2;
7558
- if (typeof timeStr !== 'string') throw new TypeError(`Bad timeStr: ${timeStr}`);
7559
- const cc = ((_options$location2 = options.location) === null || _options$location2 === void 0 ? void 0 : _options$location2.cc) || (options.il ? 'IL' : 'US');
7560
- if (typeof options.hour12 !== 'undefined' && !options.hour12) {
7561
- return timeStr;
7562
- }
7563
- if (!options.hour12 && typeof hour12cc[cc] === 'undefined') {
7564
- return timeStr;
7565
- }
7566
- const hm = timeStr.split(':');
7567
- let hour = parseInt(hm[0], 10);
7568
- if (hour < 12 && suffix) {
7569
- suffix = suffix.replace('p', 'a').replace('P', 'A');
7570
- if (hour === 0) {
7571
- hour = 12;
7572
- }
7573
- } else if (hour > 12) {
7574
- hour = hour % 12;
7575
- } else if (hour === 0) {
7576
- hour = '00';
7577
- }
7578
- return `${hour}:${hm[1]}${suffix}`;
7690
+ return reformatTimeStr(timeStr, suffix, options);
7579
7691
  }
7580
7692
 
7581
7693
  /** @return {string} */
@@ -7674,7 +7786,7 @@ function appendHolidayAndRelated(events, ev, options, candlesEv, dow) {
7674
7786
  if (eFlags & options.mask || !eFlags && !options.userMask) {
7675
7787
  if (options.candlelighting && eFlags & MASK_LIGHT_CANDLES) {
7676
7788
  const hd = ev.getDate();
7677
- candlesEv = makeCandleEvent(ev, hd, dow, location, options);
7789
+ candlesEv = makeCandleEvent(ev, hd, dow, options);
7678
7790
  if (eFlags & CHANUKAH_CANDLES && candlesEv && !options.noHolidays) {
7679
7791
  const chanukahEv = dow === FRI || dow === SAT ? candlesEv : makeWeekdayChanukahCandleLighting(ev, hd, options);
7680
7792
  const attrs = {
package/hebcal.d.ts CHANGED
@@ -28,7 +28,7 @@ declare module '@hebcal/core' {
28
28
  observedIn(il: boolean): boolean;
29
29
  clone(): Event;
30
30
  getCategories(): string[];
31
- readonly date: Date;
31
+ readonly date: HDate;
32
32
  readonly desc: string;
33
33
  readonly mask: number;
34
34
  readonly emoji?: string;
@@ -365,8 +365,13 @@ declare module '@hebcal/core' {
365
365
  * @param gloc GeoLocation including latitude, longitude, and timezone
366
366
  * @param date Regular or Hebrew Date. If `date` is a regular `Date`,
367
367
  * hours, minutes, seconds and milliseconds are ignored
368
+ * @param useElevation use elevation for calculations (default `false`).
369
+ * If `true`, use elevation to affect the calculation of all sunrise/sunset based
370
+ * zmanim. Note: there are some zmanim such as degree-based zmanim that are driven
371
+ * by the amount of light in the sky and are not impacted by elevation.
372
+ * These zmanim intentionally do not support elevation adjustment.
368
373
  */
369
- constructor(gloc: GeoLocation, date: Date | HDate);
374
+ constructor(gloc: GeoLocation, date: Date | HDate, useElevation?: boolean);
370
375
 
371
376
  /**
372
377
  * Returns a string like "2022-04-01T13:06:00-11:00"
@@ -414,11 +419,28 @@ declare module '@hebcal/core' {
414
419
  sofZmanShma(): Date;
415
420
  /** Latest Shacharit (Gra); Sunrise plus 4 halachic hours, according to the Gra */
416
421
  sofZmanTfilla(): Date;
417
- /** Latest Shema (MGA); Sunrise plus 3 halachic hours, according to Magen Avraham */
422
+ /**
423
+ * Latest Shema (MGA); Sunrise plus 3 halachic hours, according to Magen Avraham.
424
+ * Based on the opinion of the MGA that the day is calculated from
425
+ * dawn being fixed 72 minutes before sea-level sunrise, and nightfall is fixed
426
+ * 72 minutes after sea-level sunset.
427
+ */
418
428
  sofZmanShmaMGA(): Date;
429
+ /**
430
+ * Latest Shema (MGA); Sunrise plus 3 halachic hours, according to Magen Avraham.
431
+ * Based on the opinion of the MGA that the day is calculated from
432
+ * dawn to nightfall with both being 16.1° below the horizon.
433
+ */
434
+ sofZmanShmaMGA16Point1(): Date;
419
435
  /** Latest Shacharit (MGA); Sunrise plus 4 halachic hours, according to Magen Avraham */
420
436
  sofZmanTfillaMGA(): Date;
421
437
  /** Earliest Mincha – Mincha Gedola; Sunrise plus 6.5 halachic hours */
438
+ /**
439
+ * Latest Shacharit (MGA); Sunrise plus 4 halachic hours, according to Magen Avraham.
440
+ * Based on the opinion of the MGA that the day is calculated from
441
+ * dawn to nightfall with both being 16.1° below the horizon.
442
+ */
443
+ sofZmanTfillaMGA16Point1(): Date;
422
444
  minchaGedola(): Date;
423
445
  /** Preferable earliest time to recite Minchah – Mincha Ketana; Sunrise plus 9.5 halachic hours */
424
446
  minchaKetana(): Date;
@@ -814,6 +836,7 @@ declare module '@hebcal/core' {
814
836
  * @return parts of a minute (0-17)
815
837
  */
816
838
  getChalakim(): number;
839
+ render(locale?: string, options?: CalOptions): string;
817
840
  }
818
841
 
819
842
  /**
@@ -989,7 +1012,7 @@ declare module '@hebcal/core' {
989
1012
  * @param desc - Description (not translated)
990
1013
  */
991
1014
  export class TimedEvent extends Event {
992
- constructor(date: HDate, desc: string, mask: number, eventTime: Date, location: Location, linkedEvent?: Event);
1015
+ constructor(date: HDate, desc: string, mask: number, eventTime: Date, location: Location, linkedEvent?: Event, options?: CalOptions);
993
1016
  render(locale?: string): string;
994
1017
  renderBrief(locale?: string): string;
995
1018
  getCategories(): string[];
@@ -999,11 +1022,11 @@ declare module '@hebcal/core' {
999
1022
  readonly linkedEvent?: Event;
1000
1023
  }
1001
1024
  export class CandleLightingEvent extends TimedEvent {
1002
- constructor(date: HDate, mask: number, eventTime: Date, location: Location, linkedEvent?: Event);
1025
+ constructor(date: HDate, mask: number, eventTime: Date, location: Location, linkedEvent?: Event, options?: CalOptions);
1003
1026
  getEmoji(): string;
1004
1027
  }
1005
1028
  export class HavdalahEvent extends TimedEvent {
1006
- constructor(date: HDate, mask: number, eventTime: Date, location: Location, havdalahMins?: number, linkedEvent?: Event);
1029
+ constructor(date: HDate, mask: number, eventTime: Date, location: Location, havdalahMins?: number, linkedEvent?: Event, options?: CalOptions);
1007
1030
  render(locale?: string): string;
1008
1031
  renderBrief(locale?: string): string;
1009
1032
  getEmoji(): string;
@@ -1044,7 +1067,7 @@ declare module '@hebcal/core' {
1044
1067
  readonly monthName: string;
1045
1068
  }
1046
1069
  export class MoladEvent extends Event {
1047
- constructor(date: HDate, hyear: number, hmonth: number);
1070
+ constructor(date: HDate, hyear: number, hmonth: number, options?: CalOptions);
1048
1071
  render(locale?: string): string;
1049
1072
  renderBrief(locale?: string): string;
1050
1073
  readonly molad: Molad;