1.3.2 Compatibility with Python 2.3 and above

The datetime module is as combitible as possible with Python 2.3. It does not implement all the features of the Python 2.3 datetime module but it implements all the ones the modules themselves need. Most of the time this is all that is required. One important omission is that you cannot add or subtract date objects in this combatibility module. Instead convert them to times and then convert them back again.

In order to write code compatible with both Python 2.2 and 2.3 there is one particular point to note; datetime is not a type in Python 2.2, it is a class. This means that datetime.datetime.now() will not work because you can't call the now() of an uninitialised class. Instead use datetime.datetime(2004,1,1).now(). This will produce the same (correct) result in both versions regardless of the values chosen for the date.