This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: strftime('%z') behaving differently with/without time arg.
Type: behavior Stage: resolved
Components: Library (Lib) Versions: Python 3.0, Python 2.6
process
Status: closed Resolution: duplicate
Dependencies: 1493676 Superseder: Time zone-capable variant of time.localtime
View: 1667546
Assigned To: Nosy List: ajaksu2, knutroy, pboddie
Priority: normal Keywords:

Created on 2006-09-18 14:53 by knutroy, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (3)
msg29872 - (view) Author: Knut Aksel Røysland (knutroy) Date: 2006-09-18 14:53
According to the documentation, time.strftime will use
time.localtime, when no time tuple is provided as
argument. So, I wonder if it is desired behavior that
%z returns different values in the following two cases:

Python 2.4.3 (#2, Apr 27 2006, 14:43:58)
[GCC 4.0.3 (Ubuntu 4.0.3-1ubuntu5)] on linux2
Type "help", "copyright", "credits" or "license" for
more information.
>>> import time
>>> time.strftime('%Y-%m-%dT%H:%M:%S%z')
'2006-09-18T16:12:05+0200'
>>> time.strftime('%Y-%m-%dT%H:%M:%S%z', time.localtime())
'2006-09-18T16:12:05+0000'

The first behavior is what I am looking for.

I realize that %z is not documented, so maybe it should
be rejected instead of giving surprising results, like
above.

This behavior is observed on different Linux systems
under different versions of Python, e.g. on Ubuntu
Dapper Drake running Python 2.4.3.
msg29873 - (view) Author: Paul Boddie (pboddie) Date: 2007-02-24 00:33
See patch #1667546 and related bug #1493676 (with discussion).
msg84475 - (view) Author: Daniel Diniz (ajaksu2) * (Python triager) Date: 2009-03-30 03:09
Closing as issue 1667546 is much more advanced (patch and discussion).
History
Date User Action Args
2022-04-11 14:56:20adminsetgithub: 43991
2009-03-30 03:09:05ajaksu2setstatus: open -> closed

resolution: duplicate

dependencies: + time.strftime() %z error
type: behavior
stage: resolved
versions: + Python 2.6, Python 3.0, - Python 2.4
nosy: + ajaksu2
messages: + msg84475
superseder: Time zone-capable variant of time.localtime
2006-09-18 14:53:42knutroycreate