Understanding .ics file with RFC 5545
Deepankar Bhade /
I was stuck in a shop for hours yesterday because it was raining heavily. I got bored so decided to pass some time by connecting my work google calendar to the Apple calendar in iOS.
As I was doing that found the "Add Subscription Calendar" option which had a
SUBSCRIPTION URL to a
.ics file. I got curious & started reading more about
Add Subscription Calendar
In this blog, we will demystify the
.ics file + also create our own and integrate it into our calendars! If you're using google calendar you can export your
.ics file from the settings.
The filename extension of ics is to be used for files containing calendaring and scheduling information. The file format was specified in RFC 5545 which defined the data format for representing and exchanging calendaring and scheduling information such as events, to-dos, journal entries, and free/busy information, independent of any particular calendar service or protocol.
If you open any
.ics file you should see something like this
BEGIN:VCALENDAR PRODID:-//Google Inc//Google Calendar 70.9054//EN VERSION:2.0 BEGIN:VEVENT DTSTART:20220626T093000Z DTEND:20220626T133000Z DTSTAMP:20220630T174300Z UID:firstname.lastname@example.org CREATED:20220623T183246Z LAST-MODIFIED:20220623T183254Z SEQUENCE:0 STATUS:CONFIRMED SUMMARY:MEETUP END:VEVENT END:VCALENDAR
On 1st impression, this kinda looks like a markup language with the BEGIN and END words. Let's see it in a tree format:
vcalendar - vevent - dtstart- 2022-06-26T09:30:00Z - dtend- 2022-06-26T13:30:00Z - dtstamp- 2022-06-30T17:43:00Z - uid- email@example.com - created- 2022-06-23T18:32:46Z - last-modified- 2022-06-23T18:32:54Z - sequence- 0 - status- CONFIRMED - summary- MEETUP - prodid -//Google Inc//Google Calendar 70.9054//EN - version - 2.0
Just like HTML consists of Document Object model ics is built on Core Object which is a collection of calendaring and scheduling information. The object consists of a sequence of calendar properties and one or more calendar components.
The above example we saw is the most basic representation of an iCalendar object. The first line and last line of the iCalendar object must contain a pair of iCalendar object delimiter strings: BEGIN & END in our case.
The body of the iCalendar object consists of a sequence of calendar properties and one or more calendar components.
DTEND are properties that specify calendar component begin/end.
BEGIN:VCALENDAR ... DTSTART:20220626T093000Z DTEND:20220626T133000Z ... END:VCALENDAR
You might have noticed
VEVENT in the ics files it's a Calendar component to provide a grouping of component properties that would describe an event.
Now let's create our event and add it to our google calendar. To start let's create an iCalendar Object with property VERSION set to 2.0 (latest).
BEGIN:VCALENDAR VERSION:2.0 END:VCALENDAR
Now let's add a new event by defining an Event Component. It would begin/end with
VEVENT we will add
UID which is a required property. Every event has a starting/ending time to define this in an event we will use
We will use the date with local time For example, the following represents January 18, 1998, at 11 PM: 19980118T230000.
You can more read about the time formats in RFC doc.
BEGIN:VCALENDAR VERSION:2.0 BEGIN:VEVENT UID:firstname.lastname@example.org DTSTART:20220701T090000 DTEND:20220701T100000 END:VEVENT END:VCALENDAR
Now that our event is in place we will add some meta properties like location, summary.
BEGIN:VCALENDAR VERSION:2.0 BEGIN:VEVENT UID:email@example.com DTSTART:20220701T090000 DTEND:20220701T100000 SUMMARY:Test Event DESCRIPTION:This is test event for my blog LOCATION:https://dpnkr.in END:VEVENT END:VCALENDAR
Now that this is in place let's try to import this in Google calendar, you can do it in settings -> import & export -> upload file. Upload the file and you should see our event created from the ics file.
Event created via ics file
A quick favor: was anything I wrote incorrectly or misspelled, or do you still have questions? Feel free to message me on twitter .
Until then, thanks, and have a great day.