Parsing iCal Data
by Robert PratteAugust 18, 2005
A somewhat trivial example of this sort of creation is an application that converts iCalendar data into a directed graph, readable by an application such as GraphViz. This example seems so trivial that you might ask yourself why you would wish to do such a thing. The answer is perhaps equally trivial: aside from the challenge factor, the ability to convert data could provide an alternative (or complement) to Gantt charts in project documentation, map relationships between events, etc. Moreover, by providing a simple way to allow disparate applications to interoperate, you can cumulatively build suites of applications, hopefully allowing for unforeseen advantages in the future.
Returning to the example, say you would like to take an iCal calendar (Figure 1) and turn it into an interesting visualization (Figure 2). How would you do this? Such an ability to convert formats is one step in constructing that killer application.

Figure 1. An iCal calendar

Figure 2. An alternate visualization of the calendar data
Reading the iCalendar Format
RFC 2446 defines the
iCalendar format, which Apple's iCal application uses. Each iCalendar file
represents an individual calendar and contains at least one block of event data
in key:value tuples, starting with a BEGIN:VEVENT tuple and ending
with END:VEVENT. Here is an example (with indentation added for
readability) of a small iCalendar file containing two events:
BEGIN:VCALENDAR
CALSCALE:GREGORIAN
PRODID:-//Apple Computer\, Inc//iCal 2.0//EN
VERSION:2.0
BEGIN:VEVENT
LOCATION:San Francisco
DTSTAMP:20050618T151130Z
UID:BDF17182-CA21-4752-8D4F-40A4FE47C90D
SEQUENCE:8
URL;VALUE=URI:http://developer.apple.com/wwdc/
DTSTART;VALUE=DATE:20050606
SUMMARY:Apple WWDC
DTEND;VALUE=DATE:20050612
DESCRIPTION:Lots of sessions.
END:VEVENT
BEGIN:VEVENT
DURATION:PT1H
LOCATION:Home
DTSTAMP:20050618T151543Z
UID:5F88A0EC-AD21-428E-AAAD-005F1B1AB72E
SEQUENCE:6
DTSTART;TZID=America/Chicago:20050615T180000
SUMMARY:Set up File Server
DESCRIPTION:Music server for the kids.
END:VEVENT
END:VCALENDAR

