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()?

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.mixmin.net!rt.uk.eu.org!newsfeed.xs4all.nl!newsfeed2.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <michi.schwarz@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.039
X-Spam-Evidence '*H*': 0.92; '*S*': 0.00; 'dst': 0.09; 'formatting': 0.09; 'python': 0.11; '00:00:00': 0.16; '365': 0.16; 'dst,': 0.16; 'subject:broken': 0.16; 'subject:values': 0.16; 'timestamp': 0.16; 'utc': 0.16; 'utc,': 0.16; 'bit': 0.19; '(but': 0.19; '>>>': 0.22; 'import': 0.22; 'michael': 0.29; 'wondering': 0.29; '+0100,': 0.31; 'yields': 0.31; 'compatible': 0.32; 'running': 0.33; 'but': 0.35; 'received:google.com': 0.35; 'dates': 0.36; 'seconds': 0.37; 'message-id:@gmail.com': 0.38; 'apple': 0.38; 'to:addr:python- list': 0.38; 'to:addr:python.org': 0.39; 'according': 0.40; 'header:Message-Id:1': 0.63; 'today': 0.64; 'more': 0.64; 'charset:windows-1252': 0.65; 'here': 0.66; 'past.': 0.68; '4.2.1': 0.84; '2013,': 0.91
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:content-type:subject:message-id:date:to:mime-version; bh=2TnKmYNkOtdCNzHKOKFrtYJf5xwNCjgNQvbWUI0aK3w=; b=ozXmxCmJP2XkBylJyKuoef4J7+FxTbVUGEqkCmAQBol6Y/6pmDZWh7/mIoYEt5GgZs ZnR0fZEeMRamv4CCSgvF3UR/lfJhuE8OE2Fxl8i29qTCs67hRQa4ihDhKj2COcQCRRnE URH3RrT7K6JdEuBdK/abbuF5acKqDaikhU/ZLeB3tr0E9byhTXYmKQMHEyVdsdaPSMSF BRE0VHjHTTDnALzkmzFd9exGZAX3vkipD/FjW4/PcFMh0wDbeTSZexltrt6UU3of28Y/ 5567An8Xu4JTcMeR0fbM/hnRK9aFwFi8k8toYxeJM3VJahqWKyje5hujELM18RvZ0yiy iLrw==
X-Received by 10.15.67.131 with SMTP id u3mr42842258eex.34.1379337323173; Mon, 16 Sep 2013 06:15:23 -0700 (PDT)
From Michael Schwarz <michi.schwarz@gmail.com>
Content-Type multipart/signed; boundary="Apple-Mail=_2315DE7B-911B-43D6-AF8F-4E30E6B862A2"; protocol="application/pkcs7-signature"; micalg=sha1
Subject Is %z broken for return values of time.gmtime()?
Date Mon, 16 Sep 2013 15:15:22 +0200
To python-list@python.org
Mime-Version 1.0 (Mac OS X Mail 6.5 \(1508\))
X-Mailer Apple Mail (2.1508)
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.28.1379337330.18130.python-list@python.org> (permalink)
Lines 84
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1379337330 news.xs4all.nl 15969 [2001:888:2000:d::a6]:58069
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:54225

Show key headers only | 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