# @salmonui/export/ics API reference

> 13 exported symbols of @salmonui/export/ics: 7 functions, 4 interfaces, 1 type and 1 constant.

Canonical: https://salmonui.dev/docs/reference/export/ics

```ts
import { … } from '@salmonui/export/ics';
```

## Functions

### escapeText

Kind: function

Page: https://salmonui.dev/docs/reference/export/ics/escapeText

```ts
function escapeText(text: string): string;
```

TEXT escape (RFC 5545 3.3.11): backslash, `;`, `,` and line breaks.

### exportICalendar

Kind: function

Page: https://salmonui.dev/docs/reference/export/ics/exportICalendar

```ts
function exportICalendar(events: readonly ICalendarEvent[], options?: ICalendarExportOptions): {
    readonly fileName: string;
    readonly mimeType: string;
    readonly data: string;
};
```

`writeICalendar` as an export file (`{ fileName, mimeType: 'text/calendar', data }`).

### foldLine

Kind: function

Page: https://salmonui.dev/docs/reference/export/ics/foldLine

```ts
function foldLine(line: string): string;
```

Folds a content line at 75 octets (UTF-8), never inside a character; continuation lines start with a space.

### parseICalendar

Kind: function

Page: https://salmonui.dev/docs/reference/export/ics/parseICalendar

```ts
function parseICalendar(text: string): ICalendarDocument;
```

Parses iCalendar text (RFC 5545): unfolds lines, unescapes TEXT values and
reads every VEVENT (nested components such as VALARM are skipped). A
VEVENT without a readable DTSTART is dropped. A DURATION without DTEND
becomes `end`.

### unescapeText

Kind: function

Page: https://salmonui.dev/docs/reference/export/ics/unescapeText

```ts
function unescapeText(text: string): string;
```

Reverses `escapeText`.

### vtimezone

Kind: function

Page: https://salmonui.dev/docs/reference/export/ics/vtimezone

```ts
function vtimezone(zone: string, fromYear: number, toYear: number): string[] | null;
```

A VTIMEZONE for `zone` covering the years `[fromYear, toYear]`: yearly
RRULE observances when the transitions follow an nth-weekday pattern every
year of the span (as most zones do), otherwise one observance per
transition. Null when the platform does not know the zone.

### writeICalendar

Kind: function

Page: https://salmonui.dev/docs/reference/export/ics/writeICalendar

```ts
function writeICalendar(events: readonly ICalendarEvent[], options?: ICalendarWriteOptions): string;
```

Writes events as an RFC 5545 VCALENDAR (CRLF line ends, lines folded at 75 octets).

## Interfaces

### ICalendarDocument

Kind: interface

Page: https://salmonui.dev/docs/reference/export/ics/ICalendarDocument

```ts
interface ICalendarDocument {
    readonly events: ICalendarEvent[];
    readonly prodId?: string | undefined;
    readonly method?: string | undefined;
    readonly calendarName?: string | undefined;
    readonly timeZone?: string | undefined;
}
```

A parsed VCALENDAR.

Members (5):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `events` | `readonly events: ICalendarEvent[];` |  |  |
| `prodId` | `readonly prodId?: string \| undefined;` | optional |  |
| `method` | `readonly method?: string \| undefined;` | optional |  |
| `calendarName` | `readonly calendarName?: string \| undefined;` | optional | X-WR-CALNAME. |
| `timeZone` | `readonly timeZone?: string \| undefined;` | optional | X-WR-TIMEZONE. |

### ICalendarEvent

Kind: interface

Page: https://salmonui.dev/docs/reference/export/ics/ICalendarEvent

```ts
interface ICalendarEvent {
    readonly uid: string;
    readonly summary?: string | undefined;
    readonly location?: string | undefined;
    readonly description?: string | undefined;
    readonly start: ICalendarTime;
    readonly end?: ICalendarTime | undefined;
    readonly rrule?: string | undefined;
    readonly exdates?: readonly ICalendarTime[] | undefined;
    readonly recurrenceId?: ICalendarTime | undefined;
    readonly dtstamp?: number | undefined;
    readonly extra?: Readonly<Record<string, string>> | undefined;
}
```

One VEVENT.

