[issue23517] datetime.utcfromtimestamp parses timestamps incorrectly

Alexander Belopolsky report at bugs.python.org
Wed Feb 25 17:48:46 CET 2015


Alexander Belopolsky added the comment:

Victor,

Would you consider going back to round to nearest?  Mark and I put in a lot of effort to get the rounding in the datetime module right.  (See for example, #8860.)

Sub-microsecond timesources are still rare and users who work with such should avoid FP timestamps in any case.  On the other hand, double precision timestamps are adequate for microsecond resolution now and in the next few decades.

Timestamps like OP's (sec=1424817268, us=274000) should not change when converted to double and back.  IMO, the following behavior is a bug.

>>> dt = datetime(2015, 2, 24, 22, 34, 28, 274000)
>>> datetime.utcfromtimestamp(dt.timestamp())
datetime.datetime(2015, 2, 25, 3, 34, 28, 273999)

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue23517>
_______________________________________


More information about the Python-bugs-list mailing list