[Zope-dev] Bug in DateTime arithmetic

Brian Lloyd Brian@digicool.com
Sun, 11 Apr 1999 21:39:20 -0400


> Hello, everyone.
> 
> While messing around with Zope, I came across a bug in the 
> DateTime class.
> The following python session exhibits the faulty behavior:
>
> >>> 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.

At first glance, I'd guess that you are seeing the
(backward) transition from daylight savings time to
standard time... 


Brian Lloyd        brian@digicool.com
Software Engineer  540.371.6909              
Digital Creations  http://www.digicool.com