Brett Cannon added the comment:
There's actually a footnote pointing out that %z is not supported by all libc
implementations: https://docs.python.org/3/library/time.html#id2. Probably
adding a note for %z in the strftime() table would be good.
--
nosy: +brett.cannon
R. David Murray added the comment:
Yes, that's exactly right. 'time' is a low-level os-function wrapper, and
inherits many of the deficiencies of the platform. datetime attempts to be a
more comprehensive, portable solution. (But even it has its quirks...timezones
are *hard*.)
--
Martin Panter added the comment:
We could change this to a documentation issue if you have any suggestions to
make the documentation clearer.
I understand the “time” module is mainly a wrapper or emulator of the OS’s own
strptime, mktime, etc functions, which explains some of these quirks.
Paul Pinterits added the comment:
No no, the docs are correct. This was definitely my mistake. I'm just trying to
say that it's rather confusing how there's only partial support for time zones.
When I saw that there is support for parsing the time zone offset, I assumed
that the functions
Martin Panter added the comment:
As far as I can see, the documentation only claims that “mktime” converts local
time. If you saw a suggestion that it supports arbitrary time zones, please
point it out.
--
___
Python tracker
Paul Pinterits added the comment:
I see. You're right, it does make a difference.
However, this behaviour is quite unexpected. Perhaps I just didn't read the
docs carefully enough, but it wasn't clear to me that the time module had such
half-baked support for time zones.
An unsuspecting
Martin Panter added the comment:
Are you sure? It works for me:
>>> strptime("+0200", "%z").tm_gmtoff
7200
>>> strptime("+", "%z").tm_gmtoff
0
The "struct_time" class is documented as a named tuple, but the time zone
offset is not one of the tuple elements, so isn’t going to be checked
New submission from Paul Pinterits:
%z is listed as a supported directive in the python 3 documentation
(https://docs.python.org/3.5/library/time.html#time.strftime), but it doesn't
actually do anything:
>>> from time import strptime
>>> strptime('+', '%z') == strptime('+0200', '%z')
True