[Zope] Incrementing with DateTime

Paul Tiemann pault@center7.com
23 Oct 2002 09:23:07 -0600


If you want a very solid date/time library that is *very* easy to use
for date calculations, I would recommend looking into the mx library. 
It has a DateTime sub-library that is wonderfully intuitive, and easy to
work with.  For example, a snip of mx.DateTime code:

from mx import DateTime

halloween = DateTime.Date(2002,10,31)
weekBeforeHalloween = halloween - DateTime.oneWeek
halloween_seconds = halloween.ticks()
today_midnight = DateTime.today(0,0,0) # h,m,s

I ran into a very similar problem last spring with daylight savings time
while trying to generate a nice little calendar, and after I picked up
the mx library it made life with dates 100% easier.  

hope that might help anyone struggling with date calcs in python,
:paul

> I stumbled upon a strange occurrence when I incrementally
> add days using the DateTime function.