The "beaty" of date arithmetic

Hans-Joachim Widmaier hjwidmaier at web.de
Fri Jan 24 01:53:51 EST 2003


Manuel M. Garcia <mgarcia at cole-switches.com> wrote in message news:<clt03v8a49rtfhe90l7nomj91rll1n8vjk at 4ax.com>...
> The 'time' module is terrible for doing any kind of date arithmetic.
> In Python 2.3 there will be a standard module 'datetime' that will
> support straightforward and efficient date arithmetic.  But Python 2.3
> is in beta right now.
> 
> For now, please try 'mxDateTime', an extension module that is
> currently the best way to do date arithmetic in Python.

I've considered using mxDateTime, but from looking at the docs, I
haven't found anything that seemed to make it much easier. The
problems start as soon as you're going from fixed units like hour, day
to somewhat fuzzier like month. What date is "T - 1 month - 1 day"?
What date is "2000-02-29 + 1 year"? Date arithmetic *is* complex. Most
of the ugliness IMHO stems from the tuple-list conversions and
numerical indices. (Sure, I could have created names for them, making
this little thing even longer.)

I already compiled 2.3a1 but didn't install it as it didn't pass the
tests.

Thanks anyway,
Hans-Joachim




More information about the Python-list mailing list