Stories
Slash Boxes
Comments
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

richardc (1662)

richardc
  (email not shown publicly)
http://unixbeard.net/~richardc/

Journal of richardc (1662)

Friday February 20, 2004
06:55 PM

evolving - Friday 20th February, 2003 - Fun with Calendars

[ #17532 ]

A couple of months ago, that pesky Paul Mison (if I get to be the "wily" Richard Clamp for Pod::Coverage I reserve the right to hand out one pesky to someone) planted an idea in my head, which lead me through something of a world of hurt...

First I'll tell you what the idea is, and you can tell me what the pain was.

Ready?

It would be cool to turn a page on our intranet into ics so we can
  add it to iCal.

Okay, so now take a moment to yourselves to figure out where the pain came from.

Done?

10 points if you guessed Net::ICal.

Now I know it's disclaimed as being alpha code, and that I shouldn't be surprised if it's not too good, but the CPAN dist doesn't even pass its own tests, and the CVS version didn't even get that far.

I even sat down for a few afternoons and worked on a fork of Net::ICal CVS which got the tests passing, and it still wasn't fit for duty.

There's a whole other paragraph which goes here and questions the parentage and sanity of Class::MethodMapper, but there's only so many times you can say rude words. Let's just say it's not suitable for something you want to parse, validate, and follow the flow of control without big sheets of paper and crayons. I like crayons, but I like clear flow of control even more.

Thus cheesed off, I put the idea aside for a few weeks, expecting that when I came back to it I'd just cave and write an alternative to the whole ball of wax.

That few weeks ended this week, when Nik pointed out to me that Text::vFile should be a suitable module to base a vCalendar parser on.

an aside - iCalendars, vCalendars, ics, vFile, rfc2445, make your mind up!

So why do I keep calling things ics one moment, vCalendars the other, and iCal the next? Well it's partly due to my brain being a swiss cheesed mess, but also because someone is out to get me.

rfc2445 / iCalendar

rfc 2445

     Internet Calendaring and Scheduling Core Object Specification
                               (iCalendar)

This baby is the specification for iCalendar-formatted files.

Weighing in at 148 pages it covers pretty much anything you need to do for online interactive calendars (maybe).

---

ics

The common extension for iCalendar files when stored on disk.

---

vFile

It turns out that the object/property/parameter encoding used by rfc 2445 is the same as the one used by rfc 2426 vCard MIME Directory Profile, apart from 2445 encoded documents tend to have deeply nested objects.

We follow Text::vFiles example in calling these documents vFile formatted.

---

vCalendar

Okay, this one's probably made up.

It comes about because iCalendar is a kind of vFile.

I think.

Look just stop looking at me like that.

---

iCal

An application from Apple Computer, Ltd. Parses, generates, and generally speaks rfc 2445.

Sometimes I call it iCal.app, in order to distinguish it from the standard in the same way that use Mail.app to refer to Apple Mail.

And thus overloading occured, in my branes at least.

Sadly, Text::vFile doesn't handle nested objects - which you really need for iCalendars - and clones a little too much (ie. at all) from Class::MethodMapper in its api and thinking.

At about the time we discovered this my impatience kicked in. "Surely it can't be that hard to parse vFile to a simple data structure" I said to myself, and half an hour of coding later it turned out it wasn't. Text::vFile::asData sprang into the world.

A couple more hours tagteaming with Nik to find the corner cases and fix them and we both managed to scratch our itches. Nik's handy what's going on script to summarise upcoming events, and my wiki to ical script for the intranet, both done fairly easily with the assistance of DateTime. Version 0.01 hit the CPAN last night, with 0.02 to follow this weekend.