This package can parse and create Ics files and provides TypeScript types for easy handling.
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.
npm i ts-ics
import { generateIcsCalendar, type VCalendar } from "ts-ics";
const calendar: VCalendar = {...}
const icsCalendarString = generateIcsCalendar(calendar);
import { generateIcsEvent, type VEvent } from "ts-ics";
const event: VEvent = {...}
const icsEventString = generateIcsEvent(event);
import { parseIcsCalendar, type VCalendar } from "ts-ics";
const calendarParsed: VCalendar = parseIcsCalendar(icsCalendarString);
import { icsCalendarToObject, type VCalendar } from "ts-ics";
const calendar: VCalendar = icsCalendarToObject(icsCalendarString);
import { parseIcsEvent, type VEvent } from "ts-ics";
const eventParsed: VEvent = parseIcsEvent(icsEventString);
import { icsEventToObject, type VEvent } from "ts-ics";
const event: VEvent = icsEventToObject(icsEventString);
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),
});
MIT - License
Thanks to iCalendar.org for the ics documentation and the many examples which are used for testing purposes.