@procedures/ics 0.2.3 → 0.4.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/CHANGELOG.md ADDED
@@ -0,0 +1,73 @@
1
+ # @procedures/ics
2
+
3
+ ## 0.4.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 0f1d06e: New iCalendar writer. The function `writeIcs(events, options)` and the pure procedure `ics.write` write a calendar from events. The reader `parseIcs` reads the text back to the same events.
8
+
9
+ - The writer writes `UID`, `DTSTAMP`, `DTSTART`, `DTEND`, `SUMMARY`, `LOCATION`, `DESCRIPTION`, `URL`, `RRULE`, `EXDATE`, `STATUS` and `SEQUENCE`. Each time is in UTC. An all-day event gets `VALUE=DATE`.
10
+ - The options set `PRODID`, `METHOD`, `CALSCALE`, `X-WR-CALNAME` and the `DTSTAMP`. `VERSION` is always `2.0`.
11
+ - The writer escapes `\`, `;`, `,` and each line break in a text value. It folds each line at 75 octets of UTF-8 and does not divide a character. Each line ends with CRLF.
12
+ - The package also exports `escapeText`, `foldLine`, `formatUtc` and `formatDate`.
13
+
14
+ Two corrections of the reader:
15
+
16
+ - `unescapeText` reads each escape one time from left to right. Before, an escaped backslash before an `n` (`C:\\new`) became a line break.
17
+ - The reader decodes the escapes of a `UID`, because a `UID` is a TEXT value.
18
+
19
+ ### Patch Changes
20
+
21
+ - Updated dependencies [d919678]
22
+ - Updated dependencies [057d69a]
23
+ - Updated dependencies [b2a1a1e]
24
+ - Updated dependencies [057d69a]
25
+ - Updated dependencies [057d69a]
26
+ - Updated dependencies [057d69a]
27
+ - Updated dependencies [057d69a]
28
+ - Updated dependencies [057d69a]
29
+ - Updated dependencies [afd6a19]
30
+ - Updated dependencies [057d69a]
31
+ - Updated dependencies [4e751da]
32
+ - @procedures/client@0.4.0
33
+
34
+ ## 0.3.0
35
+
36
+ ### Minor Changes
37
+
38
+ - 5e2ba76: New package: `ics.parse`, `ics.occurrences` and `ics.fetch` read an iCalendar calendar and give the occurrences of its events in a time window, recurrences included.
39
+
40
+ ### Patch Changes
41
+
42
+ - Updated dependencies [ddea529]
43
+ - Updated dependencies [b2a3e3a]
44
+ - Updated dependencies [a8c47f1]
45
+ - Updated dependencies [381ce3a]
46
+ - Updated dependencies [0c627f8]
47
+ - Updated dependencies [ae7f05f]
48
+ - Updated dependencies [7873940]
49
+ - Updated dependencies [a70d445]
50
+ - Updated dependencies [bc70357]
51
+ - Updated dependencies [07cc998]
52
+ - Updated dependencies [a6b01a9]
53
+ - Updated dependencies [c799cdd]
54
+ - Updated dependencies [540f8d9]
55
+ - Updated dependencies [b6daaec]
56
+ - Updated dependencies [5b9264e]
57
+ - Updated dependencies [956e88b]
58
+ - Updated dependencies [ff62281]
59
+ - Updated dependencies [d81d0ed]
60
+ - Updated dependencies [aa67cc7]
61
+ - Updated dependencies [061fa22]
62
+ - Updated dependencies [cfb9d69]
63
+ - Updated dependencies [43f7de5]
64
+ - Updated dependencies [b07bb50]
65
+ - Updated dependencies [4a3bfa1]
66
+ - Updated dependencies [bd0b626]
67
+ - Updated dependencies [a6be873]
68
+ - Updated dependencies [fb30718]
69
+ - Updated dependencies [c5528e4]
70
+ - Updated dependencies [fee5d9c]
71
+ - Updated dependencies [21f7743]
72
+ - Updated dependencies [31a0b46]
73
+ - @procedures/client@0.3.0
package/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  [![npm](https://img.shields.io/npm/v/@procedures/ics?color=2346c4&label=npm)](https://www.npmjs.com/package/@procedures/ics)
4
4
 
5
- An iCalendar (RFC 5545) reader without dependencies. It gives the events of a calendar and the occurrences of each event in a time window, with the recurrence rules.
5
+ An iCalendar (RFC 5545) reader and writer without dependencies. The reader gives the events of a calendar and the occurrences of each event in a time window, with the recurrence rules. The writer makes a calendar from events.
6
6
 
7
7
  ## Install
8
8
 
@@ -18,6 +18,7 @@ A host registers the procedures with `createRegistry(icsModule)`, or with `impor
18
18
  | --- | --- | --- |
