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: %z does not work in time.strftime()
Type: Stage: resolved
Components: Versions: Python 3.4
process
Status: closed Resolution: duplicate
Dependencies: Superseder: [doc] time.strftime %z format specifier is the same as %Z
View: 20281
Assigned To: Nosy List: dendory, r.david.murray
Priority: normal Keywords:

Created on 2015-06-26 19:13 by dendory, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Messages (4)
msg245860 - (view) Author: (dendory) Date: 2015-06-26 19:13
Using `%z` gives the same result as using `%Z` in `time.strftime()`:

    Python 3.4.3 (v3.4.3:9b73f1c3e601, Feb 24 2015, 22:43:06) [MSC v.1600 32 bit (Intel)] on win32
    Type "help", "copyright", "credits" or "license" for more information.
    >>> import time
    >>> time.strftime("%z")
    'Eastern Daylight Time'
    >>> time.strftime("%Z")
    'Eastern Daylight Time'

Instead it's supposed to give a +0000 or -0000 result.
msg245861 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2015-06-26 19:18
That's a platform peculiarity.  See issue 20281.
msg245863 - (view) Author: (dendory) Date: 2015-06-26 19:53
Uh? But that's completely besides the point. Windows provides timezone offset information in a different way than Linux does (through the Registry) but it's still available. It's trivial to do in .NET for example:

    Console.WriteLine(TimeZone.CurrentTimeZone.GetUtcOffset(DateTime.Now));

Aren't a lot of things implemented differently in Linux and Windows? I'm not familiar with Python's internals, but I'm sure a lot of functions are implemented differently cross platform. This bug is certainly valid, as any code using this function will not work as expected on this platform.
msg245866 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2015-06-26 20:27
Yes, but the Microsoft C runtime doesn't use that interface, and it is currently the C runtime that we use to implement strftime.  This could change, but that's an enhancement.  See issue 3173 for example.
History
Date User Action Args
2022-04-11 14:58:18adminsetgithub: 68705
2015-06-26 20:27:48r.david.murraysetmessages: + msg245866
2015-06-26 19:53:45dendorysetmessages: + msg245863
2015-06-26 19:18:28r.david.murraysetstatus: open -> closed

superseder: [doc] time.strftime %z format specifier is the same as %Z

nosy: + r.david.murray
messages: + msg245861
resolution: duplicate
stage: resolved
2015-06-26 19:13:45dendorycreate