I'm too cheap to pay Apple for .Mac. Besides, I want to synchronise my calendar with more devices than they support. Specifically, I'd like to be able to use Sunfire to edit my shared calendars, as well as my phone and my Mac. Currently I keep my calendars on the excellent

The best solution seems to be to develop my own synchronisation tool, to 'enhance' Apple's offering. This entry contains a few building blocks that I'll be needing.

Information on using Python to script iCal is at This works well. iCal is scriptable, even though the interface isn't very object orientated. There is a better interface builder called AppScript, but I'm put off by the fact that it depends upon a number of other packages.

One minor problem is in date conversions. Apple's Open Scripting Architecture (OSA) epoch starts on the 1st January, 1904. Python uses the Unix epoch that starts in 1970. Here's a tiny module that helps with the conversion:

"""Apple's Open Scripting Architecture stores dates
    as seconds since 1-Jan-1904. This is 2082844800
    seconds before the Unix epoch.


def to_osa_date(unix_date):
  return long(unix_date) + _offset

def from_osa_date(osa_date):
  return osa_date - _offset

More on this later, I hope.

Update 2006/05/30

In order to talk with iCal, python needs access to the window manager. So I need to run python as pythonw. Unfortunately that always starts an icon in the Dock, which won't do if this program is to run in the background and constantly sync my calendars.

The solution is to run `py2app <>`__ on the script, and then set the new app's LSUIElement element to 1.