ical-generator 11.1.3-develop.4 → 11.1.3-develop.5
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/README.md +16 -6
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +6 -2
- package/dist/index.d.mts +6 -2
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/calendar.ts +3 -1
- package/src/event.ts +3 -1
package/README.md
CHANGED
|
@@ -81,15 +81,24 @@ You can also pass a string which is then passed to javascript's `Date` internall
|
|
|
81
81
|
|
|
82
82
|
It is recommended to use UTC time as far as possible. `ical-generator` will output all time information as UTC time as
|
|
83
83
|
long as no time zone is defined. For day.js, a plugin is necessary for this, which is a prerequisite. If a time zone is
|
|
84
|
-
set, `ical-generator` assumes that the given time matches the time zone.
|
|
85
|
-
|
|
86
|
-
`
|
|
84
|
+
set, `ical-generator` assumes that the given time matches the time zone.
|
|
85
|
+
|
|
86
|
+
Please note that a native `Date` (or a string) has no time zone of its own. If a time zone is set, `ical-generator`
|
|
87
|
+
uses the local time of the machine it runs on (`getHours()` etc.) and labels it with the given time zone. The result
|
|
88
|
+
therefore depends on the server's time zone: `new Date('2026-07-01T09:30:00Z')` with `timezone: 'Europe/Prague'` becomes
|
|
89
|
+
`DTSTART;TZID=Europe/Prague:20260701T093000` on a server running in UTC, although 09:30 UTC is 11:30 in Prague. To get
|
|
90
|
+
the same output everywhere, pass a `TZDate`, a Luxon `DateTime`, a `moment-timezone` or a Temporal object, or do not
|
|
91
|
+
set a time zone so that the time is written as UTC.
|
|
92
|
+
|
|
93
|
+
If a time zone is used, it is also recommended to use a VTimezone generator. Such a function generates a VTimezone entry
|
|
94
|
+
and returns it. For example, `timezones-ical-library` or `@touch4it/ical-timezones` can be used for this:
|
|
87
95
|
|
|
88
96
|
#### Example with `@touch4it/ical-timezones`
|
|
89
97
|
|
|
90
98
|
```typescript
|
|
91
99
|
import { ICalCalendar } from 'ical-generator';
|
|
92
100
|
import { getVtimezoneComponent } from '@touch4it/ical-timezones';
|
|
101
|
+
import { TZDate } from '@date-fns/tz';
|
|
93
102
|
|
|
94
103
|
const cal = new ICalCalendar();
|
|
95
104
|
cal.timezone({
|
|
@@ -97,7 +106,7 @@ cal.timezone({
|
|
|
97
106
|
generator: getVtimezoneComponent,
|
|
98
107
|
});
|
|
99
108
|
cal.createEvent({
|
|
100
|
-
start: new
|
|
109
|
+
start: new TZDate(2026, 0, 15, 9, 30, 'Europe/London'), // 09:30 London time
|
|
101
110
|
timezone: 'Europe/London',
|
|
102
111
|
});
|
|
103
112
|
```
|
|
@@ -107,14 +116,15 @@ cal.createEvent({
|
|
|
107
116
|
```typescript
|
|
108
117
|
import { ICalCalendar } from 'ical-generator';
|
|
109
118
|
import { tzlib_get_ical_block } from 'timezones-ical-library';
|
|
119
|
+
import { TZDate } from '@date-fns/tz';
|
|
110
120
|
|
|
111
121
|
const cal = new ICalCalendar();
|
|
112
122
|
cal.timezone({
|
|
113
|
-
name: 'Europe/
|
|
123
|
+
name: 'Europe/London',
|
|
114
124
|
generator: (tz) => tzlib_get_ical_block(tz)[0],
|
|
115
125
|
});
|
|
116
126
|
cal.createEvent({
|
|
117
|
-
start: new
|
|
127
|
+
start: new TZDate(2026, 0, 15, 9, 30, 'Europe/London'), // 09:30 London time
|
|
118
128
|
timezone: 'Europe/London',
|
|
119
129
|
});
|
|
120
130
|
```
|