@hebcal/icalendar 4.16.0 → 4.17.2

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.js CHANGED
@@ -1,4 +1,4 @@
1
- /*! @hebcal/icalendar v4.16.0 */
1
+ /*! @hebcal/icalendar v4.17.2 */
2
2
  'use strict';
3
3
 
4
4
  Object.defineProperty(exports, '__esModule', { value: true });
@@ -8,7 +8,7 @@ var murmurhash3 = require('murmurhash3');
8
8
  var restApi = require('@hebcal/rest-api');
9
9
  var fs = require('fs');
10
10
 
11
- const version="4.16.0";
11
+ const version="4.17.2";
12
12
 
13
13
  const VTIMEZONE = {};
14
14
  const CATEGORY = {
@@ -123,7 +123,11 @@ class IcalEvent {
123
123
  const prefix = ev.getEmoji();
124
124
 
125
125
  if (prefix) {
126
- subj = prefix + ' ' + subj;
126
+ if (mask & core.flags.OMER_COUNT) {
127
+ subj = subj + ' ' + prefix;
128
+ } else {
129
+ subj = prefix + ' ' + subj;
130
+ }
127
131
  }
128
132
  } // make subject safe for iCalendar
129
133
 
@@ -139,19 +143,32 @@ class IcalEvent {
139
143
  }
140
144
 
141
145
  this.subj = subj;
142
- const isUserEvent = Boolean(mask & core.flags.USER_EVENT);
146
+ this.category = ev.category || CATEGORY[restApi.getEventCategories(ev)[0]];
147
+ }
148
+ /**
149
+ * @return {string}
150
+ */
151
+
143
152
 
