How *not* to calculate a future date

Posted on February 29, 2012
This mail was in my Inbox today and I was puzzled at first:
When I tried to start Zope it returned an error: DateError: Invalid date: (2022, 2, 29)
Apparently it only happend on a leap year and exactly on the 29th of February. Checking the old code base (Python 2.4, Plone 3) revealed this:

DateTime.DateTime(
     DateTime.DateTime().year() + 10,
    DateTime.DateTime().month(),
    DateTime.DateTime().day())

Doh!. Python provides a timedelta (Python 2.4 Library reference) module which would be better for calculating future dates.

Update: Apparently others writing similar mistakes ;) Microsoft’s Azure cloud down and out for 8 hours (via fefe)