@hebcal/icalendar 7.0.3 → 7.0.4

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/icalendar.js CHANGED
@@ -59,6 +59,37 @@ const DAILY_LEARNING = flags.DAILY_LEARNING |
59
59
  flags.MISHNA_YOMI |
60
60
  flags.YERUSHALMI_YOMI |
61
61
  flags.NACH_YOMI;
62
+ /** Formats a date-time string as `YYYYMMDDTHHMMSS` */
63
+ function rfc5545DateTime(dt, hour, minute) {
64
+ return IcalEvent.formatYYYYMMDD(dt) + 'T' + pad2(hour) + pad2(minute) + '00';
65
+ }
66
+ /**
67
+ * Computes the DTSTART/DTEND date-time strings (in `YYYYMMDDTHHMMSS`
68
+ * format) for a timed event, adding `duration` minutes (if any) to the
69
+ * wall-clock start time. Adding to the wall clock (rather than to the
70
+ * underlying instant) keeps the result in the same timezone as DTSTART
71
+ * regardless of the host machine's own local timezone.
72
+ * @private
73
+ */
74
+ function formatTimedStartEnd(ev) {
75
+ const [hourStr, minuteStr] = ev.eventTimeStr.split(':');
76
+ const hour = +hourStr;
77
+ const minute = +minuteStr;
78
+ const dt = ev.greg();
79
+ const startDate = rfc5545DateTime(dt, hour, minute);
80
+ if (!ev.duration) {
81
+ return { startDate, endDate: startDate };
82
+ }
83
+ const totalMinutes = hour * 60 + minute + ev.duration;
84
+ const endHour = Math.floor(totalMinutes / 60) % 24;
85
+ const endMinute = totalMinutes % 60;
86
+ const dayOffset = Math.floor(totalMinutes / 1440);
87
+ if (dayOffset) {
88
+ dt.setDate(dt.getDate() + dayOffset);
89
+ }
90
+ const endDate = rfc5545DateTime(dt, endHour, endMinute);
91
+ return { startDate, endDate };
92
+ }
62
93
  /**
63
94
  * Represents an RFC 2445 iCalendar VEVENT
64
95
  */
@@ -117,11 +148,9 @@ export class IcalEvent {
117
148
  this.transp = 'TRANSPARENT';
118
149
  this.busyStatus = 'FREE';
119
150
  if (timed) {
120
- let [hour, minute] = ev0.eventTimeStr.split(':');
121
- hour = +hour;
122
- minute = +minute;
123
- this.startDate += 'T' + pad2(hour) + pad2(minute) + '00';
124
- this.endDate = this.startDate;
151
+ const { startDate, endDate } = formatTimedStartEnd(ev);
152
+ this.startDate = startDate;
153
+ this.endDate = endDate;
125
154
  if (location?.getTzid()) {
126
155
  this.dtargs = `;TZID=${location.getTzid()}`;
127
156
  }
@@ -1 +1 @@
1
- export declare const version = "7.0.3";
1
+ export declare const version = "7.0.4";
@@ -1,2 +1,2 @@
1
1
  // DO NOT EDIT THIS AUTO-GENERATED FILE!
2
- export const version = '7.0.3';
2
+ export const version = '7.0.4';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hebcal/icalendar",
3
- "version": "7.0.3",
3
+ "version": "7.0.4",
4
4
  "author": "Michael J. Radwin (https://github.com/mjradwin)",
5
5
  "keywords": [
6
6
  "ical",
@@ -30,8 +30,8 @@
30
30
  },
31
31
  "homepage": "https://hebcal.github.io/api/icalendar/",
32
32
  "dependencies": {
33
- "@hebcal/core": "^6.9.1",
34
- "@hebcal/hdate": "^0.22.7",
33
+ "@hebcal/core": "^6.9.3",
34
+ "@hebcal/hdate": "^0.22.8",
35
35
  "@hebcal/murmurhash3": "^1.0.0",
36
36
  "@hebcal/rest-api": "^7.1.3"
37
37
  },
@@ -48,11 +48,11 @@
48
48
  },
49
49
  "license": "BSD-2-Clause",
50
50
  "devDependencies": {
51
- "@hebcal/learning": "^6.9.7",
52
- "@types/node": "26.2.0",
53
- "oxlint": "^1.77.0",
54
- "prettier": "^3.9.6",
51
+ "@hebcal/learning": "^6.11.3",
52
+ "@types/node": "26.6.2",
53
+ "oxlint": "^1.83.0",
54
+ "prettier": "^3.9.8",
55
55
  "typescript": "^7.0.2",
56
- "vitest": "^4.1.10"
56
+ "vitest": "^5.0.1"
57
57
  }
58
58
  }