Skip to content
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

Closed
utkonos mannequin opened this issue Dec 28, 2015 · 5 comments
Closed

strptime not parsing some timezones #70151

utkonos mannequin opened this issue Dec 28, 2015 · 5 comments
Labels
3.9 only security fixes docs Documentation in the Doc dir type-bug An unexpected behavior, bug, or error

Comments

@utkonos
Copy link
Mannequin

utkonos mannequin commented Dec 28, 2015

BPO 25963
Nosy @abalkin, @bitdancer, @vadmium, @Fidget-Spinner, @akulakov

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:

assignee = None
closed_at = <Date 2021-09-07.15:34:06.320>
created_at = <Date 2015-12-28.08:32:13.256>
labels = ['type-bug', '3.9', 'docs']
title = 'strptime not parsing some timezones'
updated_at = <Date 2021-09-07.15:34:06.317>
user = 'https://bugs.python.org/utkonos'

bugs.python.org fields:

activity = <Date 2021-09-07.15:34:06.317>
actor = 'andrei.avk'
assignee = 'docs@python'
closed = True
closed_date = <Date 2021-09-07.15:34:06.320>
closer = 'andrei.avk'
components = ['Documentation']
creation = <Date 2015-12-28.08:32:13.256>
creator = 'utkonos'
dependencies = []
files = []
hgrepos = []
issue_num = 25963
keywords = []
message_count = 5.0
messages = ['257108', '257262', '257294', '399153', '401293']
nosy_count = 7.0
nosy_names = ['belopolsky', 'r.david.murray', 'docs@python', 'martin.panter', 'utkonos', 'kj', 'andrei.avk']
pr_nums = []
priority = 'normal'
resolution = 'fixed'
stage = 'resolved'
status = 'closed'
superseder = None
type = 'behavior'
url = 'https://bugs.python.org/issue25963'
versions = ['Python 3.9']

@utkonos
Copy link
Mannequin Author

utkonos mannequin commented Dec 28, 2015

I get a ValueError when running the following through strptime:

datetime.datetime.strptime('(CST)', '(%Z)')

But the following works:
datetime.datetime.strptime('(EST)', '(%Z)')

PST and MST also trigger the same exception.

@utkonos utkonos mannequin added the type-bug An unexpected behavior, bug, or error label Dec 28, 2015
@vadmium
Copy link
Member

vadmium commented Jan 1, 2016

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\>.

@bitdancer
Copy link
Member

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.

@bitdancer bitdancer added the docs Documentation in the Doc dir label Jan 1, 2016
@akulakov
Copy link
Contributor

akulakov commented Aug 6, 2021

This was fixed so can be closed.

Current datetime docs have a footnote for %Z:

...
strptime() only accepts certain values for %Z:

any value in time.tzname for your machine’s locale

the hard-coded values UTC and GMT

@akulakov
Copy link
Contributor

akulakov commented Sep 7, 2021

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)

@akulakov akulakov added the 3.9 only security fixes label Sep 7, 2021
@akulakov akulakov closed this as completed Sep 7, 2021
@ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3.9 only security fixes docs Documentation in the Doc dir type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

No branches or pull requests

3 participants