Members (11):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `uid` | `readonly uid: string;` |  | UID; a series and its edited occurrences share it. The parser returns `''` when the VEVENT has none. |
| `summary` | `readonly summary?: string \| undefined;` | optional |  |
| `location` | `readonly location?: string \| undefined;` | optional |  |
| `description` | `readonly description?: string \| undefined;` | optional |  |
| `start` | `readonly start: ICalendarTime;` |  |  |
| `end` | `readonly end?: ICalendarTime \| undefined;` | optional | Exclusive end; omitted means zero duration (date-time) or one day (date). |
| `rrule` | `readonly rrule?: string \| undefined;` | optional | RRULE value without the `RRULE:` prefix (`FREQ=WEEKLY;BYDAY=MO`). |
| `exdates` | `readonly exdates?: readonly ICalendarTime[] \| undefined;` | optional | EXDATE values (excluded occurrence starts). |
| `recurrenceId` | `readonly recurrenceId?: ICalendarTime \| undefined;` | optional | RECURRENCE-ID: the original start of the occurrence this VEVENT replaces. |
| `dtstamp` | `readonly dtstamp?: number \| undefined;` | optional | DTSTAMP (epoch ms); defaults to the writer's `dtstamp`. |
| `extra` | `readonly extra?: Readonly<Record<string, string>> \| undefined;` | optional | Further properties by name (`X-SALMON-ROOM`), written and read as TEXT. |

### ICalendarExportOptions

Kind: interface

Page: https://salmonui.dev/docs/reference/export/ics/ICalendarExportOptions

```ts
interface ICalendarExportOptions extends ICalendarWriteOptions {
    readonly fileName?: string | undefined;
}
```

Members (8):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `fileName` | `readonly fileName?: string \| undefined;` | optional | File name; `.ics` is appended when missing. Default `calendar.ics`. |
| `prodId` | `prodId?: string;` | optional, inherited | PRODID. Default `-//Salmon UI//Scheduler//EN`. |
| `method` | `method?: string;` | optional, inherited | METHOD (`PUBLISH`, `REQUEST`); omitted by default. |
| `calendarName` | `calendarName?: string;` | optional, inherited | X-WR-CALNAME. |
| `timeZone` | `timeZone?: string;` | optional, inherited | X-WR-TIMEZONE (the calendar's default zone, informational). |
| `dtstamp` | `dtstamp?: number;` | optional, inherited | DTSTAMP of events without their own (epoch ms). Default `Date.now()`. |
| `vtimezone` | `vtimezone?: boolean;` | optional, inherited | VTIMEZONE components for every TZID used, from the platform zone data. Default true. |
| `properties` | `properties?: Readonly<Record<string, string>>;` | optional, inherited | Further calendar-level properties (TEXT values). |

### ICalendarWriteOptions

Kind: interface

Page: https://salmonui.dev/docs/reference/export/ics/ICalendarWriteOptions

```ts
interface ICalendarWriteOptions {
    readonly prodId?: string | undefined;
    readonly method?: string | undefined;
    readonly calendarName?: string | undefined;
    readonly timeZone?: string | undefined;
    readonly dtstamp?: number | undefined;
    readonly vtimezone?: boolean | undefined;
    readonly properties?: Readonly<Record<string, string>> | undefined;
}
```

Members (7):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `prodId` | `readonly prodId?: string \| undefined;` | optional | PRODID. Default `-//Salmon UI//Scheduler//EN`. |
| `method` | `readonly method?: string \| undefined;` | optional | METHOD (`PUBLISH`, `REQUEST`); omitted by default. |
| `calendarName` | `readonly calendarName?: string \| undefined;` | optional | X-WR-CALNAME. |
| `timeZone` | `readonly timeZone?: string \| undefined;` | optional | X-WR-TIMEZONE (the calendar's default zone, informational). |
| `dtstamp` | `readonly dtstamp?: number \| undefined;` | optional | DTSTAMP of events without their own (epoch ms). Default `Date.now()`. |
| `vtimezone` | `readonly vtimezone?: boolean \| undefined;` | optional | VTIMEZONE components for every TZID used, from the platform zone data. Default true. |
| `properties` | `readonly properties?: Readonly<Record<string, string>> \| undefined;` | optional | Further calendar-level properties (TEXT values). |

## Types

### ICalendarTime

Kind: type

Page: https://salmonui.dev/docs/reference/export/ics/ICalendarTime

```ts
type ICalendarTime = {
    readonly epochMs: number;
} | {
    readonly date: string;
} | {
    readonly wall: string;
    readonly timeZone?: string | undefined;
};
```

An instant, an all-day date, or a wall time (zoned with `timeZone`, floating without).

## Constants

### ICS_MIME_TYPE

Kind: const

Page: https://salmonui.dev/docs/reference/export/ics/ICS_MIME_TYPE

```ts
const ICS_MIME_TYPE = "text/calendar";
```
