1.4.0 • Published 10 days ago

ts-ics v1.4.0

Weekly downloads
-
License
MIT
Repository
github
Last release
10 days ago

TS-ICS

neuvernetzung-logo

This package can parse and create Ics files and provides TypeScript types for easy handling.

Motivation

Many of the Ics packages provide good functionality, however none of these are type safe. This package can parse Ics strings with Zod. Also, many packages are not actively maintained.

Installation

npm i ts-ics

Parsing

Parse Ics Calendar

import { parseIcsCalendar, icsCalendarToObject, type VCalendar } from "ts-ics";

const calendarParsed: VCalendar = parseIcsCalendar(icsCalendarString);

// or if you only want to convert it, but not parse it

const calendar: VCalendar = icsCalendarToObject(icsCalendarString);

Parse Ics Event

import { parseIcsEvent, icsEventToObject, type VEvent } from "ts-ics";

const eventParsed: VEvent = parseIcsEvent(icsEventString);

// or if you only want to convert it, but not parse it

const event: VEvent = icsEventToObject(icsEventString);

Generating

Generate Ics Calendar

import { generateIcsCalendar, type VCalendar } from "ts-ics";

const calendar: VCalendar = {...}

const icsCalendarString = generateIcsCalendar(calendar);

Generate Ics Event

import { generateIcsEvent, type VEvent } from "ts-ics";

const event: VEvent = {...}

const icsEventString = generateIcsEvent(event);

RRule

Extending by RRule

import { extendByRecurrenceRule } from "ts-ics";

const start = new Date(Date.UTC(2023, 9, 5));
const ruleString = "FREQ=DAILY;BYMINUTE=15,16,17,18,19;BYSECOND=0,20,40";

const rule = parseIcsRecurrenceRule(ruleString);

const dates = extendByRecurrenceRule(rule, {
  start,
  end: addDays(start, 1),
});

More

Parse and generate functions are available for every other Ics Type like:

  • VAlarm
  • VTimezone
  • ...

License

MIT - License

Thanks

Thanks to iCalendar.org for the ics documentation and the many examples which are used for testing purposes.

1.4.0

10 days ago

1.3.4

26 days ago

1.3.3

1 month ago

1.3.2

2 months ago

1.3.1

4 months ago

1.3.0

4 months ago

1.2.2

5 months ago

1.2.1

5 months ago

1.2.0

6 months ago

1.1.0

6 months ago

1.0.9

7 months ago

1.0.8

7 months ago

1.0.7

7 months ago

1.0.6

7 months ago

1.0.5

7 months ago

1.0.4

7 months ago

1.0.3

7 months ago

1.0.11

7 months ago

1.0.10

7 months ago

1.0.12

7 months ago

1.0.2

7 months ago

1.0.1

7 months ago

1.0.0

7 months ago