RE: [Zope-dev] Bug in DateTime arithmetic
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
On Sun, 11 Apr 1999, Brian Lloyd wrote:
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...
Ahhh. You can tell it's been a long weekend. I should have picked up on that at first glance. Guess that's why they say two eyes are better than one. :) Now the question is, what are the correct semantics for the subtract operator on the DateTime class? Does "date - 1" mean "date - 24hours", or does it mean "date - 1day". At least I know what's going on with the code now. :) Thanks, jkh
participants (2)
-
Brian Lloyd -
Jeff K. Hoffman