Pikkola iCal, tool No. 81

An event a calendar will actually accept.

Fill in the title, the time and the rule, and read the .ics before you download it: the properties in order, the line folding at seventy-five octets, and the next twenty dates the rule produces. A calendar that ignores the file is usually a file with one property wrong.

20
dates shown
5
repeat rules
0
uploads

The bench

Type it, then read it

The file beside the form is the file you download, produced in one pass. The dates under it come from the rule, not from the file, so the two can be compared before anything leaves the page.

The event

The zone is written as a TZID.

The rule
On these days

A number in front of a day means the second Tuesday.

    Fill in a start time.

    What a calendar reads, in order

    An .ics file is a list of properties with a strict order of operations. Most of the reasons a calendar ignores an event are in the first four lines of it.

    01

    The version and the product

    BEGIN:VCALENDAR, VERSION:2.0 and PRODID come first, and a file without them is refused by some clients before anything inside it is read. PRODID is the name of the program that wrote it, and it is free text after a slash that names the product in reverse order.

    02

    A UID and a DTSTAMP

    Every event needs a UID that is unique across every calendar it will ever meet, and a DTSTAMP that says when the file was made. Importing the same event twice with the same UID updates it; with different UIDs it duplicates, which is the most common complaint about a generated calendar.

    03

    Local time, UTC, or a zone

    DTSTART can be a date, a local time in a zone named by TZID, or a UTC time ending in Z. All-day events use a date with no time at all, and a DTEND for an all-day event is exclusive: a one-day event on the fourth ends on the fifth.

    What this page writes, and what it leaves out

    The generator writes the properties a single event needs and refuses to guess the rest. Everything it does not write is listed here rather than half-written.

    Property What this page does What it does not do
    DTSTART / DTEND Writes a date, a TZID time or a UTC time, and makes an all-day end exclusive Add a DURATION instead: one of the two, never both
    RRULE Builds FREQ, INTERVAL, COUNT or UNTIL, BYDAY with ordinals and BYMONTHDAY Write BYSETPOS, BYWEEKNO or BYYEARDAY: they are real and this form does not offer them
    EXDATE Not written Remove one date from a series: paste the file into a calendar and delete it there
    VALARM Writes one display alarm with a TRIGGER in minutes Send an email or a request: a calendar does that, a file only asks
    VTIMEZONE Writes an IANA name as TZID Write the transition table that a strict client wants beside it
    Folding Folds at seventy-five octets on a character boundary, CRLF line endings Repair a file that was folded with a different line ending

    The dates under the form are computed from the rule with the browser's own calendar arithmetic. A rule this page can build is a rule it can count; a rule pasted from elsewhere is shown as written, without a count.

    Field guide

    The calendar file, line by line

    An .ics file is 1980s text with 1990s rules and a few decisions that still surprise people. Reading one is easier than writing one that a calendar keeps, and the difference is usually four properties and one line ending.

    The shape of the file

    A VCALENDAR holds a VERSION, a PRODID and one or more components. An event is a VEVENT with a UID, a DTSTAMP, a DTSTART and usually a DTEND, SUMMARY and DESCRIPTION. Properties are NAME;PARAM=value:value and the value is text with three escapes: a backslash, a semicolon and a comma, plus a literal newline written as \n rather than an actual break. Getting the escaping wrong is silent: the file imports and the description is cut at the first comma.

    Folding is measured in octets, not characters

    A line longer than seventy-five octets is split, and the continuation begins with a single space or tab. Octets means UTF-8 bytes, so a Korean description folds at about twenty-five characters rather than seventy-five, and a folding routine that counts characters will produce a line a strict parser rejects. The folding must not split a multi-byte character either, which is the second thing a hand-written encoder gets wrong. This page counts bytes and folds between characters.

    MistakeWhat the calendar doesThe fix
    LF instead of CRLFIgnores the file or the last propertyEvery line ends CRLF
    No UIDImports, then duplicates on a second importA stable UID per event
    DTEND equal to DTSTART on an all-day eventShows a zero-day event, or drops itDTEND is the day after
    Unescaped comma in DESCRIPTIONText cut at the commaEscape it as \,
    COUNT and UNTIL togetherClient-dependent series lengthOne or the other

    RRULE is a set of choices, not a sentence

    A rule names a frequency and then narrows it with parts: an interval, a set of weekdays, days of the month, months of the year, and an end. The narrowing is not independent: BYDAY inside a monthly rule means "every matching weekday in the month" unless a number is prefixed, in which case it means the second Tuesday or the last Friday. BYMONTHDAY inside a weekly rule is meaningless and is ignored rather than rejected, which is how a rule that looks right produces dates nobody expected. The parts this page offers are the ones with one meaning.

    The end of a series has three forms

    An endless rule, a count, or a date. An endless rule is what a subscription wants and what a single import handles badly, because a client must expand it lazily forever. COUNT counts occurrences that match the rule, not calendar days, so COUNT=8 on a weekly rule is eight weeks. UNTIL is a moment in UTC, and a rule with an UNTIL date but a local DTSTART is a rule whose last occurrence depends on the zone: the same rule can include or exclude one date depending on where it is read.

    What a file cannot do

    An .ics file carries no IDs from the calendar it will land in, no reminders that the operating system already owns, and no guarantee that an attendee will be invited: an ATTENDEE property asks a server to send, and a file on a phone has no server. Importing is a one-way act that a calendar is free to interpret, which is why the file has to be right before it leaves rather than after it is refused.

    For the time arithmetic behind a recurrence, Pikkola Time converts a timestamp across zones. For the repetition syntax a server uses instead, Pikkola Cron is the other side of the same idea.

    Questions

    Why does my calendar show the event an hour off?

    Either the TZID is not one the calendar knows, or the time was written as UTC without the Z, or the zone's rules changed since the file was made. Choosing UTC in this page removes the first two causes: a UTC time is unambiguous and needs no zone table.

    Why does an all-day event end a day later than I set?

    Because DTEND is exclusive in the specification. An event that occupies the fourth from midnight to midnight must say it ends on the fifth. This page writes that value for you and shows the date it wrote, so a calendar that displays the fourth to the fourth is reading a file written by something else.

    What does COUNT do when I also set UNTIL?

    The specification says one or the other; a rule with both is invalid and clients differ on which they honour. This form writes whichever you chose and clears the other, so the file is never ambiguous.

    Can I import this into Google Calendar and Apple Calendar?

    Yes. Google reads an uploaded .ics under Settings, Import and export, and Apple opens the file with Calendar. Both accept the properties written here. A file with a TZID and no VTIMEZONE is accepted by both because both know the IANA names; a smaller client may not, which is why the zone choice is yours.

    Why is my event duplicated after importing twice?

    Each import made a new UID, and an event is identified by its UID rather than by its title. A calendar import that adds rather than updates is behaving as documented. To update instead, import the same file, with the same UID, through a route that replaces: a subscription, or a client that offers to merge.