19
19
  | `ics.parse` | none | Reads the events of an iCalendar text. |
20
20
  | `ics.occurrences` | none | Gives the occurrences of the events in a time window. An edited instance replaces its occurrence. |
21
+ | `ics.write` | none | Writes an iCalendar text from events. `ics.parse` reads the text back to the same events. |
21
22
  | `ics.fetch` | reads `network` | Gets a calendar feed and reads its events. No error repeats the feed address. |
22
23
 
23
24
  ## Example
@@ -30,6 +31,33 @@ const { occurrences } = await client.exec(["ics", "occurrences"], {
30
31
  });
31
32
  ```
32
33
 
34
+ ## Write a calendar
35
+
36
+ The function `writeIcs(events, options)` and the procedure `ics.write` make the same text:
37
+
38
+ ```ts
39
+ import { writeIcs } from "@procedures/ics";
40
+
41
+ const text = writeIcs(
42
+ [
43
+ { uid: "dinner-1@example.org", summary: "Dinner", start: "2026-11-01T23:00:00Z", end: "2026-11-02T01:00:00Z", sequence: 4 },
44
+ { uid: "trip@example.org", summary: "Trip", start: "2026-12-24", end: "2026-12-27", allDay: true },
45
+ { uid: "old-time@example.org", start: "2026-11-01T22:00:00Z", status: "CANCELLED", sequence: 4 },
46
+ ],
47
+ { prodId: "-//Example//Plans//EN", method: "PUBLISH", calendarName: "Plans" }
48
+ );
49
+ ```
50
+
51
+ - An event has `uid` and `start`. The other fields are optional: `end`, `allDay`, `summary`, `location`, `description`, `url`, `sequence`, `status`, `rrule` and `exdates`.
52
+ - The writer writes each time in UTC (`20261101T230000Z`). An all-day event gets `VALUE=DATE`, and its end date is exclusive.
53
+ - The writer escapes `\`, `;`, `,` and each line break in a text value. It removes the other control characters.
54
+ - The writer folds each line at 75 octets of UTF-8. A fold does not divide a character. Each line ends with CRLF.
55
+ - The options set the calendar properties: `prodId`, `method`, `calscale` and `calendarName` (`X-WR-CALNAME`). `VERSION` is always `2.0`.
56
+ - `stamp` sets the `DTSTAMP` of each event. The default is the current time.
57
+ - The writer throws a `RangeError` for a value that the format cannot hold. Examples are a time that is not ISO 8601 and a line break in `rrule`.
58
+ - The caller keeps `sequence` and `status`. To remove an event from a calendar, write its `uid` with `status: "CANCELLED"` and a higher `sequence`.
59
+ - The reader skips an event with `STATUS:CANCELLED`, and it does not read `DESCRIPTION`, `URL` or `STATUS`. The writer writes no `TZID` and no `RECURRENCE-ID`.
60
+
33
61
  ## Recurrences
34
62
 
35
63
  `ics.occurrences` knows `FREQ` `DAILY`, `WEEKLY` (with `BYDAY`), `MONTHLY` and `YEARLY`, with `INTERVAL`, `COUNT`, `UNTIL` and `EXDATE`. An event with a `TZID` keeps its local time across a change of daylight saving time. A month without the day of a monthly event (a 31st in April) has no occurrence. An all-day event starts at noon UTC of its date, so each time zone reads the same date.