time.strftime Timezone issue

Tim Peters tim.one at comcast.net
Sat Jun 12 21:56:14 EDT 2004


[Allen Unueco]
> I feel that the '%Z' format specifier from strftime() returns the wrong
> value when daylight savings is in effect.
>
> Today the following is always true: time.strftime('%Z') == time.tzname[0]
>
> Shouldn't it be: time.strftime('%Z') == time.tzname[time.daylight]

Please give a concrete example, including Python version and OS.  Platform C
bugs in time functions are common as mud.  Here's my concrete example,
Python 2.3.4 on WinXP running in US Eastern:

C:\Code>\python23\python.exe
Python 2.3.4 (#53, May 25 2004, 21:17:02) [MSC v.1200 32 bit (Intel)] on
win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import time
>>> time.tzname
('Eastern Standard Time', 'Eastern Daylight Time')
>>> time.daylight
1
>>> time.strftime("%Z")
'Eastern Daylight Time'
>>>

Here's another, Python 2.2.2 on a Red Hat box:

-bash-2.05b$ python
Python 2.2.2 (#1, Feb 24 2003, 19:13:11)
[GCC 3.2.2 20030222 (Red Hat Linux 3.2.2-4)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import time
>>> time.tzname
('EST', 'EDT')
>>> time.daylight
1
>>> time.strftime("%Z")
'EDT'
>>>













More information about the Python-list mailing list