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
标题: strftime('%z') behaving differently with/without time arg.
类型: behavior Stage: resolved
Components: Library (Lib) Versions: Python 3.0, Python 2.6
process
状态: closed Resolution: duplicate
Dependencies: 1493676 后续: Time zone-capable variant of time.localtime
View: 1667546
分配给: 抄送列表: ajaksu2, knutroy, pboddie
优先级: normal 关键字:

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) 日期: 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) 日期: 2007-02-24 00:33
See patch #1667546 and related bug #1493676 (with discussion).
msg84475 - (view) Author: Daniel Diniz (ajaksu2) * (Python triager) 日期: 2009-03-30 03:09
Closing as issue 1667546 is much more advanced (patch and discussion).
历史
日期 用户 动作 参数
2022-04-11 14:56:20admin修改github: 43991
2009-03-30 03:09:05ajaksu2修改状态: open -> closed

resolution: duplicate

dependencies: + time.strftime() %z error
type: behavior
stage: resolved
versions: + Python 2.6, Python 3.0, - Python 2.4
抄送: + ajaksu2
消息: + msg84475
后续: Time zone-capable variant of time.localtime
2006-09-18 14:53:42knutroy创建