[Zope3-dev] datetime objects
Ulrich Eck
ueck@net-labs.de
Wed, 11 Dec 2002 16:44:01 +0100
Hello,
i'm working on my Task Scheduler and play around with the datetime objects
..
i found some strange behaviour with datetime/timedelta:
I'm using python-2.2.2/linux
1. is this a bug ??
----------------------------------
>>> from datetime import datetime
>>> def test_datetime():
... d = datetime.now()
... for i in range(1000):
... xd = datetime.now()
... print xd - d
... d = xd
...
>>> test_datetime()
sometimes prints (reproducable, but not
on any linux-machine):
0:00:00.000764
0:00:00.000762
-1 days, 23:59:59.995242
0:00:00.000872
0:00:00.000778
--------------------------------
2. another bug ??
>>> from datetime import datetime
>>> d1 = datetime.now()
>>> d2 = datetime.now()
>>> d1 - d2
timedelta(-1, 86395, 113112)
>>> abs(d1 - d2)
timedelta(0, 4, 886888)
>>> d1
datetime(2002, 12, 11, 16, 21, 3, 920367)
>>> d2
datetime(2002, 12, 11, 16, 21, 8, 807255)
>>> d1 - d2
timedelta(-1, 86395, 113112)
the latter should be a negative timedelta of about 5 seconds !!!
i've looked at the python-cvs sandbox and there is an implementation
of datetime that is under development. is this implementation
supposed to replace the current datetime module ??
what needs to be done to make the current implementation working ??
i've looked over the _datetime.py code but i'm not really into
date-math ... and there is a lot of that in there :)
Ulrich Eck
aka jack-e