I stumbled across an issue running Python 2.7.8 on Windows 8.1. I was trying to pull the UTC offset for the local timezone of the computer using time.strftime('%z')
, I was expecting to get back a UTC offset (-0700
) instead I got the full timezone name (Pacific Daylight Time
). I re-ran strftime()
on another Python interpreter (on a RaspberryPi running Python 2.7.3) and got the expected UTC offset.
The code ran on the windows machine with output is
>>> import time
>>> time.strftime('%z')
'Pacific Daylight Time'
The code ran on the RaspberryPi was identical, except for the output (the RaspberryPi's local time is set to UTC)
>>> import time
>>> time.strftime('%z')
'+0000'
I know most of Python's time methods are wrappers to system calls, is this a case where the underlying system call isn't working as described for did the implementation of strftime's formatting characters change from 2.7.3 and 2.7.8 (although the docs for 2.7.8 say lowercase z should return a UTC offset)?
Some more information about the timezone and locale information of the Windows computer:
>>> import locale; locale.getlocale(); locale.getdefaultlocale()
(None, None)
('en_US', 'cp1252')
>>> time.tzname
('Pacific Standard Time', 'Pacific Daylight Time')