[issue28565] datetime.strptime %Z doesn't get included in the result
lilydjwg
report at bugs.python.org
Mon Oct 31 01:48:57 EDT 2016
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 <report at bugs.python.org>
<http://bugs.python.org/issue28565>
_______________________________________
More information about the Python-bugs-list
mailing list