New submission from lilydjwg:

With %z, the result gets a tzinfo, but with %Z, it succeeds but the result is 
without timezone info:

>>> datetime.datetime.strptime('2016-10-31T03:58:24 CST', '%Y-%m-%dT%H:%M:%S 
>>> %Z')
datetime.datetime(2016, 10, 31, 3, 58, 24)
>>> datetime.datetime.strptime('2016-10-31T03:58:24 +0800', '%Y-%m-%dT%H:%M:%S 
>>> %z')
datetime.datetime(2016, 10, 31, 3, 58, 24, 
tzinfo=datetime.timezone(datetime.timedelta(0, 28800)))

So the first one loses infomation (and will result in wrong values if the 
programmer isn't aware of this, and the local timezone is different than the 
one in the string).

----------
messages: 279761
nosy: lilydjwg
priority: normal
severity: normal
status: open
title: datetime.strptime %Z doesn't get included in the result
type: behavior

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue28565>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to