[Zope-dev] Bug in DateTime arithmetic

Jeff K. Hoffman jkhoffman@usa.net
Sun, 11 Apr 1999 20:12:04 -0400 (EDT)


Hello, everyone.

While messing around with Zope, I came across a bug in the DateTime class.
The following python session exhibits the faulty behavior:

Python 1.5.1 (#1, Dec 11 1998, 07:16:57)  [GCC 2.7.2.3] on linux2
Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam
>>> from DateTime import *
>>>
>>> date = DateTime('05/01/1999').earliestTime()
>>> d = (date - date.day()).earliestTime()
>>> print d
1999/04/30  00:00:01 US/Eastern
>>> print (d - 24)
1999/04/06  00:00:01 US/Eastern   # correct
>>> print (d - 25)
1999/04/05  00:00:01 US/Eastern   # correct
>>> print (d - 26)
1999/04/03 23:00:1 US/Eastern     # incorrect
>>> d = d - (d.day() - 1)
>>> print d
1999/03/31 23:00:1 US/Eastern     # incorrect
>>> ^D

Apparently, the DateTime code is picking up an extra hour somewhere which
is throwing the calculation off.

I've submitted this to the collector, but I am posting it here for
discussion. Anyone know what the problem might be? I'm willing to fix it
and submit a patch, but right now I have no clue where to look.

jkh