This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author amaury.forgeotdarc
Recipients
Date 2003-01-02.14:23:25
SpamBayes Score
Marked as misclassified
Message-id
In-reply-to
Content
While exploring the new datetime module, I got results 
like:
>>> datetime.datetime.today()
datetime.datetime(2003, 1, 2, 15, 14, 51, 480999)

Shouldn't the microseconds be 637000 ?
While not very important, this can lead you to believe 
that the timestamp is accurate to 1e-6 seconds, 
whereas only milliseconds are relevant (on W2K).

since today() is equivalent to fromtimestamp(time.time()),
I explored the results of time.time():

>>> time.time(),datetime.datetime.today()
returns:
(1041516891.4809999, 
datetime.datetime(2003, 1, 2, 15, 14, 51, 480999))

It seems that the float returned by time.time is truncated 
to 1e-6. I suggest that it should be rounded instead, so 
that the last digit (which is significant) is taken into 
account.

Looking into the code, I think that the code to change is 
in datetimemodule.c: the function 
datetime_from_timestamp could add 5e-7 to the "us" 
variable before casting it to int.
History
Date User Action Args
2007-08-23 14:09:41adminlinkissue661086 messages
2007-08-23 14:09:41admincreate