Lennart Regebro - Blame it on Ceasar: A rant on calendaring

published Oct 12, 2012

Talk during the Plone Conference 2012.

Lennart Regebro blames it on Ceasar when giving a rant on calendaring during the Plone conference 2012.

I live in Krakow, Poland, and can be hired. I ended up doing a lot with calendaring support.

We have the day, the month and the year. These cycles do not fit into each other nicely, which causes problems. Rome has seen all kinds of problems for this. Rome had 10 months per year. For lunar months you may need twelve or thirteen months in a year. So several days did not actually exist. With lunar months you get out of sync with about 12 days. So you get leap months. The roman calendar went out of sync about four months compared to what the season should have been.

Julius Caesar wanted to fix this. Solar calendars let the year follow the solstices and seasons. They got months of 29 or 31 days, because even numbers were unlucky. The new calendar was probably the worst ever made, but it was forced on an unsuspecting world because Rome was the boss.

Several calendars had ten days per week, but seven is a good cycle. The week is now a cycle that has nothing to do with months or years. That makes it difficult to calculate the day of the week for a certain day of the month.

momentjs.com looks best now for javascript.

http://www.date4j.net is promising for date handling in Java.

What day is the start of the week. Sunday? Monday? The isoweekday function is the correct function to use. Monday=1, Sunday=0 or 7.

The world is not split into 24 time zones. Every country decides which standard time or times are used. But we call them time zones even though they do not exist. Some time zones used to be for example one hour and fourteen seconds before GMT.

William Willett thought other people were lazy so he invented the Daylight Savings Time.

Some time zones get abbreviated the same, which is obvious as most of them end with Standard Time:

  • BST: 5 different zones
  • CST: 4 different zones
  • IST: 4 different zones

So you can name them America/Chicago, Australia/Canberra, etcetera. Daylight savings has started at various dates and times for the same zone.

Javascript: new Date(2011, 1, 29) can give 1 March, as February=1. For date checking it is better to check a date at 12:00 at the middle of the day.

Now Python. The datetime library supports timezones, but no zoneinfo is included. So there is pytz, which is always up to date. dateutil uses what the OS gives, which is probably also up to date. There are more advantages and disadvantages. "Which half past three do you mean?" is a hard question in Daylight Savings. You can tell pytz to break when no information for DST is given. I have recently created http://pypi.python.org/pypi/tzlocal that helps pytz a bit more here.

Parsing timezones. POSIX has a number and a sign wrong here.

Recurring events: repeat every third Monday, except when it is the first of the month and not the third year. You can come up with really ridiculous rules here. It got simplified luckily. dateutil has good support. With dateutil.easter you can say things like: get the third Sunday after Easter. Other crazy stuff is in dateutil.rrule. The icalendar module helps for creating and parsing calendar files.

So what happens when you mix timezoned and timezone-naive events? plone.app.event does not allow this. Timezones do not make sense for conferences on boats. Do you use an end-date or a duration? plone.app.event supports whole day events.

With a datepicker popup you can pick a date with javascript. That is fine. But you want a fallback for non-javascript too. A dropdown box for hours is okay. For sixty minutes this is a long list. Plone limits it to five minute steps. That is a decision you need to make. An end date and time should not always be needed.

Solgema.fullcalendar is good, with hardly drawbacks and it pretty. Plone4Artists calender is good too, without javascript. Think twice before you create something new yourself. And if you do, you should limit yourself.

In calendaring you can luckily ignore leap seconds.

My blog: http://regebro.wordpress.com/