@moltenship/calendar 1.0.0-rc.2 → 2.0.0-beta.1
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 +24 -4
- package/dist/index.d.mts +2 -2
- package/docs/accessibility.md +304 -0
- package/docs/agents/changes.md +449 -0
- package/docs/agents/coding-agents.md +117 -0
- package/docs/agents/connect.md +435 -0
- package/docs/agents/deleting.md +296 -0
- package/docs/agents/reference.md +512 -0
- package/docs/agents/server.md +317 -0
- package/docs/agents/webmcp.md +153 -0
- package/docs/agents.md +353 -0
- package/docs/annotations.md +196 -0
- package/docs/api/changes.md +248 -0
- package/docs/api/dnd-kit.md +267 -0
- package/docs/api/events.md +152 -0
- package/docs/api/ics.md +524 -0
- package/docs/api/primitives.md +168 -0
- package/docs/api/react.md +236 -0
- package/docs/api/recurrence.md +586 -0
- package/docs/api/solid.md +460 -0
- package/docs/api/store.md +92 -0
- package/docs/api/temporal.md +172 -0
- package/docs/api.md +57 -0
- package/docs/availability.md +573 -0
- package/docs/comparison.md +279 -0
- package/docs/concepts/anatomy.md +73 -0
- package/docs/concepts/events.md +164 -0
- package/docs/concepts/how-it-works.md +95 -0
- package/docs/concepts/recurrence.md +127 -0
- package/docs/concepts/state.md +244 -0
- package/docs/concepts/time.md +170 -0
- package/docs/guides/dnd-kit.md +333 -0
- package/docs/guides/google-calendar-sync.md +1246 -0
- package/docs/guides/google-calendar.md +367 -0
- package/docs/guides/ics.md +486 -0
- package/docs/guides/motion.md +414 -0
- package/docs/guides/nextjs-app-router.md +630 -0
- package/docs/guides/nextjs.md +149 -0
- package/docs/guides/performance.md +103 -0
- package/docs/guides/recurring-events.md +583 -0
- package/docs/guides/tanstack-query.md +485 -0
- package/docs/index.md +118 -0
- package/docs/installation.md +194 -0
- package/docs/interactions.md +408 -0
- package/docs/llms.txt +86 -0
- package/docs/migrating-to-2.md +322 -0
- package/docs/quick-start.md +159 -0
- package/docs/stylex.md +265 -0
- package/docs/testing.md +581 -0
- package/docs/theme-builder.md +81 -0
- package/docs/theming.md +169 -0
- package/docs/undo-redo.md +339 -0
- package/docs/views/agenda.md +221 -0
- package/docs/views/custom-views.md +192 -0
- package/docs/views/month.md +109 -0
- package/docs/views/resource-columns.md +261 -0
- package/docs/views/resource-timeline.md +225 -0
- package/docs/views/scrolling.md +192 -0
- package/docs/views/week-and-day.md +257 -0
- package/docs/views/year.md +138 -0
- package/docs/views.md +69 -0
- package/package.json +41 -14
- package/skills/moltenship-time/SKILL.md +75 -0
- package/skills/moltenship-time/references/agent-ready.md +272 -0
- package/skills/moltenship-time/references/changes.md +188 -0
- package/skills/moltenship-time/references/compose.md +168 -0
- package/skills/moltenship-time/references/mistakes.md +98 -0
- package/skills/moltenship-time/references/solid.md +202 -0
- package/skills/moltenship-time/references/state.md +129 -0
- package/skills/moltenship-time/references/testing.md +176 -0
|
@@ -0,0 +1,367 @@
|
|
|
1
|
+
# Google Calendar events
|
|
2
|
+
|
|
3
|
+
Read recurring events from the Google Calendar API, with their RRULE, EXDATE and RDATE lines, and show and edit them.
|
|
4
|
+
|
|
5
|
+
Source: https://time.molten.sh/docs/guides/google-calendar
|
|
6
|
+
|
|
7
|
+
The Google Calendar API stores a repeating event the way iCalendar does. `events.list`, without
|
|
8
|
+
`singleEvents=true`, returns each series once:
|
|
9
|
+
|
|
10
|
+
- **The master**, at the series' first occurrence, with its rule and exceptions as iCalendar lines
|
|
11
|
+
in `recurrence`, and the zone it repeats in as `start.timeZone`.
|
|
12
|
+
- **Changed occurrences**: events with the master's ID in `recurringEventId`, and the start the
|
|
13
|
+
series gave them in `originalStartTime`.
|
|
14
|
+
- **Deleted occurrences**: the same, with `status: "cancelled"` and no times of their own.
|
|
15
|
+
|
|
16
|
+
```json
|
|
17
|
+
[
|
|
18
|
+
{
|
|
19
|
+
"id": "standup",
|
|
20
|
+
"summary": "Stand-up",
|
|
21
|
+
"start": { "dateTime": "2026-10-19T09:00:00+02:00", "timeZone": "Europe/Berlin" },
|
|
22
|
+
"end": { "dateTime": "2026-10-19T09:30:00+02:00", "timeZone": "Europe/Berlin" },
|
|
23
|
+
"recurrence": ["RRULE:FREQ=DAILY;COUNT=5", "EXDATE;TZID=Europe/Berlin:20261021T090000"]
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
"id": "standup_20261020T070000Z",
|
|
27
|
+
"recurringEventId": "standup",
|
|
28
|
+
"originalStartTime": { "dateTime": "2026-10-20T09:00:00+02:00", "timeZone": "Europe/Berlin" },
|
|
29
|
+
"summary": "Stand-up (late)",
|
|
30
|
+
"start": { "dateTime": "2026-10-20T11:00:00", "timeZone": "Europe/Berlin" },
|
|
31
|
+
"end": { "dateTime": "2026-10-20T11:30:00", "timeZone": "Europe/Berlin" }
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
"id": "standup_20261022T070000Z",
|
|
35
|
+
"recurringEventId": "standup",
|
|
36
|
+
"originalStartTime": { "dateTime": "2026-10-22T09:00:00+02:00", "timeZone": "Europe/Berlin" },
|
|
37
|
+
"status": "cancelled"
|
|
38
|
+
}
|
|
39
|
+
]
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
That's a master, overrides and cancelled overrides, as in
|
|
43
|
+
[Recurring events](../concepts/recurrence.md). This page maps them to `RecurringCalendarEvent`s,
|
|
44
|
+
which the calendar from [Show and edit recurring events](./recurring-events.md) expands and
|
|
45
|
+
edits. Here, the stand-up shows on Monday at 09:00, Tuesday at 11:00 and Friday at 09:00.
|
|
46
|
+
|
|
47
|
+
With `singleEvents=true`, Google expands series itself, between `timeMin` and `timeMax`, and
|
|
48
|
+
leaves the masters out. Each occurrence is then an event of its own. It names its series in
|
|
49
|
+
`recurringEventId`, but not the series' rule, which "This and following events" and "All events"
|
|
50
|
+
change. [Sync with Google Calendar](./google-calendar-sync.md#series-masters-not-instances)
|
|
51
|
+
compares the two.
|
|
52
|
+
|
|
53
|
+
## The event type
|
|
54
|
+
|
|
55
|
+
The mapping reads a few fields of Google's
|
|
56
|
+
[Event resource](https://developers.google.com/workspace/calendar/api/v3/reference/events), and
|
|
57
|
+
keeps the whole Google event as each calendar event's `data`:
|
|
58
|
+
|
|
59
|
+
```ts title="google-calendar.ts"
|
|
60
|
+
// lib/google-calendar.ts
|
|
61
|
+
import type { CalendarEventInterval } from "@moltenship/calendar";
|
|
62
|
+
import {
|
|
63
|
+
formatRecurrenceRule,
|
|
64
|
+
parseRecurrenceRule,
|
|
65
|
+
type EventRecurrence,
|
|
66
|
+
type RecurrenceDate,
|
|
67
|
+
type RecurrenceRule,
|
|
68
|
+
type RecurringCalendarEvent,
|
|
69
|
+
} from "@moltenship/calendar-recurrence";
|
|
70
|
+
import {
|
|
71
|
+
decodeIcsDateValue,
|
|
72
|
+
encodeIcsValue,
|
|
73
|
+
icsValueTypeOf,
|
|
74
|
+
parseIcsComponents,
|
|
75
|
+
splitIcsValues,
|
|
76
|
+
type IcsDateValue,
|
|
77
|
+
} from "@moltenship/ics";
|
|
78
|
+
|
|
79
|
+
/** The fields of a Google Calendar API event that this mapping and the sync guide read. */
|
|
80
|
+
export interface GoogleEvent {
|
|
81
|
+
readonly id: string;
|
|
82
|
+
/** Changes on every write. Send it as `If-Match`, so a write never overwrites a newer one. */
|
|
83
|
+
readonly etag?: string;
|
|
84
|
+
readonly status?: "confirmed" | "tentative" | "cancelled";
|
|
85
|
+
readonly summary?: string;
|
|
86
|
+
/** An event color from `colors.get`, "1" to "11". Without it, the calendar's color. */
|
|
87
|
+
readonly colorId?: string;
|
|
88
|
+
/** "transparent" shows the time as free. "opaque", the default, as busy. */
|
|
89
|
+
readonly transparency?: "opaque" | "transparent";
|
|
90
|
+
readonly start?: GoogleEventTime;
|
|
91
|
+
readonly end?: GoogleEventTime;
|
|
92
|
+
/** On a series' master: RRULE, EXRULE, RDATE and EXDATE lines. */
|
|
93
|
+
readonly recurrence?: readonly string[];
|
|
94
|
+
/** On a changed or cancelled occurrence: the master's ID. */
|
|
95
|
+
readonly recurringEventId?: string;
|
|
96
|
+
/** On a changed or cancelled occurrence: where the series put it. */
|
|
97
|
+
readonly originalStartTime?: GoogleEventTime;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
export interface GoogleEventTime {
|
|
101
|
+
/** An all-day event's date, such as "2026-10-12". */
|
|
102
|
+
readonly date?: string;
|
|
103
|
+
/** RFC 3339. The offset may be left out when `timeZone` is set. */
|
|
104
|
+
readonly dateTime?: string;
|
|
105
|
+
/** The IANA time zone a series repeats in. */
|
|
106
|
+
readonly timeZone?: string;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/** A Google event as the calendar's event, with the Google event as its `data`. */
|
|
110
|
+
export type GoogleCalendarEvent = RecurringCalendarEvent<GoogleEvent>;
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
## Read the recurrence lines
|
|
114
|
+
|
|
115
|
+
`parseRecurrenceRule` reads an `RRULE:` line as Google writes it. EXDATE and RDATE lines need their
|
|
116
|
+
parameters: `TZID` names the zone of their wall times, and `VALUE=DATE` makes them dates. The
|
|
117
|
+
syntax layer of `@moltenship/ics` reads those lines, and its value decoders read each date:
|
|
118
|
+
|
|
119
|
+
```ts title="google-calendar.ts"
|
|
120
|
+
/** A master's `recurrence` lines as an `EventRecurrence`, and the lines it couldn't read. */
|
|
121
|
+
export function readGoogleRecurrence(lines: readonly string[]): {
|
|
122
|
+
readonly problems: readonly string[];
|
|
123
|
+
readonly recurrence: EventRecurrence;
|
|
124
|
+
} {
|
|
125
|
+
const problems: string[] = [];
|
|
126
|
+
const exceptionDates: RecurrenceDate[] = [];
|
|
127
|
+
const recurrenceDates: RecurrenceDate[] = [];
|
|
128
|
+
let rule: RecurrenceRule | undefined;
|
|
129
|
+
|
|
130
|
+
// The ICS syntax layer splits content lines into names, parameters and values.
|
|
131
|
+
const { components } = parseIcsComponents(["BEGIN:VEVENT", ...lines, "END:VEVENT"].join("\r\n"));
|
|
132
|
+
for (const property of components[0]?.properties ?? []) {
|
|
133
|
+
if (property.name === "RRULE") {
|
|
134
|
+
const parsed = parseRecurrenceRule(property.value);
|
|
135
|
+
rule = parsed.rule;
|
|
136
|
+
problems.push(...parsed.issues.map((issue) => `RRULE: ${issue.message}`));
|
|
137
|
+
continue;
|
|
138
|
+
}
|
|
139
|
+
// EXRULE, which RFC 5545 deprecated, and anything else.
|
|
140
|
+
if (property.name !== "EXDATE" && property.name !== "RDATE") {
|
|
141
|
+
problems.push(`${property.name} isn't supported`);
|
|
142
|
+
continue;
|
|
143
|
+
}
|
|
144
|
+
// A DATE-TIME unless VALUE says otherwise, as in EXDATE;VALUE=DATE:20261014.
|
|
145
|
+
const type = icsValueTypeOf(property);
|
|
146
|
+
if (type !== "DATE" && type !== "DATE-TIME") {
|
|
147
|
+
problems.push(`${property.name};VALUE=${type} isn't read`);
|
|
148
|
+
continue;
|
|
149
|
+
}
|
|
150
|
+
const tzid = property.parameters.TZID?.[0];
|
|
151
|
+
const dates = property.name === "EXDATE" ? exceptionDates : recurrenceDates;
|
|
152
|
+
for (const raw of splitIcsValues(type, property.value)) {
|
|
153
|
+
const decoded = decodeIcsDateValue(raw, type, tzid === undefined ? {} : { tzid });
|
|
154
|
+
const date = decoded.ok ? recurrenceDateOf(decoded.value) : undefined;
|
|
155
|
+
if (date === undefined) problems.push(`${property.name}: can't read ${raw}`);
|
|
156
|
+
else dates.push(date);
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
return { problems, recurrence: { exceptionDates, recurrenceDates, rule } };
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
/** An ICS date in the series' terms. The expander converts dates of another kind. */
|
|
163
|
+
function recurrenceDateOf(value: IcsDateValue): RecurrenceDate | undefined {
|
|
164
|
+
switch (value.kind) {
|
|
165
|
+
case "date":
|
|
166
|
+
return value.date;
|
|
167
|
+
case "utc":
|
|
168
|
+
return value.instant;
|
|
169
|
+
case "zoned":
|
|
170
|
+
return value.zoned.toInstant();
|
|
171
|
+
case "floating":
|
|
172
|
+
return value.wallTime;
|
|
173
|
+
case "unresolved":
|
|
174
|
+
return undefined;
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
- **`parseIcsComponents`** splits each line into its name, parameters and raw value. It reads
|
|
180
|
+
content lines inside a component, so the lines are wrapped in a `VEVENT`.
|
|
181
|
+
- **`icsValueTypeOf`** gives the line's value type: its `VALUE` parameter, else DATE-TIME for
|
|
182
|
+
EXDATE and RDATE. **`splitIcsValues`** splits a line that lists several dates, and
|
|
183
|
+
**`decodeIcsDateValue`** reads each one, in the zone `TZID` names.
|
|
184
|
+
- **Dates of another kind** are fine. A UTC EXDATE on a series in Berlin, or a date-only one that
|
|
185
|
+
excludes a whole day, converts when the series is expanded.
|
|
186
|
+
- **What it leaves out** goes to `problems`: EXRULE, which RFC 5545 deprecated, RDATE periods, and
|
|
187
|
+
dates it can't read. The rest of the series still shows.
|
|
188
|
+
|
|
189
|
+
## Map the events
|
|
190
|
+
|
|
191
|
+
Masters get their recurrence, changed and cancelled occurrences become overrides, and everything
|
|
192
|
+
else is a one-off event:
|
|
193
|
+
|
|
194
|
+
```ts title="google-calendar.ts"
|
|
195
|
+
/**
|
|
196
|
+
* Events from `events.list` without `singleEvents`: masters with `recurrence`, occurrences that
|
|
197
|
+
* changed or were cancelled with `recurringEventId`, and one-off events.
|
|
198
|
+
*/
|
|
199
|
+
export function fromGoogleEvents(items: readonly GoogleEvent[]): {
|
|
200
|
+
readonly events: readonly GoogleCalendarEvent[];
|
|
201
|
+
readonly problems: readonly string[];
|
|
202
|
+
} {
|
|
203
|
+
const events: GoogleCalendarEvent[] = [];
|
|
204
|
+
const problems: string[] = [];
|
|
205
|
+
|
|
206
|
+
for (const item of items) {
|
|
207
|
+
const base = { data: item, id: item.id, title: item.summary ?? "(No title)" };
|
|
208
|
+
|
|
209
|
+
if (item.recurringEventId !== undefined) {
|
|
210
|
+
// An occurrence that changed, or was cancelled, which Google returns without times.
|
|
211
|
+
const recurrenceId = item.originalStartTime && pointOf(item.originalStartTime);
|
|
212
|
+
const interval = intervalOf(item.start, item.end) ?? recurrenceId?.interval;
|
|
213
|
+
if (recurrenceId === undefined || interval === undefined) {
|
|
214
|
+
problems.push(`${item.id}: no original start`);
|
|
215
|
+
continue;
|
|
216
|
+
}
|
|
217
|
+
const cancelled = item.status === "cancelled";
|
|
218
|
+
events.push({
|
|
219
|
+
...base,
|
|
220
|
+
...interval,
|
|
221
|
+
override: { cancelled, recurrenceId: recurrenceId.date, seriesId: item.recurringEventId },
|
|
222
|
+
});
|
|
223
|
+
continue;
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
if (item.status === "cancelled") continue;
|
|
227
|
+
const interval = intervalOf(item.start, item.end);
|
|
228
|
+
if (interval === undefined) {
|
|
229
|
+
problems.push(`${item.id}: no start or end`);
|
|
230
|
+
continue;
|
|
231
|
+
}
|
|
232
|
+
if (item.recurrence === undefined) {
|
|
233
|
+
events.push({ ...base, ...interval });
|
|
234
|
+
continue;
|
|
235
|
+
}
|
|
236
|
+
const { problems: lines, recurrence } = readGoogleRecurrence(item.recurrence);
|
|
237
|
+
problems.push(...lines.map((problem) => `${item.id}: ${problem}`));
|
|
238
|
+
events.push({ ...base, ...interval, recurrence });
|
|
239
|
+
}
|
|
240
|
+
return { events, problems };
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
function intervalOf(
|
|
244
|
+
start: GoogleEventTime | undefined,
|
|
245
|
+
end: GoogleEventTime | undefined,
|
|
246
|
+
): CalendarEventInterval | undefined {
|
|
247
|
+
if (start?.date !== undefined && end?.date !== undefined) {
|
|
248
|
+
const [from, to] = [Temporal.PlainDate.from(start.date), Temporal.PlainDate.from(end.date)];
|
|
249
|
+
return { end: to, kind: "all-day", start: from };
|
|
250
|
+
}
|
|
251
|
+
if (start?.dateTime === undefined || end?.dateTime === undefined) return undefined;
|
|
252
|
+
const timeZone = start.timeZone;
|
|
253
|
+
return {
|
|
254
|
+
end: instantOf(end.dateTime, end.timeZone ?? timeZone),
|
|
255
|
+
kind: "timed",
|
|
256
|
+
start: instantOf(start.dateTime, timeZone),
|
|
257
|
+
// A series repeats on this zone's wall clock, so 09:00 stays 09:00 across DST.
|
|
258
|
+
...(timeZone === undefined ? {} : { sourceTimeZone: timeZone }),
|
|
259
|
+
};
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
/** `originalStartTime` as a recurrence ID, and an interval there for a cancelled occurrence. */
|
|
263
|
+
function pointOf(time: GoogleEventTime) {
|
|
264
|
+
const interval = intervalOf(time, time);
|
|
265
|
+
return interval && { date: interval.start, interval };
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
function instantOf(dateTime: string, timeZone: string | undefined): Temporal.Instant {
|
|
269
|
+
// "2026-10-12T09:00:00+02:00" has its offset; "2026-10-12T09:00:00" is a wall time in timeZone.
|
|
270
|
+
return /(?:Z|[+-]\d{2}:\d{2})$/i.test(dateTime)
|
|
271
|
+
? Temporal.Instant.from(dateTime)
|
|
272
|
+
: Temporal.PlainDateTime.from(dateTime)
|
|
273
|
+
.toZonedDateTime(timeZone ?? "UTC")
|
|
274
|
+
.toInstant();
|
|
275
|
+
}
|
|
276
|
+
```
|
|
277
|
+
|
|
278
|
+
- **Times.** `start.dateTime` is RFC 3339, and may leave out its offset when `timeZone` is set, so
|
|
279
|
+
`instantOf` reads it in that zone. `start.date` makes an all-day event, whose `end.date` is
|
|
280
|
+
exclusive, as the calendar's is.
|
|
281
|
+
- **The zone a series repeats in** is `start.timeZone`, which Google requires on recurring events.
|
|
282
|
+
It becomes `sourceTimeZone`, so a 09:00 meeting stays at 09:00 across daylight saving time.
|
|
283
|
+
- **Overrides** keep Google's instance IDs as their own. The calendar shows them under the ID of
|
|
284
|
+
the occurrence they replace, such as `standup::2026-10-20T07:00:00Z`, before and after their
|
|
285
|
+
master loads.
|
|
286
|
+
- **Cancelled occurrences** have no times, so they're placed at their original start. A cancelled
|
|
287
|
+
override only hides its occurrence and never shows, so its length doesn't matter.
|
|
288
|
+
|
|
289
|
+
Give the events to the calendar with the canonical adapters, as the
|
|
290
|
+
[guide](./recurring-events.md#wire-the-adapters) does:
|
|
291
|
+
|
|
292
|
+
```ts
|
|
293
|
+
import {
|
|
294
|
+
createCanonicalRecurrenceAdapter,
|
|
295
|
+
createOccurrenceExpander,
|
|
296
|
+
} from "@moltenship/calendar-recurrence";
|
|
297
|
+
|
|
298
|
+
const adapters = createCanonicalRecurrenceAdapter<GoogleEvent>();
|
|
299
|
+
const expander = createOccurrenceExpander(adapters);
|
|
300
|
+
|
|
301
|
+
const { events, problems } = fromGoogleEvents(response.items);
|
|
302
|
+
```
|
|
303
|
+
|
|
304
|
+
Google returns an event list a page at a time, with `nextPageToken`. Read every page before you
|
|
305
|
+
expand: a master on one page and its overrides on another are one series.
|
|
306
|
+
|
|
307
|
+
## Write changes back
|
|
308
|
+
|
|
309
|
+
An edit from `resolveRecurrenceEdit` writes the master's whole recurrence. Google stores it as the
|
|
310
|
+
master's `recurrence` lines, so write them back in Google's format:
|
|
311
|
+
|
|
312
|
+
```ts title="google-calendar.ts"
|
|
313
|
+
/**
|
|
314
|
+
* A series' recurrence as Google's `recurrence` lines, such as the one an edit writes. Instants
|
|
315
|
+
* are written on the series' wall clock when it has a time zone.
|
|
316
|
+
*/
|
|
317
|
+
export function toGoogleRecurrence(
|
|
318
|
+
recurrence: EventRecurrence,
|
|
319
|
+
timeZone: string | undefined,
|
|
320
|
+
): string[] {
|
|
321
|
+
const lines =
|
|
322
|
+
recurrence.rule === undefined ? [] : [`RRULE:${formatRecurrenceRule(recurrence.rule)}`];
|
|
323
|
+
for (const date of recurrence.exceptionDates ?? [])
|
|
324
|
+
lines.push(`EXDATE${dateText(date, timeZone)}`);
|
|
325
|
+
for (const date of recurrence.recurrenceDates ?? []) {
|
|
326
|
+
// This mapping reads no RDATE periods, so edits write none.
|
|
327
|
+
if ("start" in date) continue;
|
|
328
|
+
lines.push(`RDATE${dateText(date, timeZone)}`);
|
|
329
|
+
}
|
|
330
|
+
return lines;
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
function dateText(date: RecurrenceDate, timeZone: string | undefined): string {
|
|
334
|
+
if (date instanceof Temporal.PlainDate) {
|
|
335
|
+
return `;VALUE=DATE:${encodeIcsValue("DATE", { date, kind: "date" })}`;
|
|
336
|
+
}
|
|
337
|
+
if (date instanceof Temporal.PlainDateTime) {
|
|
338
|
+
return `:${encodeIcsValue("DATE-TIME", { kind: "floating", wallTime: date })}`;
|
|
339
|
+
}
|
|
340
|
+
if (timeZone === undefined)
|
|
341
|
+
return `:${encodeIcsValue("DATE-TIME", { instant: date, kind: "utc" })}`;
|
|
342
|
+
const wallTime = date.toZonedDateTimeISO(timeZone).toPlainDateTime();
|
|
343
|
+
return `;TZID=${timeZone}:${encodeIcsValue("DATE-TIME", { kind: "floating", wallTime })}`;
|
|
344
|
+
}
|
|
345
|
+
```
|
|
346
|
+
|
|
347
|
+
`formatRecurrenceRule` writes the rule's value without the `RRULE:` prefix, so the line adds it.
|
|
348
|
+
Exception dates are written on the series' wall clock, with its `TZID`, as Google writes them.
|
|
349
|
+
|
|
350
|
+
Apply the edit to your copy of the events with `applyRecurrenceEdit`, as the guide does, and send
|
|
351
|
+
its writes to Google:
|
|
352
|
+
|
|
353
|
+
| The edit says | In the Calendar API |
|
|
354
|
+
| ------------------------------------- | --------------------------------------------------------------------------------------------- |
|
|
355
|
+
| `series.action: "update"` | Patch the master: `start` and `end` from `placement`, `recurrence` from `toGoogleRecurrence`. |
|
|
356
|
+
| `series.action: "delete"` | Delete the master, which deletes the whole series. |
|
|
357
|
+
| `newSeries` | Insert a new event, copied from the master, with its own `recurrence`. |
|
|
358
|
+
| `override` (`"create"` or `"update"`) | Patch the occurrence: the instance whose `originalStartTime` is the edit's `recurrenceId`. |
|
|
359
|
+
| `override` (`"delete"`) | Delete that instance. |
|
|
360
|
+
|
|
361
|
+
After a write that changes the master, list the series again, so your copy matches what Google
|
|
362
|
+
stored for its other occurrences. [Sync with Google Calendar](./google-calendar-sync.md)
|
|
363
|
+
does this with sync tokens, and writes with etags.
|
|
364
|
+
|
|
365
|
+
A "This event" delete adds an EXDATE line to the master, which Google reads like any other
|
|
366
|
+
`recurrence` line. Google records a deleted occurrence as a cancelled instance instead;
|
|
367
|
+
`fromGoogleEvents` reads both.
|