[issue22627] Calling timestamp() on a datetime object modifies the timestamp of a different datetime object.
Christopher Lee
report at bugs.python.org
Tue Oct 14 22:13:21 CEST 2014
Christopher Lee added the comment:
Hi Antoine, thanks for taking a look.
I should explain further. This code is for an introspection tool[1] that provides an interface to write tests in python against an application.
This code is a workaround for using large timestamps[2] (i.e. larger than 32bit time_t) the original suggested code (from SO, using timedelta) has an inconsistancy with the hour in some cases (this example in the NZ timezone):
>>> datetime.datetime.fromtimestamp(2047570047)
datetime.datetime(2034, 11, 19, 17, 27, 27)
>>> datetime.datetime.fromtimestamp(0) + datetime.timedelta(seconds=2047570047)
datetime.datetime(2034, 11, 19, 18, 27, 27)
The code you see here in my example, creating a timezone aware object, is a result of 'fixing' this behaviour I've seen.
The reason for then removing the tzinfo is because currently our API states that dates returned from the introspected objects are naive.
[1] https://launchpad.net/autopilot
[2] https://bugs.launchpad.net/autopilot/+bug/1328600
----------
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue22627>
_______________________________________
More information about the Python-bugs-list
mailing list