New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
strptime not parsing some timezones #70151
Comments
I get a ValueError when running the following through strptime: datetime.datetime.strptime('(CST)', '(%Z)') But the following works: PST and MST also trigger the same exception. |
I suspect the datetime module’s %Z parsing depends on the locale, just like time.strptime() does: <https://docs.python.org/dev/library/time.html#time.strptime\>. |
The code is shared by the two modules (it's in _strptime.py). So, yes. There is clearly a doc bug here (%Z needs a footnote in the table in the datetime docs), but there is no practical way to implement the parsing of arbitrary (non-locale) timezone strings, since it is not a one-to-one mapping. |
This was fixed so can be closed. Current datetime docs have a footnote for %Z: ... any value in time.tzname for your machine’s locale the hard-coded values UTC and GMT |
I'm closing this as fixed, the note in datetime docs is here: https://docs.python.org/3.9/library/datetime.html (search for 'only accepts', - note 6) |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: