Message13805
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. |
|
Date |
User |
Action |
Args |
2007-08-23 14:09:41 | admin | link | issue661086 messages |
2007-08-23 14:09:41 | admin | create | |
|