Simon Wistow (deflatermouse) wrote,
Simon Wistow
deflatermouse

Yet more ICalendar stuff

You see, the title is self-referential in a totally hip, ironic, post-modern kind of way. Because I keep talking about ICalendar stuff. And because it's also about recurring events in ICalendar stuff. And ... oh, forget it.

So, we can parse hideously complicated recurring dates like the London.pm date scheme now. Which is cool.

However what happens when you want to have note - i.e you want to automatically say that the meetings are on the first Thursday after a Wednesday every month but then, on Thursday the 8th you want to say "It's in the Prince Arthur"?

Well, the secret, apparently is in the Recurrence-IDs and UIDs.

Look at this ICalendar snippet

    BEGIN:VCALENDAR
    BEGIN:VEVENT
    DTSTART;TZID=Europe/London:20050815T110000
    SUMMARY:Test event
    UID:2FB51E02-170F-11DA-B41B-000A9599EB44
    RRULE:FREQ=DAILY;INTERVAL=1;UNTIL=20050818T225959Z
    DURATION:PT1H
    END:VEVENT
    BEGIN:VEVENT
    DTSTART;TZID=Europe/London:20050816T110000
    SUMMARY:This is on a Tuesday
    UID:2FB51E02-170F-11DA-B41B-000A9599EB44
    RECURRENCE-ID;TZID=Europe/London:20050816T110000
    DURATION:PT1H
    END:VEVENT
    END:VCALENDAR

Notice how the two UIDs are the same and that the RECURRENCE-ID of the second event is the exactly one day later than the DTSTART of the first one (which recurs daily)?

All we have to do is keep a list of all the events belonging to a UID then if we find an event with a RECURRENCE-ID look up all the events with its UID, check to see if the start time is the same and, if it is, replace it.

Tags: apparently, belonging, icalendar, ids, ironic, parse, prince arthur, recurrence, recurring events, snippet, stuff, uid
Subscribe

  • This is a call to all my past resignations

    My building, like many here in the fair City O' Fog, has a door entry system which calls a phone number - I can then buzz the door open using the…

  • You Get Me Closer To God

    And ooooooooooooh, the music puns get worse and worse. So, at work we stumbled across an interesting Perlism. Well, interesting if you're a huge…

  • All Tomorrow's Parties

    After my last bit of Calendar fiddling I was left slightly disgusted by the state of the code. In my defence it was written over the course of a…

  • Post a new comment

    Error

    default userpic

    Your reply will be screened

    Your IP address will be recorded 

    When you submit the form an invisible reCAPTCHA check will be performed.
    You must follow the Privacy Policy and Google Terms of use.
  • 0 comments