-
-
Notifications
You must be signed in to change notification settings - Fork 32k
Behavior of datetime.datetime.strptime differs from documented behavior on %z #122781
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
Comments
Linked a PR where I made %z allow an optional utc offset instead of mandating a utc offset, would appreciate it if someone could take a look, thanks! |
Making cc @pganssle |
(I believe that rejecting |
cc @pganssle This can be closed |
Bug report
Bug description:
will fail with
ValueError: time data '2024-03-21T15:49:51' does not match format '%Y-%m-%dT%H:%M:%S%z'
From the documentation for strptime, empty string should be allowed here.
NB: strftime behaves correctly.
So
strptime(strftime(datetime.datetime(2024, 3, 21, 15, 49, 51), '%Y-%m-%dT%H:%M:%S%z'), '%Y-%m-%dT%H:%M:%S%z')
would fail.CPython 3.12.4, WSL2 (Ubuntu 20.04)
CPython versions tested on:
3.12
Operating systems tested on:
Linux
Linked PRs
%z
instrptime
#132922The text was updated successfully, but these errors were encountered: