Time.strftime () wrong timezone format

I stumbled upon an issue with 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 expected to get the UTC offset ( -0700

), I got the full timezone name ( ) instead Pacific Daylight Time

. I re-ran strftime()

in another Python interpreter (on a RaspberryPi running Python 2.7.3) and got the expected UTC offset.

Code running on Windows machine with output

>>> import time
>>> time.strftime('%z')
'Pacific Daylight Time'

      

The code running on RaspberryPi was identical except for the exit (RaspberryPi localization time is set to UTC)

>>> import time
>>> time.strftime('%z')
'+0000'

      

I know most Python timing methods are wrappers for system calls, this is the case where the underlying system call fails as described for the strftime formatting character implementation to change from 2.7.3 and 2.7.8 (although the docs for 2.7.8 say lowercase z should return UTC offset)?

For more information about the time zone and language information of a Windows computer:

>>> import locale; locale.getlocale(); locale.getdefaultlocale()
(None, None)
('en_US', 'cp1252')
>>> time.tzname
('Pacific Standard Time', 'Pacific Daylight Time')

      

+3


source to share





All Articles