144
- if (ev.alarm) {
145
- this.alarm = ev.alarm;
153
+ getAlarm() {
154
+ const ev = this.ev;
155
+ const mask = ev.getFlags();
156
+ const evAlarm = ev.alarm;
157
+
158
+ if (typeof evAlarm === 'string') {
159
+ return 'TRIGGER:' + evAlarm;
160
+ } else if (core.greg.isDate(evAlarm)) {
161
+ evAlarm.setSeconds(0);
162
+ return 'TRIGGER;VALUE=DATE-TIME:' + IcalEvent.makeDtstamp(evAlarm);
146
163
  } else if (mask & core.flags.OMER_COUNT) {
147
- this.alarm = '-P0DT3H30M0S'; // 8:30pm Omer alarm evening before
148
- } else if (isUserEvent) {
149
- this.alarm = '-P0DT12H0M0S'; // noon the day before
150
- } else if (timed && ev.getDesc().startsWith('Candle lighting')) {
151
- this.alarm = '-P0DT0H10M0S'; // ten minutes
164
+ return 'TRIGGER:-P0DT3H30M0S'; // 8:30pm Omer alarm evening before
165
+ } else if (mask & core.flags.USER_EVENT) {
166
+ return 'TRIGGER:-P0DT12H0M0S'; // noon the day before
167
+ } else if (this.timed && ev.getDesc().startsWith('Candle lighting')) {
168
+ return 'TRIGGER:-P0DT0H10M0S';
152
169
  }
153
170
 
154
- this.category = ev.category || CATEGORY[restApi.getEventCategories(ev)[0]];
171
+ return null;
155
172
  }
156
173
  /**
157
174
  * @return {string}
@@ -206,8 +223,10 @@ class IcalEvent {
206
223
  arr.push('GEO:' + options.location.latitude + ';' + options.location.longitude);
207
224
  }
208
225
 
209
- if (this.alarm) {
210
- arr.push('BEGIN:VALARM', 'ACTION:DISPLAY', 'DESCRIPTION:This is an event reminder', `TRIGGER:${this.alarm}`, 'END:VALARM');
226
+ const trigger = this.getAlarm();
227
+
228
+ if (trigger) {
229
+ arr.push('BEGIN:VALARM', 'ACTION:DISPLAY', 'DESCRIPTION:Event reminder', `${trigger}`, 'END:VALARM');
211
230
  }
212
231
 
213
232
  arr.push('END:VEVENT');
@@ -388,7 +407,8 @@ function createMemo(e, options) {
388
407
  const mask = e.getFlags();
389
408
 
390
409
  if (mask & core.flags.OMER_COUNT) {
391
- return e.getTodayIs('en') + '\\n\\n' + e.memo;
410
+ const sefira = [e.sefira('en'), e.sefira('he'), e.sefira('translit')].join('\\n');
411
+ return e.getTodayIs('en') + '\\n\\n' + sefira + '\\n\\n' + e.url();
392
412
  }
393
413
 
394
414
  const url = appendTrackingToUrl(e.url(), options);
package/dist/index.mjs CHANGED
@@ -1,10 +1,10 @@
1
- /*! @hebcal/icalendar v4.16.0 */
2
- import { flags, Locale } from '@hebcal/core';
1
+ /*! @hebcal/icalendar v4.17.2 */
2
+ import { flags, Locale, greg } from '@hebcal/core';
3
3
  import { murmur32HexSync } from 'murmurhash3';
4
4
  import { shouldRenderBrief, pad2, getEventCategories, makeAnchor, pad4, getHolidayDescription, getCalendarTitle, appendIsraelAndTracking, makeTorahMemoText } from '@hebcal/rest-api';
5
5
  import { promises } from 'fs';
6
6
 
7
- const version="4.16.0";
7
+ const version="4.17.2";
8
8
 
9
9
  const VTIMEZONE = {};
10
10
  const CATEGORY = {
@@ -119,7 +119,11 @@ class IcalEvent {
119
119
  const prefix = ev.getEmoji();
120
120
 
121
121
  if (prefix) {
122
- subj = prefix + ' ' + subj;
122
+ if (mask & flags.OMER_COUNT) {
123
+ subj = subj + ' ' + prefix;
124
+ } else {
125
+ subj = prefix + ' ' + subj;
126
+ }
123
127
  }
124
128
  } // make subject safe for iCalendar
125
129
 
@@ -135,19 +139,32 @@ class IcalEvent {
135
139
  }
136
140
 
137
141
  this.subj = subj;
138
- const isUserEvent = Boolean(mask & flags.USER_EVENT);
142
+ this.category = ev.category || CATEGORY[getEventCategories(ev)[0]];
143
+ }
144
+ /**
145
+ * @return {string}
146
+ */
147
+
139
148
 
140
- if (ev.alarm) {
141
- this.alarm = ev.alarm;
149
+ getAlarm() {
150
+ const ev = this.ev;
151
+ const mask = ev.getFlags();
152
+ const evAlarm = ev.alarm;
153
+
154
+ if (typeof evAlarm === 'string') {
155
+ return 'TRIGGER:' + evAlarm;
156
+ } else if (greg.isDate(evAlarm)) {
157
+ evAlarm.setSeconds(0);
158
+ return 'TRIGGER;VALUE=DATE-TIME:' + IcalEvent.makeDtstamp(evAlarm);
142
159
  } else if (mask & flags.OMER_COUNT) {
143
- this.alarm = '-P0DT3H30M0S'; // 8:30pm Omer alarm evening before
144
- } else if (isUserEvent) {
145
- this.alarm = '-P0DT12H0M0S'; // noon the day before
146
- } else if (timed && ev.getDesc().startsWith('Candle lighting')) {
147
- this.alarm = '-P0DT0H10M0S'; // ten minutes
160
+ return 'TRIGGER:-P0DT3H30M0S'; // 8:30pm Omer alarm evening before
161
+ } else if (mask & flags.USER_EVENT) {
162
+ return 'TRIGGER:-P0DT12H0M0S'; // noon the day before
163
+ } else if (this.timed && ev.getDesc().startsWith('Candle lighting')) {
164
+ return 'TRIGGER:-P0DT0H10M0S';
148
165
  }
149
166
 
150
- this.category = ev.category || CATEGORY[getEventCategories(ev)[0]];
167
+ return null;
151
168
  }
152
169
  /**
153
170
  * @return {string}
@@ -202,8 +219,10 @@ class IcalEvent {
202
219
  arr.push('GEO:' + options.location.latitude + ';' + options.location.longitude);
203
220
  }
204
221
 
205
- if (this.alarm) {
206
- arr.push('BEGIN:VALARM', 'ACTION:DISPLAY', 'DESCRIPTION:This is an event reminder', `TRIGGER:${this.alarm}`, 'END:VALARM');
222
+ const trigger = this.getAlarm();
223
+
224
+ if (trigger) {
225
+ arr.push('BEGIN:VALARM', 'ACTION:DISPLAY', 'DESCRIPTION:Event reminder', `${trigger}`, 'END:VALARM');
207
226
  }
208
227
 
209
228
  arr.push('END:VEVENT');
@@ -384,7 +403,8 @@ function createMemo(e, options) {
384
403
  const mask = e.getFlags();
385
404
 
386
405
  if (mask & flags.OMER_COUNT) {
387
- return e.getTodayIs('en') + '\\n\\n' + e.memo;
406
+ const sefira = [e.sefira('en'), e.sefira('he'), e.sefira('translit')].join('\\n');
407
+ return e.getTodayIs('en') + '\\n\\n' + sefira + '\\n\\n' + e.url();
388
408
  }
389
409
 
390
410
  const url = appendTrackingToUrl(e.url(), options);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hebcal/icalendar",
3
- "version": "4.16.0",
3
+ "version": "4.17.2",
4
4
  "author": "Michael J. Radwin (https://github.com/mjradwin)",
5
5
  "keywords": [
6
6
  "ical",
@@ -24,7 +24,7 @@
24
24
  "url": "https://github.com/hebcal/hebcal-icalendar/issues"
25
25
  },
26
26
  "dependencies": {
27
- "@hebcal/core": "^3.35.0",
27
+ "@hebcal/core": "^3.36.1",
28
28
  "@hebcal/rest-api": "^3.13.0",
29
29
  "murmurhash3": "^0.5.0"
30
30
  },