Karthikeyan Singaravelan <tir.kar...@gmail.com> added the comment:

Thanks for the report Raghunath. Regarding timezone detection there is a 
limitation with %Z supporting only UTC, GMT and `time.tzname` which is not 
documented and it's an open issue tracked at issue22377 . Regarding a directive 
to determine Era I think it falls under a feature request and compile error is 
used for errors during compiling python interpreter itself. So I am changing 
this from compile error to enhancement.

# Support for GMT, UTC and error on PDT

$ ./python.exe
Python 3.8.0a0 (heads/master:f6c8007a29, Sep 25 2018, 12:30:43)
[Clang 7.0.2 (clang-700.1.81)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import datetime
>>> datetime.datetime.strptime("2018-06-14 10:10:11 GMT", "%Y-%m-%d %H:%M:%S 
>>> %Z")
datetime.datetime(2018, 6, 14, 10, 10, 11)
>>> datetime.datetime.strptime("2018-06-14 10:10:11 UTC", "%Y-%m-%d %H:%M:%S 
>>> %Z")
datetime.datetime(2018, 6, 14, 10, 10, 11)
>>> datetime.datetime.strptime("2018-06-14 10:10:11 PDT", "%Y-%m-%d %H:%M:%S 
>>> %Z")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/karthikeyansingaravelan/stuff/python/cpython/Lib/_strptime.py", 
line 568, in _strptime_datetime
    tt, fraction, gmtoff_fraction = _strptime(data_string, format)
  File "/Users/karthikeyansingaravelan/stuff/python/cpython/Lib/_strptime.py", 
line 349, in _strptime
    raise ValueError("time data %r does not match format %r" %
ValueError: time data '2018-06-14 10:10:11 PDT' does not match format '%Y-%m-%d 
%H:%M:%S %Z'

Hope this helps!

Thanks

----------
type: compile error -> enhancement

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

Reply via email to