[issue33579] calendar.timegm not always an inverse of time.gmtime

Alexander Belopolsky report at bugs.python.org
Sun May 20 12:57:49 EDT 2018


Alexander Belopolsky <alexander.belopolsky at gmail.com> added the comment:

I was able to reproduce this issue on Linux as follows

>>> import time, calendar, os
>>> os.environ['TZ'] = 'right/UTC'  # "right" timezones account for leap seconds
>>> time.tzset()
>>> calendar.timegm(time.gmtime(1234567899))
1234567875

This confirms Martin's insight that on the OP's system gmtime accounts for leap seconds.

There has been a general trend in Python to replace calls to system dependent functions in the time module with system independent reimplementations.  It is certainly possible to reimplement time.gmtime, but someone should champion this idea on python-dev.

----------
assignee:  -> belopolsky
stage:  -> needs patch
type: behavior -> enhancement
versions: +Python 3.8

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue33579>
_______________________________________


More information about the Python-bugs-list mailing list