@hebcal/rest-api 4.3.5 → 4.3.7

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/rest-api v4.3.5 */
1
+ /*! @hebcal/rest-api v4.3.7 */
2
2
  import { flags, HDate, HebrewCalendar, Zmanim, Locale, gematriya } from '@hebcal/core';
3
3
  import { getLeyningForParshaHaShavua, getLeyningForHoliday, formatAliyahWithBook } from '@hebcal/leyning';
4
4
  import { getTriennialForParshaHaShavua } from '@hebcal/triennial';
@@ -11,7 +11,6 @@ const AD="Andorra";const AE="United Arab Emirates";const AF="Afghanistan";const
11
11
  * @param {Location} location
12
12
  * @return {string}
13
13
  */
14
-
15
14
  function locationToPlainObj(location) {
16
15
  if (typeof location === 'object' && location !== null && typeof location.name === 'string') {
17
16
  const o = {
@@ -35,6 +34,7 @@ function locationToPlainObj(location) {
35
34
  };
36
35
  }
37
36
  }
37
+
38
38
  /**
39
39
  * Helper function to transform a string to make it more usable in a URL or filename.
40
40
  * Converts to lowercase and replaces non-word characters with hyphen ('-').
@@ -43,25 +43,21 @@ function locationToPlainObj(location) {
43
43
  * @param {string} s
44
44
  * @return {string}
45
45
  */
46
-
47
46
  function makeAnchor(s) {
48
47
  return s.toLowerCase().replace(/'/g, '').replace(/[^\w]/g, '-').replace(/-+/g, '-').replace(/^-/g, '').replace(/-$/g, '');
49
48
  }
49
+
50
50
  /**
51
51
  * @param {CalOptions} options
52
52
  * @return {string}
53
53
  */
54
-
55
54
  function getDownloadFilename(options) {
56
55
  let fileName = 'hebcal';
57
-
58
56
  if (options.year) {
59
57
  fileName += '_' + options.year;
60
-
61
58
  if (options.isHebrewYear) {
62
59
  fileName += 'h';
63
60
  }
64
-
65
61
  if (options.month) {
66
62
  fileName += '_' + options.month;
67
63
  }
@@ -70,42 +66,37 @@ function getDownloadFilename(options) {
70
66
  const end = new HDate(options.end);
71
67
  const y1 = start.greg().getFullYear();
72
68
  const y2 = end.greg().getFullYear();
73
-
74
69
  if (y1 === y2) {
75
70
  fileName += '_' + y1;
76
71
  } else {
77
72
  fileName += '_' + y1 + '_' + y2;
78
73
  }
79
74
  }
80
-
81
75
  if (typeof options.location === 'object') {
82
76
  const loc = options.location;
83
77
  const name = loc.zip || loc.asciiname || loc.getShortName();
84
-
85
78
  if (name) {
86
79
  fileName += '_' + makeAnchor(name).replace(/[-]/g, '_');
87
80
  }
88
81
  }
89
-
90
82
  return fileName;
91
83
  }
84
+
92
85
  /**
93
86
  * @param {number} number
94
87
  * @return {string}
95
88
  */
96
-
97
89
  function pad2(number) {
98
90
  if (number < 10) {
99
91
  return '0' + number;
100
92
  }
101
-
102
93
  return '' + number;
103
94
  }
95
+
104
96
  /**
105
97
  * @param {number} number
106
98
  * @return {string}
107
99
  */
108
-
109
100
  function pad4(number) {
110
101
  if (number < 0) {
111
102
  return '-00' + pad4(-number);
@@ -116,59 +107,51 @@ function pad4(number) {
116
107
  } else if (number < 1000) {
117
108
  return '0' + number;
118
109
  }
119
-
120
110
  return '' + number;
121
111
  }
112
+
122
113
  /**
123
114
  * Returns just the date portion as YYYY-MM-DD
124
115
  * @param {Date} d
125
116
  * @return {string}
126
117
  */
127
-
128
118
  function toISOString(d) {
129
119
  return pad4(d.getFullYear()) + '-' + pad2(d.getMonth() + 1) + '-' + pad2(d.getDate());
130
120
  }
131
- const flagToCategory = [[flags.MAJOR_FAST, 'holiday', 'major', 'fast'], [flags.CHANUKAH_CANDLES, 'holiday', 'major'], [flags.DAF_YOMI, 'dafyomi'], [flags.HEBREW_DATE, 'hebdate'], [flags.MINOR_FAST, 'holiday', 'fast'], [flags.MINOR_HOLIDAY, 'holiday', 'minor'], [flags.MISHNA_YOMI, 'mishnayomi'], [flags.MODERN_HOLIDAY, 'holiday', 'modern'], [flags.MOLAD, 'molad'], [flags.OMER_COUNT, 'omer'], [flags.PARSHA_HASHAVUA, 'parashat'], // backwards-compat
121
+ const flagToCategory = [[flags.MAJOR_FAST, 'holiday', 'major', 'fast'], [flags.CHANUKAH_CANDLES, 'holiday', 'major'], [flags.DAF_YOMI, 'dafyomi'], [flags.HEBREW_DATE, 'hebdate'], [flags.MINOR_FAST, 'holiday', 'fast'], [flags.MINOR_HOLIDAY, 'holiday', 'minor'], [flags.MISHNA_YOMI, 'mishnayomi'], [flags.YERUSHALMI_YOMI, 'yerushalmi'], [flags.MODERN_HOLIDAY, 'holiday', 'modern'], [flags.MOLAD, 'molad'], [flags.OMER_COUNT, 'omer'], [flags.PARSHA_HASHAVUA, 'parashat'],
122
+ // backwards-compat
132
123
  [flags.ROSH_CHODESH, 'roshchodesh'], [flags.SHABBAT_MEVARCHIM, 'mevarchim'], [flags.SPECIAL_SHABBAT, 'holiday', 'shabbat'], [flags.USER_EVENT, 'user']];
124
+
133
125
  /**
134
126
  * Returns a category and subcategory name
135
127
  * @param {Event} ev
136
128
  * @return {string[]}
137
129
  */
138
-
139
130
  function getEventCategories(ev) {
140
131
  const desc = ev.getDesc();
141
-
142
132
  switch (desc) {
143
133
  // LIGHT_CANDLES or LIGHT_CANDLES_TZEIS
144
134
  case 'Candle lighting':
145
135
  return ['candles'];
146
136
  // YOM_TOV_ENDS
147
-
148
137
  case 'Havdalah':
149
138
  return ['havdalah'];
150
139
  // flags.MINOR_FAST or flags.MAJOR_FAST
151
-
152
140
  case 'Fast begins':
153
141
  case 'Fast ends':
154
142
  return ['zmanim', 'fast'];
155
143
  }
156
-
157
144
  if (ev.cholHaMoedDay) {
158
145
  return ['holiday', 'major', 'cholhamoed'];
159
146
  }
160
-
161
147
  const mask = ev.getFlags();
162
-
163
148
  for (let i = 0; i < flagToCategory.length; i++) {
164
149
  const attrs = flagToCategory[i];
165
-
166
150
  if (mask & attrs[0]) {
167
151
  return attrs.slice(1);
168
152
  }
169
- } // Don't depend on flags.MINOR_HOLIDAY always being set
170
-
171
-
153
+ }
154
+ // Don't depend on flags.MINOR_HOLIDAY always being set
172
155
  switch (desc) {
173
156
  case 'Lag BaOmer':
174
157
  case 'Leil Selichot':
@@ -180,31 +163,29 @@ function getEventCategories(ev) {
180
163
  case 'Tu BiShvat':
181
164
  case 'Rosh Hashana LaBehemot':
182
165
  return ['holiday', 'minor'];
183
-
184
166
  default:
185
167
  return ['holiday', 'major'];
186
168
  }
187
169
  }
170
+
188
171
  /**
189
172
  * Renders the event title in default locale, but strips off time
190
173
  * @param {Event} ev
191
174
  * @return {string}
192
175
  */
193
-
194
176
  function renderTitleWithoutTime(ev) {
195
177
  return typeof ev.eventTime === 'undefined' ? ev.render() : ev.renderBrief();
196
178
  }
179
+
197
180
  /**
198
181
  * Generates a title like "Hebcal 2020 Israel" or "Hebcal May 1993 Providence"
199
182
  * @param {Event[]} events
200
183
  * @param {CalOptions} options
201
184
  * @return {string}
202
185
  */
203
-
204
186
  function getCalendarTitle(events, options) {
205
187
  let title = 'Hebcal';
206
188
  const location = options.location;
207
-
208
189
  if (options.yahrzeit) {
209
190
  title += ' Yahrzeits and Anniversaries';
210
191
  } else if (location && location.name) {
@@ -216,17 +197,14 @@ function getCalendarTitle(events, options) {
216
197
  } else {
217
198
  title += ' Diaspora';
218
199
  }
219
-
220
200
  if (options.subscribe == '1') {
221
201
  return title;
222
202
  }
223
-
224
203
  if (options.year && (options.isHebrewYear || events.length == 0)) {
225
204
  title += ' ' + options.year;
226
205
  } else if (events.length) {
227
206
  const start = events[0].getDate().greg();
228
207
  const end = events[events.length - 1].getDate().greg();
229
-
230
208
  if (start.getFullYear() != end.getFullYear()) {
231
209
  title += ' ' + start.getFullYear() + '-' + end.getFullYear();
232
210
  } else if (start.getMonth() == end.getMonth()) {
@@ -239,71 +217,62 @@ function getCalendarTitle(events, options) {
239
217
  title += ' ' + start.getFullYear();
240
218
  }
241
219
  }
242
-
243
220
  return title;
244
221
  }
222
+
245
223
  /**
246
224
  * Returns an English language description of the holiday
247
225
  * @param {Event} ev
248
226
  * @param {boolean} [firstSentence=false]
249
227
  * @return {string}
250
228
  */
251
-
252
229
  function getHolidayDescription(ev, firstSentence = false) {
253
230
  const str = holidayDescription[ev.getDesc()] || holidayDescription[ev.basename()] || '';
254
-
255
231
  if (firstSentence && str) {
256
232
  const dot = str.indexOf('.');
257
-
258
233
  if (dot != -1) {
259
234
  return str.substring(0, dot);
260
235
  }
261
236
  }
262
-
263
237
  return str;
264
238
  }
265
- const HOLIDAY_IGNORE_MASK = flags.DAF_YOMI | flags.OMER_COUNT | flags.SHABBAT_MEVARCHIM | flags.MOLAD | flags.USER_EVENT | flags.HEBREW_DATE;
239
+ const HOLIDAY_IGNORE_MASK = flags.DAF_YOMI | flags.OMER_COUNT | flags.SHABBAT_MEVARCHIM | flags.MOLAD | flags.USER_EVENT | flags.HEBREW_DATE | flags.YERUSHALMI_YOMI;
240
+
266
241
  /**
267
242
  * Makes mulit-line text that summarizes Torah & Haftarah
268
243
  * @param {Event} ev
269
244
  * @param {boolean} il
270
245
  * @return {string}
271
246
  */
272
-
273
247
  function makeTorahMemoText(ev, il) {
274
248
  const mask = ev.getFlags();
275
-
276
249
  if (mask & HOLIDAY_IGNORE_MASK) {
277
250
  return '';
251
+ } else if (typeof ev.eventTime !== 'undefined') {
252
+ return '';
278
253
  }
279
-
280
254
  const reading = mask & flags.PARSHA_HASHAVUA ? getLeyningForParshaHaShavua(ev, il) : getLeyningForHoliday(ev, il);
281
255
  let memo = '';
282
-
283
256
  if (reading && (reading.summary || reading.haftara)) {
284
257
  if (reading.summary) {
285
258
  memo += `Torah: ${reading.summary}`;
286
259
  }
287
-
288
260
  if (reading.summary && reading.haftara) {
289
261
  memo += '\n';
290
262
  }
291
-
292
263
  if (reading.haftara) {
293
264
  memo += 'Haftarah: ' + reading.haftara;
294
-
295
265
  if (reading.reason && reading.reason.haftara) {
296
266
  memo += ' | ' + reading.reason.haftara;
297
267
  }
298
268
  }
299
269
  }
300
-
301
270
  if (reading && reading.sephardic) {
302
271
  memo += '\nHaftarah for Sephardim: ' + reading.sephardic;
303
272
  }
304
-
305
273
  return memo;
306
274
  }
275
+
307
276
  /**
308
277
  * Appends utm_source and utm_medium parameters to a URL
309
278
  * @param {string} url
@@ -313,24 +282,19 @@ function makeTorahMemoText(ev, il) {
313
282
  * @param {string} utmCampaign
314
283
  * @return {string}
315
284
  */
316
-
317
285
  function appendIsraelAndTracking(url, il, utmSource, utmMedium, utmCampaign) {
318
286
  const u = new URL(url);
319
287
  const isHebcal = u.host === 'www.hebcal.com';
320
-
321
288
  if (isHebcal) {
322
289
  if (il) {
323
290
  u.searchParams.set('i', 'on');
324
291
  }
325
-
326
292
  const path = u.pathname;
327
293
  const isHolidays = path.startsWith('/holidays/');
328
294
  const isSedrot = path.startsWith('/sedrot/');
329
295
  const isOmer = path.startsWith('/omer/');
330
-
331
296
  if (isHolidays || isSedrot || isOmer) {
332
297
  u.host = 'hebcal.com';
333
-
334
298
  if (isHolidays) {
335
299
  u.pathname = '/h/' + path.substring(10);
336
300
  } else if (isSedrot) {
@@ -339,51 +303,41 @@ function appendIsraelAndTracking(url, il, utmSource, utmMedium, utmCampaign) {
339
303
  // isOmer
340
304
  u.pathname = '/o/' + path.substring(6);
341
305
  }
342
-
343
306
  if (!utmCampaign || !(utmCampaign.startsWith('ical-') || utmCampaign.startsWith('pdf-'))) {
344
307
  if (utmSource) {
345
308
  u.searchParams.set('us', utmSource);
346
309
  }
347
-
348
310
  if (utmMedium) {
349
311
  u.searchParams.set('um', utmMedium);
350
312
  }
351
313
  }
352
-
353
314
  if (utmCampaign) {
354
315
  u.searchParams.set('uc', utmCampaign);
355
316
  }
356
-
357
317
  return u.toString();
358
318
  }
359
319
  }
360
-
361
320
  utmSource = isHebcal ? utmSource : 'hebcal.com';
362
-
363
321
  if (utmSource) {
364
322
  u.searchParams.set('utm_source', utmSource);
365
323
  }
366
-
367
324
  if (utmMedium) {
368
325
  u.searchParams.set('utm_medium', utmMedium);
369
326
  }
370
-
371
327
  if (utmCampaign) {
372
328
  u.searchParams.set('utm_campaign', utmCampaign);
373
329
  }
374
-
375
330
  return u.toString();
376
331
  }
332
+
377
333
  /**
378
334
  * @private
379
335
  * @param {Event} ev
380
336
  * @return {boolean}
381
337
  */
382
-
383
338
  function shouldRenderBrief(ev) {
384
339
  if (typeof ev.eventTime !== 'undefined') return true;
385
340
  const mask = ev.getFlags();
386
-
387
341
  if (mask & flags.HEBREW_DATE) {
388
342
  const hd = ev.getDate();
389
343
  return hd.getDate() === 1 ? false : true;
@@ -398,6 +352,7 @@ function shouldRenderBrief(ev) {
398
352
  }
399
353
  }
400
354
 
355
+ // eslint-disable-next-line max-len
401
356
  const csvHeader = '"Subject","Start Date","Start Time","End Date","End Time","All day event","Description","Show time as","Location"';
402
357
  const CATEGORY = {
403
358
  dafyomi: 'Daf Yomi',
@@ -410,13 +365,13 @@ const CATEGORY = {
410
365
  roshchodesh: 'Jewish Holidays',
411
366
  user: 'Personal'
412
367
  };
368
+
413
369
  /**
414
370
  * Renders an Event as a string
415
371
  * @param {Event} e
416
372
  * @param {CalOptions} options
417
373
  * @return {string}
418
374
  */
419
-
420
375
  function eventToCsv(e, options) {
421
376
  const d = e.getDate().greg();
422
377
  const mday = d.getDate();
@@ -429,62 +384,51 @@ function eventToCsv(e, options) {
429
384
  let allDay = '"true"';
430
385
  const timed = Boolean(e.eventTime);
431
386
  let subj = shouldRenderBrief(e) ? e.renderBrief(options.locale) : e.render(options.locale);
432
-
433
387
  if (e.eventTime) {
434
388
  const timeStr = HebrewCalendar.reformatTimeStr(e.eventTimeStr, ' PM', options);
435
389
  endTime = startTime = `"${timeStr}"`;
436
390
  endDate = date;
437
391
  allDay = '"false"';
438
392
  }
439
-
440
393
  let loc = 'Jewish Holidays';
441
394
  const mask = e.getFlags();
442
-
443
395
  if (timed && options.location && options.location.name) {
444
396
  const locationName = options.location.name;
445
397
  const comma = locationName.indexOf(',');
446
398
  loc = comma === -1 ? locationName : locationName.substring(0, comma);
447
399
  } else if (mask & flags.DAF_YOMI) {
448
400
  const colon = subj.indexOf(': ');
449
-
450
401
  if (colon != -1) {
451
402
  loc = subj.substring(0, colon);
452
403
  subj = subj.substring(colon + 2);
453
404
  }
454
405
  } else {
455
406
  const category = CATEGORY[getEventCategories(e)[0]];
456
-
457
407
  if (category) {
458
408
  loc = category;
459
409
  }
460
410
  }
461
-
462
411
  subj = subj.replace(/,/g, '').replace(/"/g, '\'\'');
463
-
464
412
  if (options.appendHebrewToSubject) {
465
413
  const hebrew = e.renderBrief('he');
466
-
467
414
  if (hebrew) {
468
415
  subj += ` / ${hebrew}`;
469
416
  }
470
417
  }
471
-
472
418
  let memo0 = e.memo || getHolidayDescription(e, true);
473
-
474
419
  if (!memo0 && typeof e.linkedEvent !== 'undefined') {
475
420
  memo0 = e.linkedEvent.render(options.locale);
476
421
  }
477
-
478
422
  const memo = memo0.replace(/,/g, ';').replace(/"/g, '\'\'').replace(/\n/g, ' / ');
479
423
  const showTimeAs = timed || mask & flags.CHAG ? 4 : 3;
480
424
  return `"${subj}",${date},${startTime},${endDate},${endTime},${allDay},"${memo}","${showTimeAs}","${loc}"`;
481
425
  }
426
+
482
427
  /**
483
428
  * @param {Event[]} events
484
429
  * @param {HebcalOptions} options
485
430
  * @return {string}
486
431
  */
487
-
488
432
  function eventsToCsv(events, options) {
489
433
  return [csvHeader].concat(events.map(e => eventToCsv(e, options))).join('\r\n') + '\r\n';
490
434
  }
@@ -494,10 +438,10 @@ function eventsToCsv(events, options) {
494
438
  * @param {Event} ev
495
439
  * @return {string}
496
440
  */
497
-
498
441
  function eventIsoDate(ev) {
499
442
  return toISOString(ev.getDate().greg());
500
443
  }
444
+
501
445
  /**
502
446
  * Formats a list events for the classic Hebcal.com JSON API response
503
447
  * @param {Event[]} events
@@ -505,25 +449,22 @@ function eventIsoDate(ev) {
505
449
  * @param {boolean} [leyning=true]
506
450
  * @return {Object}
507
451
  */
508
-
509
-
510
452
  function eventsToClassicApi(events, options, leyning = true) {
511
453
  const result = {
512
454
  title: getCalendarTitle(events, options),
513
455
  date: new Date().toISOString()
514
456
  };
515
457
  result.location = locationToPlainObj(options.location);
516
-
517
458
  if (events.length) {
518
459
  result.range = {
519
460
  start: eventIsoDate(events[0]),
520
461
  end: eventIsoDate(events[events.length - 1])
521
462
  };
522
463
  }
523
-
524
464
  result.items = events.map(ev => eventToClassicApiObject(ev, options, leyning));
525
465
  return result;
526
466
  }
467
+
527
468
  /**
528
469
  * Converts a Hebcal event to a classic Hebcal.com JSON API object
529
470
  * @param {Event} ev
@@ -531,7 +472,6 @@ function eventsToClassicApi(events, options, leyning = true) {
531
472
  * @param {boolean} [leyning=true]
532
473
  * @return {Object}
533
474
  */
534
-
535
475
  function eventToClassicApiObject(ev, options, leyning = true) {
536
476
  const timed = Boolean(ev.eventTime);
537
477
  const hd = ev.getDate();
@@ -543,63 +483,48 @@ function eventToClassicApiObject(ev, options, leyning = true) {
543
483
  let title = shouldRenderBrief(ev) ? ev.renderBrief(options.locale) : ev.render(options.locale);
544
484
  const desc = ev.getDesc();
545
485
  const candles = desc === 'Havdalah' || desc === 'Candle lighting';
546
-
547
486
  if (candles) {
548
487
  const time = HebrewCalendar.reformatTimeStr(ev.eventTimeStr, 'pm', options);
549
488
  title += ': ' + time;
550
489
  }
551
-
552
490
  const result = {
553
491
  title: title,
554
492
  date: date
555
493
  };
556
-
557
494
  if (!timed) {
558
495
  result.hdate = hd.toString();
559
496
  }
560
-
561
497
  result.category = categories[0];
562
-
563
498
  if (categories.length > 1) {
564
499
  result.subcat = categories[1];
565
500
  }
566
-
567
501
  if (categories[0] === 'holiday' && mask & flags.CHAG) {
568
502
  result.yomtov = true;
569
503
  }
570
-
571
504
  if (title != desc) {
572
505
  result.title_orig = desc;
573
506
  }
574
-
575
507
  const hebrew = ev.renderBrief('he');
576
-
577
508
  if (hebrew) {
578
509
  result.hebrew = Locale.hebrewStripNikkud(hebrew);
579
510
  }
580
-
581
511
  if (!candles) {
582
512
  if (leyning) {
583
513
  const il = options.il;
584
514
  const isParsha = mask === flags.PARSHA_HASHAVUA;
585
515
  const reading = isParsha ? getLeyningForParshaHaShavua(ev, il) : getLeyningForHoliday(ev, il);
586
-
587
516
  if (reading) {
588
517
  result.leyning = formatLeyningResult(reading);
589
518
  const hyear = hd.getFullYear();
590
-
591
519
  if (isParsha && !il && hyear >= 5745) {
592
520
  const triReading = getTriennialForParshaHaShavua(ev);
593
-
594
521
  if (triReading) {
595
522
  result.leyning.triennial = formatAliyot({}, triReading.aliyot);
596
523
  }
597
524
  }
598
525
  }
599
526
  }
600
-
601
527
  const url = ev.url();
602
-
603
528
  if (url) {
604
529
  const utmSource = options.utmSource || 'js';
605
530
  const utmMedium = options.utmMedium || 'api';
@@ -607,7 +532,6 @@ function eventToClassicApiObject(ev, options, leyning = true) {
607
532
  result.link = appendIsraelAndTracking(url, options.il, utmSource, utmMedium, utmCampaign);
608
533
  }
609
534
  }
610
-
611
535
  if (mask & flags.OMER_COUNT) {
612
536
  result.omer = {
613
537
  count: {
@@ -621,7 +545,6 @@ function eventToClassicApiObject(ev, options, leyning = true) {
621
545
  }
622
546
  };
623
547
  }
624
-
625
548
  if (options.heDateParts && !timed || mask & flags.HEBREW_DATE) {
626
549
  const yy = hd.getFullYear();
627
550
  const mm = hd.getMonthName();
@@ -632,31 +555,26 @@ function eventToClassicApiObject(ev, options, leyning = true) {
632
555
  d: gematriya(dd)
633
556
  };
634
557
  }
635
-
636
558
  const memo = ev.memo || holidayDescription[ev.basename()];
637
-
638
559
  if (memo) {
639
560
  result.memo = memo;
640
561
  } else if (typeof ev.linkedEvent !== 'undefined') {
641
562
  result.memo = ev.linkedEvent.render(options.locale);
642
563
  }
643
-
644
564
  if (options.includeEvent) {
645
565
  result.ev = ev;
646
566
  }
647
-
648
567
  return result;
649
568
  }
569
+
650
570
  /**
651
571
  * @param {Object} result
652
572
  * @param {Object} aliyot
653
573
  * @return {Object}
654
574
  */
655
-
656
575
  function formatAliyot(result, aliyot) {
657
576
  Object.keys(aliyot).forEach(num => {
658
577
  const aliyah = aliyot[num];
659
-
660
578
  if (typeof aliyah !== 'undefined') {
661
579
  const k = num == 'M' ? 'maftir' : num;
662
580
  result[k] = formatAliyahWithBook(aliyah);
@@ -664,31 +582,25 @@ function formatAliyot(result, aliyot) {
664
582
  });
665
583
  return result;
666
584
  }
585
+
667
586
  /**
668
587
  * @param {Leyning} reading
669
588
  * @return {Object}
670
589
  */
671
-
672
-
673
590
  function formatLeyningResult(reading) {
674
591
  const result = {};
675
-
676
592
  if (reading.summary) {
677
593
  result.torah = reading.summary;
678
594
  }
679
-
680
595
  if (reading.haftara) {
681
596
  result.haftarah = reading.haftara;
682
597
  }
683
-
684
598
  if (reading.sephardic) {
685
599
  result.haftarah_sephardic = reading.sephardic;
686
600
  }
687
-
688
601
  if (reading.fullkriyah) {
689
602
  formatAliyot(result, reading.fullkriyah);
690
603
  }
691
-
692
604
  if (reading.reason) {
693
605
  ['7', '8', 'M'].forEach(num => {
694
606
  if (reading.reason[num]) {
@@ -696,12 +608,10 @@ function formatLeyningResult(reading) {
696
608
  result[k] += ' | ' + reading.reason[num];
697
609
  }
698
610
  });
699
-
700
611
  if (reading.reason.haftara) {
701
612
  result.haftarah += ' | ' + reading.reason.haftara;
702
613
  }
703
614
  }
704
-
705
615
  return result;
706
616
  }
707
617
 
@@ -715,7 +625,6 @@ function formatLeyningResult(reading) {
715
625
  * @param {string} utmMedium
716
626
  * @return {string[]}
717
627
  */
718
-
719
628
  function getLinkAndGuid(ev, il, tzid, mainUrl, utmSource, utmMedium) {
720
629
  let link;
721
630
  let guid;
@@ -726,7 +635,6 @@ function getLinkAndGuid(ev, il, tzid, mainUrl, utmSource, utmMedium) {
726
635
  const descAnchor = makeAnchor(ev.getDesc());
727
636
  const anchor = `${dtAnchor}-${descAnchor}`;
728
637
  const url0 = ev.url();
729
-
730
638
  if (url0) {
731
639
  link = appendIsraelAndTracking(url0, il, utmSource, utmMedium).replace(/&/g, '&amp;');
732
640
  guid = `${url0}#${anchor}`;
@@ -736,10 +644,8 @@ function getLinkAndGuid(ev, il, tzid, mainUrl, utmSource, utmMedium) {
736
644
  guid = url1.replace(/&/g, '&amp;') + `#${anchor}`;
737
645
  link = `${url}#${anchor}`;
738
646
  }
739
-
740
647
  return [link, guid];
741
648
  }
742
-
743
649
  const localeToLg = {
744
650
  's': 'en',
745
651
  'a': 'en',
@@ -748,12 +654,12 @@ const localeToLg = {
748
654
  'ah': 'en',
749
655
  'sh': 'en'
750
656
  };
657
+
751
658
  /**
752
659
  * @param {Event[]} events
753
660
  * @param {CalOptions} options
754
661
  * @return {string}
755
662
  */
756
-
757
663
  function eventsToRss2(events, options) {
758
664
  options.dayFormat = new Intl.DateTimeFormat('en-US', {
759
665
  weekday: 'long',
@@ -790,6 +696,7 @@ function eventsToRss2(events, options) {
790
696
  str += '</channel>\n</rss>\n';
791
697
  return str;
792
698
  }
699
+
793
700
  /**
794
701
  * @private
795
702
  * @param {Event} ev
@@ -798,27 +705,22 @@ function eventsToRss2(events, options) {
798
705
  * @param {string} lastBuildDate
799
706
  * @return {string}
800
707
  */
801
-
802
708
  function getPubDate(ev, evPubDate, evDate, lastBuildDate) {
803
709
  if (evPubDate) {
804
710
  const dt = ev.eventTime;
805
-
806
711
  if (dt) {
807
712
  return dt.toUTCString();
808
713
  }
809
-
810
714
  return evDate.toUTCString().replace(/ \S+ GMT$/, ' 00:00:00 GMT');
811
715
  }
812
-
813
716
  return lastBuildDate;
814
717
  }
718
+
815
719
  /**
816
720
  * @param {Event} ev
817
721
  * @param {CalOptions} options
818
722
  * @return {string}
819
723
  */
820
-
821
-
822
724
  function eventToRssItem2(ev, options) {
823
725
  let subj = ev.render();
824
726
  const evDate = ev.getDate().greg();
@@ -836,10 +738,8 @@ function eventToRssItem2(ev, options) {
836
738
  const desc = ev.getDesc();
837
739
  const candles = desc === 'Havdalah' || desc === 'Candle lighting';
838
740
  let memo;
839
-
840
741
  if (candles) {
841
742
  const colon = subj.indexOf(': ');
842
-
843
743
  if (colon != -1) {
844
744
  const options = {
845
745
  location,
@@ -852,7 +752,6 @@ function eventToRssItem2(ev, options) {
852
752
  } else {
853
753
  memo = ev.getFlags() & flags.PARSHA_HASHAVUA ? makeTorahMemoText(ev, il) : ev.memo || holidayDescription[ev.basename()];
854
754
  }
855
-
856
755
  const dayFormat = options.dayFormat;
857
756
  const description = memo || dayFormat.format(evDate);
858
757
  const geoTags = cat0 == 'candles' ? `<geo:lat>${location.getLatitude()}</geo:lat>\n<geo:long>${location.getLongitude()}</geo:long>\n` : '';
@@ -874,15 +773,12 @@ ${geoTags}</item>
874
773
  * @param {boolean} il true if Israel
875
774
  * @return {Object}
876
775
  */
877
-
878
776
  function eventToFullCalendar(ev, tzid, il) {
879
777
  const classes = getEventCategories(ev);
880
778
  const mask = ev.getFlags();
881
-
882
779
  if (classes[0] == 'holiday' && mask & flags.CHAG) {
883
780
  classes.push('yomtov');
884
781
  }
885
-
886
782
  const timed = Boolean(ev.eventTime);
887
783
  const title = shouldRenderBrief(ev) ? ev.renderBrief() : ev.render();
888
784
  const start = timed ? Zmanim.formatISOWithTimeZone(tzid, ev.eventTime) : toISOString(ev.getDate().greg());
@@ -893,30 +789,23 @@ function eventToFullCalendar(ev, tzid, il) {
893
789
  className: classes.join(' ')
894
790
  };
895
791
  const hebrew = ev.renderBrief('he');
896
-
897
792
  if (hebrew) {
898
793
  result.hebrew = Locale.hebrewStripNikkud(hebrew);
899
794
  }
900
-
901
795
  const url = ev.url();
902
-
903
796
  if (url) {
904
797
  result.url = appendIsraelAndTracking(url, il, 'js', 'fc');
905
798
  }
906
-
907
799
  const desc = ev.getDesc();
908
800
  const candles = desc === 'Havdalah' || desc === 'Candle lighting';
909
-
910
801
  if (!candles) {
911
802
  const memo = mask & flags.PARSHA_HASHAVUA ? makeTorahMemoText(ev, il) : ev.memo || holidayDescription[ev.basename()];
912
-
913
803
  if (memo) {
914
804
  result.description = memo;
915
805
  } else if (typeof ev.linkedEvent !== 'undefined') {
916
806
  result.description = ev.linkedEvent.render();
917
807
  }
918
808
  }
919
-
920
809
  return result;
921
810
  }
922
811