Skip to content
Jennifer Programming Language

ical API reference

Build and parse iCalendar (RFC 5545): a Calendar holding Events (VEVENT) and Todos (VTODO), encoded to a VCALENDAR and parsed back. Pure Jennifer over strings / lists + time - no Go, no system engine.

Beyond the basics (UID / SUMMARY / DESCRIPTION / LOCATION), an event supports recurrence (RRULE / RDATE / EXDATE, with an occurrences expander for FREQ / INTERVAL / COUNT / UNTIL), DURATION, all-day dates (VALUE=DATE) and a named-zone TZID, an ORGANIZER and ATTENDEEs, and VALARM alarms. Times go through time: UTC values write as 20240615T130000Z; a TZID event stores its wall clock as a floating value paired with the zone name (because time models fixed-offset zones only, add a matching VTIMEZONE for a strict consumer). Text values are RFC 5545-escaped and content lines folded at 75 octets, so parse(encode(cal)) round-trips; parse throws an IcalError for malformed input.

Import with import "ical.j" as ical;. See the ical guide for prose and examples.

Contents

NameWhat it is
addA copy of the calendar with an event appended (value-semantic).
addAlarmA copy of the event with a VALARM appended.
addAttendeeA copy of the event with an ATTENDEE appended.
addExdateA copy of the event with an excluded recurrence instant (EXDATE) appended.
addRdateA copy of the event with an extra recurrence instant (RDATE) appended.
addTodoA copy of the calendar with a to-do appended.
alarmAn alarm (VALARM).
attendeeAn attendee.
calendarA calendar with the default Jennifer PRODID and no events.
calendarWithA calendar with a caller-supplied PRODID.
describeA copy of the event with its description set (value-semantic).
describeTodoA copy of the to-do with its DESCRIPTION set.
encodeRender a calendar to iCalendar text (RFC 5545): a VCALENDAR wrapping one VEVENT per event (and a...
eventAn event.
locateA copy of the event with its location set (value-semantic).
occurrencesExpand an event's recurrence set into up to max occurrence instants, sorted and without duplicates:...
parseParse iCalendar text into a Calendar.
recurA copy of the event with a recurrence rule (RRULE).
ruleBuild a simple RRULE value from a frequency, interval, and count.
todoA to-do (VTODO).
withAllDayA copy of the event marked (or unmarked) as an all-day event.
withDueA copy of the to-do with its DUE instant set.
withOrganizerA copy of the event with its ORGANIZER set.
withStatusA copy of the to-do with its STATUS set (e.g.
withZoneA copy of the event with its time-zone id (TZID) set, so DTSTART / DTEND encode as local time in that...
Alarmstruct: An event alarm (VALARM).
Attendeestruct: An event attendee (ATTENDEE).
Calendarstruct: A calendar: a product identifier, its events, and its to-dos.
Eventstruct: A single calendar event (a VEVENT).
IcalErrorstruct: A malformed calendar or recurrence rule.
Todostruct: A to-do item (a VTODO).

Functions

add

jennifer
ical.add(cal as Calendar, ev as Event)

A copy of the calendar with an event appended (value-semantic).

cal
the calendar
ev
the event to add
Returns Calendar
a fresh calendar with the event appended

addAlarm

jennifer
ical.addAlarm(ev as Event, a as Alarm)

A copy of the event with a VALARM appended.

ev
the event
a
the alarm
Returns Event
a fresh event with the alarm added

addAttendee

jennifer
ical.addAttendee(ev as Event, a as Attendee)

A copy of the event with an ATTENDEE appended.

ev
the event
a
the attendee
Returns Event
a fresh event with the attendee added

addExdate

jennifer
ical.addExdate(ev as Event, t as time.Time)

A copy of the event with an excluded recurrence instant (EXDATE) appended.

ev
the event
t
the excluded instant
Returns Event
a fresh event with the EXDATE added

addRdate

jennifer
ical.addRdate(ev as Event, t as time.Time)

A copy of the event with an extra recurrence instant (RDATE) appended.

ev
the event
t
the extra instant
Returns Event
a fresh event with the RDATE added

addTodo

jennifer
ical.addTodo(cal as Calendar, td as Todo)

A copy of the calendar with a to-do appended.

cal
the calendar
td
the to-do to add
Returns Calendar
a fresh calendar with the to-do appended

alarm

jennifer
ical.alarm(action as string, trigger as string, description as string)

An alarm (VALARM).

action
the action ("DISPLAY" / "AUDIO" / "EMAIL")
trigger
the trigger value (e.g. -PT15M)
description
the reminder text ("" for none)
Returns Alarm
the alarm

attendee

jennifer
ical.attendee(address as string, cn as string, role as string)

An attendee.

address
the calendar address (e.g. mailto:bob@example.com)
cn
the common name ("" for none)
role
the role ("" for none; e.g. "REQ-PARTICIPANT")
Returns Attendee
the attendee

calendar

jennifer
ical.calendar()

A calendar with the default Jennifer PRODID and no events.

Returns Calendar
the empty calendar

calendarWith

jennifer
ical.calendarWith(prodid as string)

A calendar with a caller-supplied PRODID.

prodid
the product identifier
Returns Calendar
the empty calendar

describe

jennifer
ical.describe(ev as Event, description as string)

A copy of the event with its description set (value-semantic).

ev
the event
description
the description text
Returns Event
a fresh event with the description set

describeTodo

jennifer
ical.describeTodo(td as Todo, description as string)

A copy of the to-do with its DESCRIPTION set.

td
the to-do
description
the description
Returns Todo
a fresh to-do with the description set

encode

jennifer
ical.encode(cal as Calendar)

Render a calendar to iCalendar text (RFC 5545): a VCALENDAR wrapping one VEVENT per event (and a VTODO per to-do), CRLF line endings, escaped text, folded long lines. Optional properties (DESCRIPTION / LOCATION / recurrence / organizer / attendees / alarms) are emitted only when set.

cal
the calendar to encode
Returns string
the iCalendar text (CRLF-terminated)

event

jennifer
ical.event(
    uid as string,
    start as time.Time,
    end as time.Time,
    summary as string)

An event. DTSTAMP defaults to the start; the optional fields (DESCRIPTION / LOCATION / recurrence / organizer / attendees / alarms) are empty until set with the describe / locate / recur / ... builders.

uid
the unique identifier
start
the start instant
end
the end instant
summary
the title
Returns Event
the event

locate

jennifer
ical.locate(ev as Event, location as string)

A copy of the event with its location set (value-semantic).

ev
the event
location
the location text
Returns Event
a fresh event with the location set

occurrences

jennifer
ical.occurrences(ev as Event, max as int)

Expand an event's recurrence set into up to max occurrence instants, sorted and without duplicates: DTSTART, the RRULE series from it (FREQ SECONDLY ... YEARLY, INTERVAL, COUNT, UNTIL), and the RDATEs, minus the EXDATEs. A MONTHLY / YEARLY instance whose date does not exist (Jan 31 + 1 month, Feb 29 in a common year) is skipped and not counted, as RFC 5545 requires. The BY* parts are not expanded: a rule holding one throws rather than yield wrong instants.

ev
the event
max
the maximum number of occurrences to return
Returns list of time.Time
the occurrence instants (at most max)
Throws IcalError
kind "ical" for a malformed or unsupported RRULE, or a series that runs past the representable time range
Throws Error
kind "limit" when reaching max takes more than 100000 recurrence steps

parse

jennifer
ical.parse(text as string)

Parse iCalendar text into a Calendar. Unfolds folded lines and reads the PRODID, each VEVENT (UID / DTSTAMP / DTSTART / DTEND / DURATION / SUMMARY / DESCRIPTION / LOCATION, the all-day VALUE=DATE and TZID parameters, RRULE / RDATE / EXDATE, ORGANIZER / ATTENDEE, and nested VALARMs), and each VTODO. A VTIMEZONE and other components are checked for structure and skipped. An event with no DTSTART is skipped; one with neither DTEND nor DURATION ends at its start (a DATE start: one day later).

text
the iCalendar text: one or more VCALENDARs
Returns Calendar
the parsed calendar
Throws IcalError
kind "ical" for malformed input: no VCALENDAR, a line without a :, a property outside a component, a missing or mismatched END, an invalid TEXT escape, a malformed or impossible date, a malformed DURATION, DTEND together with DURATION, or an end before the start

recur

jennifer
ical.recur(ev as Event, rrule as string)

A copy of the event with a recurrence rule (RRULE). Pass a raw RRULE value (e.g. "FREQ=WEEKLY;COUNT=10") or build one with rule.

ev
the event
rrule
the RRULE value
Returns Event
a fresh recurring event

rule

jennifer
ical.rule(freq as string, interval as int, count as int)

Build a simple RRULE value from a frequency, interval, and count. INTERVAL is omitted when 1 and COUNT when 0 (i.e. unbounded).

freq
the frequency ("DAILY" / "WEEKLY" / "MONTHLY" / "YEARLY")
interval
the interval (every N periods; 1 = every period)
count
the number of occurrences (0 = unbounded)
Returns string
the RRULE value

todo

jennifer
ical.todo(uid as string, stamp as time.Time, summary as string)

A to-do (VTODO). DTSTAMP defaults to stamp; DUE / STATUS / DESCRIPTION are set with the builders.

uid
the unique identifier
stamp
the DTSTAMP
summary
the title
Returns Todo
the to-do

withAllDay

jennifer
ical.withAllDay(ev as Event, isAllDay as bool)

A copy of the event marked (or unmarked) as an all-day event. All-day DTSTART / DTEND encode as VALUE=DATE (a bare YYYYMMDD).

ev
the event
isAllDay
whether the event is all-day
Returns Event
a fresh event with the all-day flag set

withDue

jennifer
ical.withDue(td as Todo, due as time.Time)

A copy of the to-do with its DUE instant set.

td
the to-do
due
the due instant
Returns Todo
a fresh to-do with the due date set

withOrganizer

jennifer
ical.withOrganizer(ev as Event, address as string)

A copy of the event with its ORGANIZER set.

ev
the event
address
the calendar address (e.g. mailto:a@example.com)
Returns Event
a fresh event with the organizer set

withStatus

jennifer
ical.withStatus(td as Todo, status as string)

A copy of the to-do with its STATUS set (e.g. "NEEDS-ACTION" / "COMPLETED").

td
the to-do
status
the status
Returns Todo
a fresh to-do with the status set

withZone

jennifer
ical.withZone(ev as Event, tzid as string)

A copy of the event with its time-zone id (TZID) set, so DTSTART / DTEND encode as local time in that zone (DTSTART;TZID=America/New_York:...) instead of UTC. The named zone is preserved verbatim; add a matching VTIMEZONE for a strict consumer.

ev
the event
tzid
the IANA time-zone name (e.g. "Europe/London"); "" restores UTC
Returns Event
a fresh event with the time zone set

Structs

Alarm

An event alarm (VALARM).

jennifer
def struct Alarm {
    action as string,
    trigger as string,
    description as string
};
action
the ACTION ("DISPLAY" / "AUDIO" / "EMAIL")
trigger
the TRIGGER value (e.g. -PT15M = 15 minutes before)
description
the DESCRIPTION (the reminder text; "" when unset)

Attendee

An event attendee (ATTENDEE).

jennifer
def struct Attendee {
    address as string,
    cn as string,
    role as string
};
address
the calendar address (e.g. mailto:bob@example.com)
cn
the common name (CN parameter; "" when unset)
role
the participation role (ROLE; e.g. "REQ-PARTICIPANT"; "" when unset)

Calendar

A calendar: a product identifier, its events, and its to-dos.

jennifer
def struct Calendar {
    prodid as string,
    events as list of Event,
    todos as list of Todo
};
prodid
the PRODID product identifier
events
the calendar's events
todos
the calendar's to-dos (VTODOs)

Event

A single calendar event (a VEVENT).

jennifer
def struct Event {
    uid as string,
    stamp as time.Time,
    start as time.Time,
    end as time.Time,
    summary as string,
    description as string,
    location as string,
    allDay as bool,
    tzid as string,
    rrule as string,
    rdates as list of time.Time,
    exdates as list of time.Time,
    organizer as string,
    attendees as list of Attendee,
    alarms as list of Alarm
};
uid
the globally-unique UID
stamp
the DTSTAMP (creation / last-modified instant)
start
the DTSTART start instant
end
the DTEND end instant
summary
the SUMMARY (title)
description
the DESCRIPTION ("" when unset)
location
the LOCATION ("" when unset)
allDay
whether the event is an all-day event (VALUE=DATE)
tzid
the TZID time-zone name for a local DTSTART / DTEND ("" = UTC)
rrule
the RRULE recurrence rule value ("" when non-recurring)
rdates
extra recurrence instants (RDATE)
exdates
excluded recurrence instants (EXDATE)
organizer
the ORGANIZER calendar address ("" when unset)
attendees
the ATTENDEEs
alarms
the event's VALARMs

IcalError

A malformed calendar or recurrence rule. Every error of kind "ical" is one, so its fields are safe to read once the kind matches.

jennifer
def struct IcalError {
    kind as string,
    message as string,
    line as int
};
kind
always "ical"
message
what is wrong, prefixed line N: when tied to a line
line
the 1-based physical line of parse's input the fault is on (a folded line counts from its first physical line); 0 when the fault is not tied to a line (an occurrences rule, input with no VCALENDAR)

Todo

A to-do item (a VTODO).

jennifer
def struct Todo {
    uid as string,
    stamp as time.Time,
    summary as string,
    due as time.Time,
    hasDue as bool,
    description as string,
    status as string
};
uid
the globally-unique UID
stamp
the DTSTAMP
summary
the SUMMARY
due
the DUE instant (valid only when hasDue)
hasDue
whether a DUE is set
description
the DESCRIPTION ("" when unset)
status
the STATUS (e.g. "NEEDS-ACTION" / "COMPLETED"; "" when unset)