[Vobject] VAVAILABILITY usage / documentation ?

Erik Dykema dykema at gmail.com
Wed Mar 17 11:51:52 CDT 2010


Hi Jeffrey-
     Thanks for taking the time to read my question & respond.  I
believe, based on your response, that what I'm looking for doesn't
exist yet.  But I'll try and clarify what I'm doing with an example
just in case.

> Let me see if I understand what you're looking for. You'd like to describe availability in some way, based on a set of (possibly recurring) events that should block the calendar?

    Precisely.  I'm trying to build an application which can deal with
reservations & scheduling of an object.  Rather than reinvent the
wheel, I decided to use iCal calendars to store this sort of
information.
     So, a particular object to be reserved (for example, a restaurant
table) might have an ical associated with it, and some recurring
events that describe when it's available.  For example, one event
might make the table available from 10am to 10pm every day, because
that's when the restaurant is open.  I can implement this as a
recurring event.
     A regular diner might have that table for lunch every Tuesday &
Thursday from noon - 1pm; so the table should be busy/unavailable
during that time.  I can implement this as a recurring event too.
     Then, a customer might request a reservation of the table from
12:30 to 1:30 on Thursday - such a reservation would overlap the
recurring event created by the regular recurring event.

     What I'd like is to be able to do is create a calendar, add the
first two v-events into the calendar, and then query the calendar to
see if a particular datetime or datetime + timedelta or relative is
busy or available.  I think this is about the same thing you suggested
you would be open to here:

> I think it would be great for vobject, or a thin wrapper on top of vobject, to provide an API where you pass in a list of VEVENT/VAVAILABILITY/VFREEBUSY components and a time range, and return a VFREEBUSY for that time range. CalendarServer almost certainly has open source code that does this now, but I'm not sure if it's easy to pull that logic out. I would ask about this on the calendarserver-dev mailing list if you're interested.

     I've written some code that accomplishes this function, but based
on your descriptions of the relevant RFC's, I'm not in conformance
with the standard, and it feels to me like junk that isn't really
suitable for inclusion into vobject.

     What my code does is:

* Include two parameters - (X-AVAILABLE, X-LAYER), into the
description field of each v-event.  Available is true/false.  Layer is
a way to prioritize the events.

* Restrict the begin / end times of my vevents to hour & half-hour boundries

* Given an attempted reservation (like the 2nd dinner reservation above):
** Break it into 30 minute blocks.
** Loop through all the vevents in the calendar, ordered by layer, and
use the vevent.rruleset.between() method to see if there is an
occurrence of an event which intersects with the attempted
reservation.

     This is really expensive (cycle wise), but I can't think of a
smarter way to do it.

-erik


More information about the VObject mailing list