@moltenship/calendar 2.0.0-beta.1 → 2.0.0
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 +11 -10
- package/dist/index.d.mts +2 -2
- package/dist/index.mjs +2 -2
- package/docs/accessibility.md +5 -4
- package/docs/agents/changes.md +3 -3
- package/docs/agents/coding-agents.md +19 -20
- package/docs/agents/connect.md +20 -11
- package/docs/agents/deleting.md +2 -2
- package/docs/agents/reference.md +5 -6
- package/docs/agents/server.md +4 -4
- package/docs/agents/webmcp.md +2 -2
- package/docs/agents.md +10 -8
- package/docs/annotations.md +10 -8
- package/docs/api/changes.md +37 -21
- package/docs/api/{react.md → components.md} +65 -56
- package/docs/api/dnd-kit.md +1 -3
- package/docs/api/events.md +14 -13
- package/docs/api/primitives.md +61 -11
- package/docs/api/store.md +3 -3
- package/docs/api.md +23 -23
- package/docs/availability.md +25 -22
- package/docs/comparison.md +23 -24
- package/docs/concepts/anatomy.md +3 -3
- package/docs/concepts/events.md +2 -3
- package/docs/concepts/how-it-works.md +33 -16
- package/docs/concepts/state.md +1 -1
- package/docs/concepts/time.md +5 -7
- package/docs/customization.md +271 -0
- package/docs/frameworks.md +116 -0
- package/docs/guides/dnd-kit.md +2 -2
- package/docs/guides/google-calendar-sync.md +3 -3
- package/docs/guides/google-calendar.md +4 -4
- package/docs/guides/motion.md +2 -2
- package/docs/guides/nextjs-app-router.md +1 -1
- package/docs/guides/nextjs.md +1 -1
- package/docs/guides/performance.md +6 -6
- package/docs/guides/tanstack-query.md +2 -2
- package/docs/{guides/ics.md → ics/feed.md} +7 -9
- package/docs/ics/import.md +183 -0
- package/docs/{api/ics.md → ics/reference.md} +11 -53
- package/docs/ics.md +142 -0
- package/docs/index.md +81 -50
- package/docs/installation.md +48 -33
- package/docs/interactions.md +36 -3
- package/docs/llms.txt +81 -68
- package/docs/migrating-to-2.md +200 -25
- package/docs/quick-start.md +27 -23
- package/docs/{guides/recurring-events.md → recurrence/calendar.md} +23 -8
- package/docs/{concepts/recurrence.md → recurrence/model.md} +13 -12
- package/docs/{api/recurrence.md → recurrence/reference.md} +22 -61
- package/docs/recurrence.md +122 -0
- package/docs/stylex.md +74 -49
- package/docs/temporal/daylight-saving-time.md +172 -0
- package/docs/temporal/month-grid.md +119 -0
- package/docs/{api/temporal.md → temporal/reference.md} +7 -12
- package/docs/temporal.md +105 -0
- package/docs/testing.md +20 -1
- package/docs/theme-builder.md +9 -8
- package/docs/theming.md +108 -2
- package/docs/undo-redo.md +24 -16
- package/docs/views/agenda.md +14 -13
- package/docs/views/custom-views.md +13 -10
- package/docs/views/month.md +10 -9
- package/docs/views/resource-columns.md +21 -17
- package/docs/views/resource-timeline.md +16 -15
- package/docs/views/scrolling.md +7 -6
- package/docs/views/week-and-day.md +15 -14
- package/docs/views/year.md +11 -11
- package/docs/views.md +1 -1
- package/package.json +7 -6
- package/skills/moltenship-time/SKILL.md +7 -5
- package/skills/moltenship-time/references/compose.md +13 -6
- package/skills/moltenship-time/references/mistakes.md +4 -2
- package/skills/moltenship-time/references/solid.md +36 -25
- package/docs/api/solid.md +0 -460
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
# Read an .ics file
|
|
2
|
+
|
|
3
|
+
Parse an iCalendar file a person picks or uploads, report its problems with their lines, and turn its dates into instants.
|
|
4
|
+
|
|
5
|
+
Source: https://time.molten.sh/docs/react/ics/import
|
|
6
|
+
|
|
7
|
+
A person exports a calendar from Google Calendar or Outlook and gives your app the `.ics` file.
|
|
8
|
+
This page reads it in the browser, tells the person what the file got wrong, and checks an upload
|
|
9
|
+
on a server. Nothing here needs the calendar or a UI framework.
|
|
10
|
+
|
|
11
|
+
## Read the file
|
|
12
|
+
|
|
13
|
+
`readIcsFile` takes the `File` from an `<input type="file">` or a drop, and the viewer's time
|
|
14
|
+
zone. It returns the events with their times as instants, and a line for each problem:
|
|
15
|
+
|
|
16
|
+
```ts title="read-ics-file.ts"
|
|
17
|
+
import { getEventEnd, parseIcs, type IcsDateValue, type IcsIssue } from "@moltenship/ics";
|
|
18
|
+
|
|
19
|
+
export interface ImportedEvent {
|
|
20
|
+
readonly id: string;
|
|
21
|
+
readonly title: string;
|
|
22
|
+
readonly allDay: boolean;
|
|
23
|
+
readonly start: Temporal.Instant;
|
|
24
|
+
readonly end: Temporal.Instant;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export interface ImportResult {
|
|
28
|
+
readonly events: readonly ImportedEvent[];
|
|
29
|
+
/** What to tell the person about the file, one line per problem. */
|
|
30
|
+
readonly problems: readonly string[];
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export async function readIcsFile(file: File, viewerTimeZone: string): Promise<ImportResult> {
|
|
34
|
+
// `File.text()` decodes the bytes as UTF-8, the encoding iCalendar files use.
|
|
35
|
+
const { calendars, issues } = parseIcs(await file.text());
|
|
36
|
+
|
|
37
|
+
const events = calendars.flatMap((calendar) => {
|
|
38
|
+
// Times without a zone are read in the file's X-WR-TIMEZONE, else in the viewer's zone.
|
|
39
|
+
const timeZone = calendar.timeZone ?? viewerTimeZone;
|
|
40
|
+
return calendar.events.map((event) => ({
|
|
41
|
+
id: event.uid,
|
|
42
|
+
title: event.summary ?? "Untitled",
|
|
43
|
+
allDay: event.start.kind === "date",
|
|
44
|
+
start: toInstant(event.start, timeZone),
|
|
45
|
+
end: toInstant(getEventEnd(event), timeZone),
|
|
46
|
+
}));
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
return { events, problems: issues.filter(isError).map(describe) };
|
|
50
|
+
}
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
`parseIcs` takes a string, not bytes. `File.text()` decodes the file as UTF-8, which is the
|
|
54
|
+
encoding RFC 5545 names as the default. Read a `Response` with `response.text()`, and other bytes
|
|
55
|
+
with `new TextDecoder().decode(bytes)`.
|
|
56
|
+
|
|
57
|
+
A file can hold more than one VCALENDAR, so the function reads every calendar in `calendars`.
|
|
58
|
+
|
|
59
|
+
## Turn dates into instants
|
|
60
|
+
|
|
61
|
+
An ICS start is one of five shapes, and `kind` says which. Two of them are instants already. The
|
|
62
|
+
other three need a time zone, which you choose:
|
|
63
|
+
|
|
64
|
+
```ts title="read-ics-file.ts"
|
|
65
|
+
function toInstant(value: IcsDateValue, timeZone: string): Temporal.Instant {
|
|
66
|
+
switch (value.kind) {
|
|
67
|
+
case "utc":
|
|
68
|
+
return value.instant;
|
|
69
|
+
case "zoned":
|
|
70
|
+
return value.zoned.toInstant();
|
|
71
|
+
case "date":
|
|
72
|
+
// An all-day event starts when its date starts in the chosen zone.
|
|
73
|
+
return value.date.toZonedDateTime(timeZone).toInstant();
|
|
74
|
+
case "floating":
|
|
75
|
+
case "unresolved":
|
|
76
|
+
return value.wallTime.toZonedDateTime(timeZone).toInstant();
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
| `kind` | The file wrote | How the function reads it |
|
|
82
|
+
| ------------ | ------------------------------------- | -------------------------------------------- |
|
|
83
|
+
| `utc` | A time in UTC, ending in `Z` | The instant itself |
|
|
84
|
+
| `zoned` | A time with a `TZID` the parser knows | The instant in that zone |
|
|
85
|
+
| `date` | A date, for an all-day event | The start of that date in the zone you chose |
|
|
86
|
+
| `floating` | A time with no zone | That wall time in the zone you chose |
|
|
87
|
+
| `unresolved` | A time with a `TZID` nobody knows | That wall time in the zone you chose |
|
|
88
|
+
|
|
89
|
+
The parser never falls back to the host's time zone, so the choice is in your code. This function
|
|
90
|
+
uses the calendar's `X-WR-TIMEZONE`, which Google Calendar writes, and the viewer's zone when the
|
|
91
|
+
file has none. [Time zones](./reference.md#time-zones) lists how a `TZID` is resolved,
|
|
92
|
+
Outlook's Windows names included.
|
|
93
|
+
|
|
94
|
+
`getEventEnd` returns the end in the start's kind: the file's `DTEND`, or the start plus
|
|
95
|
+
`DURATION`. An event with neither ends the next day when it's all-day, and when it starts when it's
|
|
96
|
+
timed, so give such an event a length of your own before you show it.
|
|
97
|
+
|
|
98
|
+
An all-day event keeps its date in `event.start.date`. Keep that `Temporal.PlainDate` instead of
|
|
99
|
+
an instant if your app shows all-day events on a date, as the calendar does.
|
|
100
|
+
|
|
101
|
+
## Tell the person what went wrong
|
|
102
|
+
|
|
103
|
+
The parser is lenient. It keeps every event it can read and lists what it couldn't in `issues`. An
|
|
104
|
+
issue with the severity `"error"` dropped a value or a whole component, and one with `"warning"`
|
|
105
|
+
kept a value read leniently. Each has the line it came from, when it came from one:
|
|
106
|
+
|
|
107
|
+
```ts title="read-ics-file.ts"
|
|
108
|
+
function isError(issue: IcsIssue): boolean {
|
|
109
|
+
return issue.severity === "error";
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
function describe(issue: IcsIssue): string {
|
|
113
|
+
return issue.line === undefined ? issue.message : `Line ${issue.line}: ${issue.message}`;
|
|
114
|
+
}
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
For a file whose second event has no `DTSTART`, `problems` holds one line, and `events` holds the
|
|
118
|
+
other events:
|
|
119
|
+
|
|
120
|
+
```text
|
|
121
|
+
Line 9: VEVENT has no DTSTART; skipped
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
[Issues and strict mode](./reference.md#issues-and-strict-mode) lists every code.
|
|
125
|
+
|
|
126
|
+
## Refuse a file with errors
|
|
127
|
+
|
|
128
|
+
To import all of a file or none of it, parse with `strict: true`. The parser then throws an
|
|
129
|
+
`IcsParseError` when the text has an error. Its `message` is the first error's, with a count of the
|
|
130
|
+
others, and its `issues` lists them all. Warnings never throw:
|
|
131
|
+
|
|
132
|
+
```ts title="read-strictly.ts"
|
|
133
|
+
import { IcsParseError } from "@moltenship/ics";
|
|
134
|
+
|
|
135
|
+
/** The file's calendars, or the reason the file is refused. */
|
|
136
|
+
export function readStrictly(text: string) {
|
|
137
|
+
try {
|
|
138
|
+
return { ok: true as const, calendars: parseIcs(text, { strict: true }).calendars };
|
|
139
|
+
} catch (error) {
|
|
140
|
+
if (!(error instanceof IcsParseError)) throw error;
|
|
141
|
+
return { ok: false as const, reason: error.message, issues: error.issues };
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
Text without a VCALENDAR is an error too, so this also refuses a file that isn't a calendar.
|
|
147
|
+
|
|
148
|
+
## Check an upload on a server
|
|
149
|
+
|
|
150
|
+
A parser is a [Standard Schema](https://standardschema.dev): its `validate` fails with the errors,
|
|
151
|
+
or succeeds with the parse result. A value that isn't a string fails as well, so a form without a
|
|
152
|
+
file gets the same answer as a bad file. This handler runs wherever `Request` and `Response` do:
|
|
153
|
+
|
|
154
|
+
```ts title="route.ts"
|
|
155
|
+
import { createIcsParser } from "@moltenship/ics";
|
|
156
|
+
|
|
157
|
+
const parser = createIcsParser();
|
|
158
|
+
|
|
159
|
+
/** A route handler for a form with an `<input type="file" name="calendar">`. */
|
|
160
|
+
export async function POST(request: Request): Promise<Response> {
|
|
161
|
+
const file = (await request.formData()).get("calendar");
|
|
162
|
+
const body = file instanceof File ? await file.text() : undefined;
|
|
163
|
+
|
|
164
|
+
// A parser is a Standard Schema: it fails with the errors, or succeeds with the result.
|
|
165
|
+
const result = await parser["~standard"].validate(body);
|
|
166
|
+
if (result.issues) {
|
|
167
|
+
return Response.json({ errors: result.issues.map((issue) => issue.message) }, { status: 400 });
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
const events = result.value.calendars.flatMap((calendar) => calendar.events);
|
|
171
|
+
return Response.json({ imported: events.length });
|
|
172
|
+
}
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
Anything that takes a Standard Schema takes the parser the same way, such as a form library or a
|
|
176
|
+
router's body validation.
|
|
177
|
+
|
|
178
|
+
## Recurring events
|
|
179
|
+
|
|
180
|
+
A recurring event arrives as one event with a `recurrenceRule`, and each changed occurrence as
|
|
181
|
+
another event with the same `uid` and a `recurrenceId`. So `uid` alone doesn't identify an event
|
|
182
|
+
in a file with series. [`@moltenship/calendar-recurrence`](../recurrence.md) groups such events
|
|
183
|
+
into series with `recurringEventsFromIcs` and lists their occurrences for a range of dates.
|
|
@@ -1,50 +1,13 @@
|
|
|
1
|
-
#
|
|
1
|
+
# API reference
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Everything @moltenship/ics exports. Calendars and events, dates and time zones, issues and strict mode, extensions, and the lower layers.
|
|
4
4
|
|
|
5
|
-
Source: https://time.molten.sh/docs/
|
|
5
|
+
Source: https://time.molten.sh/docs/react/ics/reference
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
Calendars, events, to-dos, journals, free/busy and time zones come out, with dates and times as
|
|
10
|
-
Temporal values and every problem in the text listed with its line.
|
|
7
|
+
Everything on this page is exported from `@moltenship/ics`. The [Overview](../ics.md) has the
|
|
8
|
+
install command and a first example.
|
|
11
9
|
|
|
12
|
-
|
|
13
|
-
Moltenship package, so you can use it without the calendar: on a server, in a worker, or in a
|
|
14
|
-
script. It has no dependencies.
|
|
15
|
-
|
|
16
|
-
To show a feed's events in the calendar, follow [Show an ICS feed](../guides/ics.md).
|
|
17
|
-
|
|
18
|
-
## Install
|
|
19
|
-
|
|
20
|
-
Like the calendar, `@moltenship/ics` is on npm as a release candidate for 1.0.0.
|
|
21
|
-
|
|
22
|
-
**pnpm**
|
|
23
|
-
|
|
24
|
-
```bash
|
|
25
|
-
pnpm add @moltenship/ics
|
|
26
|
-
```
|
|
27
|
-
|
|
28
|
-
**npm**
|
|
29
|
-
|
|
30
|
-
```bash
|
|
31
|
-
npm install @moltenship/ics
|
|
32
|
-
```
|
|
33
|
-
|
|
34
|
-
**yarn**
|
|
35
|
-
|
|
36
|
-
```bash
|
|
37
|
-
yarn add @moltenship/ics
|
|
38
|
-
```
|
|
39
|
-
|
|
40
|
-
**bun**
|
|
41
|
-
|
|
42
|
-
```bash
|
|
43
|
-
bun add @moltenship/ics
|
|
44
|
-
```
|
|
45
|
-
|
|
46
|
-
It needs the same setup as the calendar: a runtime with `Temporal`, or a polyfill loaded first,
|
|
47
|
-
and TypeScript's `ESNext` library. See [Installation](../installation.md#temporal).
|
|
10
|
+
To show a feed's events in the calendar, follow [Show an ICS feed](./feed.md).
|
|
48
11
|
|
|
49
12
|
## Parse
|
|
50
13
|
|
|
@@ -59,12 +22,6 @@ for (const event of calendars[0]?.events ?? []) {
|
|
|
59
22
|
}
|
|
60
23
|
```
|
|
61
24
|
|
|
62
|
-
Edit the text below to see what `parseIcs` returns. The sample is a Google Calendar feed with a
|
|
63
|
-
recurring meeting, an all-day event, an event imported from Outlook, and one date written the way
|
|
64
|
-
a careless exporter writes it.
|
|
65
|
-
|
|
66
|
-
> Live example: see it at https://time.molten.sh/docs/api/ics
|
|
67
|
-
|
|
68
25
|
`parseIcs(text, options)` returns two lists:
|
|
69
26
|
|
|
70
27
|
- `calendars`: every VCALENDAR in the text, usually one. Their components keep the order of the
|
|
@@ -295,11 +252,12 @@ event.exceptionDates;
|
|
|
295
252
|
the override also applies to the occurrences after it.
|
|
296
253
|
|
|
297
254
|
This package parses rules but doesn't list a series' occurrences.
|
|
298
|
-
[`@moltenship/calendar-recurrence`](
|
|
255
|
+
[`@moltenship/calendar-recurrence`](../recurrence.md) does: `recurringEventsFromIcs` groups
|
|
299
256
|
parsed events into series masters, overrides and one-off events, and its expander lists the
|
|
300
257
|
occurrences for a range of dates. It applies an override with `RANGE=THISANDFUTURE` to the
|
|
301
|
-
occurrences after it too, by splitting the series.
|
|
302
|
-
|
|
258
|
+
occurrences after it too, by splitting the series.
|
|
259
|
+
|
|
260
|
+
See [Recurring events](./feed.md#recurring-events) in the feed guide.
|
|
303
261
|
|
|
304
262
|
## Issues and strict mode
|
|
305
263
|
|
|
@@ -517,7 +475,7 @@ them.
|
|
|
517
475
|
- **Writing ICS from typed objects.** `stringifyIcsComponents` writes a syntax tree, which you
|
|
518
476
|
build yourself.
|
|
519
477
|
- **Recurrence expansion.** Rules are parsed into `IcsRecurrenceRule`, not expanded into
|
|
520
|
-
occurrences. [`@moltenship/calendar-recurrence`](
|
|
478
|
+
occurrences. [`@moltenship/calendar-recurrence`](../recurrence/reference.md) expands them, so this
|
|
521
479
|
package stays free of dependencies.
|
|
522
480
|
- **Byte input.** `parseIcs` takes a string. Decode bytes as UTF-8 first, for example with
|
|
523
481
|
`response.text()` or `new TextDecoder().decode(bytes)`. A line fold that splits a multi-byte
|
package/docs/ics.md
ADDED
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
# Overview
|
|
2
|
+
|
|
3
|
+
What @moltenship/ics is, how to install it, and a first parse of iCalendar text into Temporal values.
|
|
4
|
+
|
|
5
|
+
Source: https://time.molten.sh/docs/react/ics
|
|
6
|
+
|
|
7
|
+
`@moltenship/ics` reads iCalendar (RFC 5545), the text format of calendar feeds, invitations and
|
|
8
|
+
exports from Google Calendar, Outlook, iCloud and most other calendar apps. ICS text goes in.
|
|
9
|
+
Calendars, events, to-dos, journals, free/busy and time zones come out, with dates and times as
|
|
10
|
+
`Temporal` values and every problem in the text listed with its line.
|
|
11
|
+
|
|
12
|
+
## Use it without the calendar
|
|
13
|
+
|
|
14
|
+
The package imports no other Moltenship package, no UI framework and no dependency. It runs
|
|
15
|
+
wherever `Temporal` does: in a browser, on a server, in a worker or in a script. An app that never
|
|
16
|
+
renders a calendar can use it to read a feed, check an upload or convert an export.
|
|
17
|
+
|
|
18
|
+
`@moltenship/calendar` doesn't re-export it, so install it by its own name.
|
|
19
|
+
|
|
20
|
+
## Install
|
|
21
|
+
|
|
22
|
+
**pnpm**
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
pnpm add @moltenship/ics
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
**npm**
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
npm install @moltenship/ics
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
**yarn**
|
|
35
|
+
|
|
36
|
+
```bash
|
|
37
|
+
yarn add @moltenship/ics
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
**bun**
|
|
41
|
+
|
|
42
|
+
```bash
|
|
43
|
+
bun add @moltenship/ics
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
The package is versioned with the calendar.
|
|
47
|
+
|
|
48
|
+
It needs a runtime with `Temporal`, or a polyfill loaded first, and TypeScript's `ESNext` library.
|
|
49
|
+
[Installation](./installation.md#temporal) shows both.
|
|
50
|
+
|
|
51
|
+
## Parse a calendar
|
|
52
|
+
|
|
53
|
+
`parseIcs` takes the text and returns its calendars. `getEventEnd` works out when an event ends,
|
|
54
|
+
from its `DTEND` or its `DURATION`:
|
|
55
|
+
|
|
56
|
+
```ts title="describe-events.ts"
|
|
57
|
+
import { getEventEnd, parseIcs, type IcsDateValue } from "@moltenship/ics";
|
|
58
|
+
|
|
59
|
+
export const text = `BEGIN:VCALENDAR
|
|
60
|
+
VERSION:2.0
|
|
61
|
+
PRODID:-//Example//Team//EN
|
|
62
|
+
BEGIN:VEVENT
|
|
63
|
+
UID:planning@example.com
|
|
64
|
+
DTSTAMP:20261001T080000Z
|
|
65
|
+
DTSTART;TZID=Europe/Berlin:20261012T090000
|
|
66
|
+
DURATION:PT45M
|
|
67
|
+
SUMMARY:Planning
|
|
68
|
+
END:VEVENT
|
|
69
|
+
BEGIN:VEVENT
|
|
70
|
+
UID:offsite@example.com
|
|
71
|
+
DTSTAMP:20261001T080000Z
|
|
72
|
+
DTSTART;VALUE=DATE:20261015
|
|
73
|
+
DTEND;VALUE=DATE:20261017
|
|
74
|
+
SUMMARY:Offsite
|
|
75
|
+
END:VEVENT
|
|
76
|
+
END:VCALENDAR`;
|
|
77
|
+
|
|
78
|
+
// A date or a time, as the file wrote it.
|
|
79
|
+
function show(value: IcsDateValue): string {
|
|
80
|
+
switch (value.kind) {
|
|
81
|
+
case "date":
|
|
82
|
+
return value.date.toString();
|
|
83
|
+
case "utc":
|
|
84
|
+
return value.instant.toString();
|
|
85
|
+
case "zoned":
|
|
86
|
+
return value.zoned.toString();
|
|
87
|
+
case "floating":
|
|
88
|
+
case "unresolved":
|
|
89
|
+
return value.wallTime.toString();
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
export function describeEvents(ics: string): string[] {
|
|
94
|
+
const { calendars } = parseIcs(ics);
|
|
95
|
+
const events = calendars[0]?.events ?? [];
|
|
96
|
+
// getEventEnd reads DTEND, or adds DURATION to the start.
|
|
97
|
+
return events.map(
|
|
98
|
+
(event) => `${event.summary}: ${show(event.start)} to ${show(getEventEnd(event))}`,
|
|
99
|
+
);
|
|
100
|
+
}
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
`describeEvents(text)` returns these lines:
|
|
104
|
+
|
|
105
|
+
```text
|
|
106
|
+
Planning: 2026-10-12T09:00:00+02:00[Europe/Berlin] to 2026-10-12T09:45:00+02:00[Europe/Berlin]
|
|
107
|
+
Offsite: 2026-10-15 to 2026-10-17
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
The first event names a time zone, so its start is a `Temporal.ZonedDateTime`. The second is an
|
|
111
|
+
all-day event, so its start is a `Temporal.PlainDate`, and its end is the day after its last day,
|
|
112
|
+
as the file wrote it. A start's `kind` says which of five shapes the file used, and
|
|
113
|
+
[Dates and times](./ics/reference.md#dates-and-times) lists them.
|
|
114
|
+
|
|
115
|
+
## Try it
|
|
116
|
+
|
|
117
|
+
Edit the text below to see what `parseIcs` returns. The sample is a Google Calendar feed with a
|
|
118
|
+
recurring meeting, an all-day event, an event imported from Outlook, and one date written the way
|
|
119
|
+
a careless exporter writes it.
|
|
120
|
+
|
|
121
|
+
> Live example: see it at https://time.molten.sh/docs/react/ics
|
|
122
|
+
|
|
123
|
+
## What it does with bad text
|
|
124
|
+
|
|
125
|
+
Parsing is lenient. The parser keeps what it can read, skips a component it can't type, such as an
|
|
126
|
+
event without `UID` or `DTSTART`, and reports each problem in `issues` with its line. Bad text
|
|
127
|
+
never throws. With `strict: true`, an error throws an `IcsParseError` instead.
|
|
128
|
+
[Read an .ics file](./ics/import.md) shows both ways.
|
|
129
|
+
|
|
130
|
+
## What it doesn't do
|
|
131
|
+
|
|
132
|
+
- **It doesn't expand recurring events.** A rule is parsed into an `IcsRecurrenceRule`, and its
|
|
133
|
+
occurrences aren't listed. [`@moltenship/calendar-recurrence`](./recurrence.md) lists them.
|
|
134
|
+
- **It doesn't write ICS from typed objects.** `stringifyIcsComponents` writes a syntax tree you
|
|
135
|
+
build yourself.
|
|
136
|
+
- **It doesn't read bytes.** `parseIcs` takes a string, so decode the bytes as UTF-8 first.
|
|
137
|
+
|
|
138
|
+
## Next
|
|
139
|
+
|
|
140
|
+
- [Read an .ics file](./ics/import.md): Parse a file a person picks, report its problems, and turn its dates into instants.
|
|
141
|
+
- [Show an ICS feed](./ics/feed.md): Fetch a feed on the server and show its events in the calendar.
|
|
142
|
+
- [API reference](./ics/reference.md): Every field of a calendar and an event, time zones, issues, extensions and the lower layers.
|
package/docs/index.md
CHANGED
|
@@ -1,25 +1,30 @@
|
|
|
1
1
|
# Introduction
|
|
2
2
|
|
|
3
|
-
A
|
|
3
|
+
A calendar engine on the Temporal API, rendered in React and in SolidJS 2, with actions an AI agent can call.
|
|
4
4
|
|
|
5
|
-
Source: https://time.molten.sh/docs
|
|
5
|
+
Source: https://time.molten.sh/docs/react
|
|
6
6
|
|
|
7
|
-
Moltenship Time
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
7
|
+
Moltenship Time is a calendar for scheduling screens such as bookings, rooms, shifts and team
|
|
8
|
+
calendars. Its engine handles dates, time zones, recurrence, calendar state, event lookups and
|
|
9
|
+
saving changes, and it imports no UI framework. Your events stay in the shape your app already
|
|
10
|
+
uses, and Time reads them through an adapter. An AI agent can read the same calendar and act on it
|
|
11
|
+
through named actions, under rules your app sets.
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
These are the React docs. `@moltenship/calendar` renders the engine in React 19, and the week, day,
|
|
14
|
+
month, year, agenda and resource views are React source files you copy into your app. The select
|
|
15
|
+
at the top of the sidebar switches to the Solid docs.
|
|
14
16
|
|
|
15
|
-
|
|
16
|
-
the same views.
|
|
17
|
+
> Live example: see it at https://time.molten.sh/docs/react
|
|
17
18
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
19
|
+
To see every view with more data, try the [live demo](https://moltenship-time-demo.vercel.app), a
|
|
20
|
+
Google Calendar-style app built from the same views.
|
|
21
|
+
|
|
22
|
+
## Where to start
|
|
23
|
+
|
|
24
|
+
- [Build a calendar](./quick-start.md): Install the package, add the views with the shadcn CLI, and render a week, day, month and agenda calendar.
|
|
25
|
+
- [Let an AI agent use a calendar](./agents.md): What an agent reads, the actions it can call, and the rules your app sets.
|
|
26
|
+
- [Build with a coding agent](./agents/coding-agents.md): These docs as Markdown, llms.txt, and a skill that ships in @moltenship/calendar.
|
|
27
|
+
- [Parse an ICS feed](./ics.md): @moltenship/ics reads iCalendar text into Temporal values, with or without the calendar.
|
|
23
28
|
|
|
24
29
|
## What it looks like
|
|
25
30
|
|
|
@@ -65,54 +70,80 @@ export function TeamCalendar({ meetings }: { readonly meetings: readonly Meeting
|
|
|
65
70
|
|
|
66
71
|
## Who it's for
|
|
67
72
|
|
|
68
|
-
Time is for developers
|
|
69
|
-
want to:
|
|
73
|
+
Time is for developers who build scheduling screens and want to:
|
|
70
74
|
|
|
71
75
|
- keep their existing event data and API,
|
|
72
76
|
- style the calendar with their own design system, or start from shadcn/ui,
|
|
73
77
|
- get time zones and daylight saving time right without writing that math themselves,
|
|
74
78
|
- let an AI agent work with the calendar without handing it the page's markup.
|
|
75
79
|
|
|
76
|
-
The calendar and its views are for React 19. A [SolidJS 2 package](./api/solid.md) renders the
|
|
77
|
-
same calendar without the views, as a preview.
|
|
78
|
-
|
|
79
80
|
[Comparison](./comparison.md) sets Time beside FullCalendar and react-big-calendar, including
|
|
80
81
|
where they're ahead.
|
|
81
82
|
|
|
82
|
-
## What you get
|
|
83
|
+
## What you get
|
|
84
|
+
|
|
85
|
+
The engine, the calendar's state, the keyboard, the gestures and the hooks are the same in React
|
|
86
|
+
and Solid. Solid's registry has every view, in Tailwind CSS, and `calendar-full` installs them
|
|
87
|
+
all. The StyleX views, the testing package and the dnd-kit adapter exist in React only.
|
|
88
|
+
[React and Solid](./frameworks.md) has the full table.
|
|
89
|
+
|
|
90
|
+
- **Your data, read through an adapter.** You describe how to read an ID, a title and a time range
|
|
91
|
+
from your records. TypeScript keeps your record and ID types in every hook and callback.
|
|
92
|
+
- **Three kinds of time.** Timed events use `Temporal.Instant`, all-day events use
|
|
93
|
+
`Temporal.PlainDate`, and floating events use `Temporal.PlainDateTime`. No `Date` objects.
|
|
94
|
+
- **Time zones and daylight saving time.** The engine lays out days that are 23 or 25 hours long,
|
|
95
|
+
and hours that a clock change skips or repeats. See
|
|
96
|
+
[Time and time zones](./concepts/time.md).
|
|
97
|
+
- **Recurrence and iCalendar.** [`@moltenship/calendar-recurrence`](./recurrence.md) expands
|
|
98
|
+
RRULE series inside the dates on screen, and [`@moltenship/ics`](./ics.md) parses ICS feeds.
|
|
99
|
+
Neither imports a framework.
|
|
100
|
+
- **Changes you save.** A move, a resize, a create or a delete arrives as a change in
|
|
101
|
+
`onEventChange`. It shows as pending while it saves, rolls back if saving fails, and passes
|
|
102
|
+
through policies you choose. See [Interactions](./interactions.md).
|
|
103
|
+
- **Controlled or uncontrolled state.** The calendar or your app can own the visible date, the
|
|
104
|
+
view, the time zone, the selection and the focus, one value at a time.
|
|
105
|
+
- **Headless parts.** `Root`, the previous, next and today buttons, `Title` and `ActiveView` render
|
|
106
|
+
plain elements. A view is a strategy and a component.
|
|
107
|
+
[Custom views](./views/custom-views.md) shows how to write one. The registry's views are one UI
|
|
108
|
+
built on these parts, and [Customization](./customization.md) shows how to restyle it, edit it
|
|
109
|
+
or build your own.
|
|
110
|
+
|
|
111
|
+
- **Actions for agents.** A calendar gives an AI agent fourteen actions, and a fifteenth, deleting,
|
|
112
|
+
when you allow it. They describe the calendar, list its events, navigate, switch view, and
|
|
113
|
+
create, rename, move and resize events. An agent sees nothing until your app creates ui-sdk's
|
|
114
|
+
agent bridge. An agent's change goes through your policies and your `onEventChange`, marked as an
|
|
115
|
+
agent's, and the agent gets back how it ended. A browser's built-in agent reaches them through
|
|
116
|
+
WebMCP, an experimental browser API, and a model you run reaches them through `agentTools`.
|
|
117
|
+
See [Agents in your app](./agents.md).
|
|
118
|
+
- **Editing by pointer and keyboard.** `useCalendarPointer` turns drags into moves, resizes and
|
|
119
|
+
creates, with a mouse, a pen or touch, and `useCalendarKeyboard` moves focus through a view and
|
|
120
|
+
moves and resizes events from the keyboard. The `Announcer` says each step to a screen reader.
|
|
121
|
+
See [Changing events](./accessibility.md#changing-events).
|
|
122
|
+
- **Undo and redo.** `createEventHistory` records changes, and `useCalendarHistory` and its
|
|
123
|
+
keyboard shortcuts take them back. See [Undo and redo](./undo-redo.md).
|
|
124
|
+
- **Server rendering.** During server rendering, Time doesn't read the clock, the host time zone or
|
|
125
|
+
`window`, so the server and the browser render the same markup from the same props.
|
|
126
|
+
- **Docs your coding agent can read.** Every page has a Markdown version, at its own address with
|
|
127
|
+
`.md` added, and [`/llms.txt`](https://time.molten.sh/llms.txt) lists them.
|
|
128
|
+
The docs ship inside `@moltenship/calendar`, and a skill teaches a coding agent the library.
|
|
129
|
+
See [Build with a coding
|
|
130
|
+
agent](./agents/coding-agents.md).
|
|
131
|
+
|
|
132
|
+
### Only in React today
|
|
83
133
|
|
|
84
134
|
- **Built-in views.** [Week, day](./views/week-and-day.md), [month](./views/month.md),
|
|
85
135
|
[year](./views/year.md), [agenda](./views/agenda.md),
|
|
86
136
|
[resource columns](./views/resource-columns.md) and
|
|
87
137
|
[resource timeline](./views/resource-timeline.md), plus week, day, month and agenda views that
|
|
88
|
-
[scroll without end](./views/scrolling.md)
|
|
89
|
-
CSS.
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
are handled for you.
|
|
96
|
-
- **Editing.** Moves, resizes, creates, and deletes arrive as changes for you to save. They show
|
|
97
|
-
as pending while they save, roll back if saving fails, and pass through policies you choose. See
|
|
98
|
-
[Interactions](./interactions.md). The built-in views support dragging, resizing, and creating
|
|
99
|
-
events with the mouse, a pen, or touch.
|
|
100
|
-
- **Controlled or uncontrolled state.** The visible date, view, time zone, selection, and focus can
|
|
101
|
-
each be owned by the calendar or by your app.
|
|
102
|
-
- **Headless parts.** `Root`, previous/next/today buttons, `Title`, and `ActiveView` render plain
|
|
103
|
-
elements, and [custom views](./views/custom-views.md) are a strategy plus a component.
|
|
104
|
-
- **Ready for agents.** A calendar gives an AI agent fifteen actions: describe the calendar, list
|
|
105
|
-
its events, navigate, switch view, and create, rename, move, resize and delete events. An
|
|
106
|
-
agent's change goes through your policies and your `onEventChange`, marked as an agent's, and
|
|
107
|
-
the agent gets back how it ended. Deleting is off until you turn it on. It works with the agent
|
|
108
|
-
built into a browser through WebMCP, or with a model you run. See [Agents](./agents.md).
|
|
109
|
-
- **Docs your coding agent can read.** Every page has a Markdown version, the docs ship inside
|
|
110
|
-
the npm package, and a skill teaches a coding agent the library. See
|
|
111
|
-
[Build with a coding agent](./agents/coding-agents.md).
|
|
112
|
-
- **Server rendering.** During server rendering, Time doesn't read the clock, the host time zone, or
|
|
113
|
-
`window`, so the server and the browser render the same markup from the same props.
|
|
138
|
+
[scroll without end](./views/scrolling.md). They are source files built on shadcn/ui and
|
|
139
|
+
Tailwind CSS, or on [StyleX](./stylex.md), with a [theme](./theming.md) of calendar tokens and
|
|
140
|
+
an event color palette.
|
|
141
|
+
- **Editing in the built-in views.** The views bind the pointer and the keyboard, and the
|
|
142
|
+
registry's undo toast offers to take each change back.
|
|
143
|
+
- **A testing package.** [`@moltenship/calendar-testing`](./testing.md) has a fixed clock, typed
|
|
144
|
+
builders, a render harness, and keyboard and pointer drivers.
|
|
114
145
|
|
|
115
146
|
- [Installation](./installation.md): Requirements and setup.
|
|
116
|
-
- [Quick start](./quick-start.md): A week,
|
|
117
|
-
- [
|
|
118
|
-
- [
|
|
147
|
+
- [Quick start](./quick-start.md): A week, day, month and agenda calendar.
|
|
148
|
+
- [React and Solid](./frameworks.md): What the two integrations share, and what each has today.
|
|
149
|
+
- [Concepts](./concepts/how-it-works.md): The packages, events, time and state.
|