Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #54225

Is %z broken for return values of time.gmtime()?

From Michael Schwarz <michi.schwarz@gmail.com>
Subject Is %z broken for return values of time.gmtime()?
Date 2013-09-16 15:15 +0200
Newsgroups comp.lang.python
Message-ID <mailman.28.1379337330.18130.python-list@python.org> (permalink)

Show all headers | View raw


[Multipart message — attachments visible in raw view] - view raw

I’m wondering whether this is expected:

Python 3.3.2 (default, May 21 2013, 11:50:47) 
[GCC 4.2.1 Compatible Apple Clang 4.1 ((tags/Apple/clang-421.11.66))] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import time
>>> time.strftime("%F %T %z", time.gmtime(40 * 365 * 86400))
'2009-12-22 00:00:00 +0100‘

According to the documentation of time.gmtime(), it returns a struct_time in UTC, but %z is replaced by +0100, which is the UTC offset of my OS’s time zone without DST, but DST is currently in effect here (but was not at the timestamp passed to gmtime()).

40 * 365 * 86400 seconds is a bit less than 40 Years. I’m using a date near to today to rule out any peculiarities with dates that are long in the past. Using a date at which DST was active yields the same result:

>>> time.strftime("%F %T %z", time.gmtime(40.5 * 365 * 86400))
'2010-06-22 12:00:00 +0100'

Why is my OS’s time zone used for formatting a struct_time with the UTC time zone? I’m running OS X 10.8.4, my OS’s time zone is set to CET/CEST.

Regards
Michael

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Is %z broken for return values of time.gmtime()? Michael Schwarz <michi.schwarz@gmail.com> - 2013-09-16 15:15 +0200

csiph-web