[Zope] Subtracting 2 datetime objects

Dieter Maurer dieter@handshake.de
Wed, 5 Sep 2001 00:22:45 +0200 (CEST)


Gitte Wange writes:
 > I need to figure out a start time for an object from two other start times.
 > 
 > I have made myself a little Python Script inside Zope to test this (because I 
 > don't know exactly how this works).
 > 
 > So I created myself two variables:
 > d1 = DateTime('14:55').timeTime()
 > d2 = DateTime('15:00').timeTime()
 > 
 > time = d2 - d1
This result is 300.0, as it should be....

DateTime(float) interprets the float argument as "seconds" since 
the epoch, which is 1970-1-1T0:0 GMT.

Thus, "DateTime(300.0)" is "1970/01/01 00:05:00 GMT",
which is "1970/01/01 01:05:00 GMT+1" in your local time zone.
When you extract "Time", you get "01:05:00". As it should
be.

Work around: convert to zone "GMT" before extracting "Time".


Dieter