[issue22296] cookielib uses time.time(), making incorrect checks of expiration times in cookies
Akira Li
report at bugs.python.org
Mon Sep 1 14:36:55 CEST 2014
Akira Li added the comment:
timestamp() method works correctly for an aware datetime objects
as in my example (notice: timezone.utc in the code).
The issue is not that it is a manual computation,
the issue is that it is incorrect:
#XXX WRONG, DO NOT DO IT
time.mktime(datetime.datetime.utcnow().timetuple())
On older Python versions, given a utc time as a naive datetime
object, POSIX timestamp is:
ts = (utc_dt - datetime(1970, 1, 1)).total_seconds()
utc_dt = datetime(1970, 1, 1) + timedelta(seconds=ts) # in reverse
----------
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue22296>
_______________________________________
More information about the Python-bugs-list
mailing list