Alexander Belopolsky <alexander.belopol...@gmail.com> added the comment:

I think strptime should only accept %Z when it comes together with %z and not 
do any validation.

This is close to the current behavior.  %Z by itself is useless because even 
when it is accepted, the value is discarded:

>>> print(datetime.strptime('UTC', '%Z'))
1900-01-01 00:00:00

You have to use %z to get an aware datetime instance: 

>>> print(datetime.strptime('UTC+0000', '%Z%z'))
1900-01-01 00:00:00+00:00


The validation is already fairly lax:

>>> print(datetime.strptime('UTC+1234', '%Z%z'))
1900-01-01 00:00:00+12:34

I don't think this issue has anything to do with the availability of zoneinfo 
database.  Timezone abbreviations are often ambiguous and should only serve as 
a human-readable supplement to the UTC offset and cannot by itself be used as a 
TZ specification.

----------

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

Reply via email to