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

Invalid datetime.time.fromisoformat #124257

Open
random1st opened this issue Sep 19, 2024 · 4 comments
Open

Invalid datetime.time.fromisoformat #124257

random1st opened this issue Sep 19, 2024 · 4 comments
Labels
stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error

Comments

@random1st
Copy link

random1st commented Sep 19, 2024

Bug report

Bug description:

According to the standard ISO 8601 Thus the value ‘24:00:00’ is chosen to represent the final instant of the day in order to distinguish the expression of this instant from an expression of a time scale unit.

>>> datetime.time.fromisoformat("24:00")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ValueError: hour must be in 0..23

Link to standard pdf

CPython versions tested on:

3.10, 3.12

Operating systems tested on:

Linux, macOS

@random1st random1st added the type-bug An unexpected behavior, bug, or error label Sep 19, 2024
@Eclips4 Eclips4 added the stdlib Python modules in the Lib dir label Sep 19, 2024
@eendebakpt
Copy link
Contributor

Some other discussions on supporting this: dotnet/runtime#12197, astropy/astropy#9837

Also note the documentation of datetime.datetime.fromisoformat:

Return a date corresponding to a date_string given in any valid ISO 8601 format, with the following

The part "in any valid ISO 8601" suggest that fromisodate should support 24:00

@tomasr8
Copy link
Contributor

tomasr8 commented Sep 19, 2024

The part "in any valid ISO 8601" suggest that fromisodate should support 24:00

On one hand it says any valid ISO 8601 format (which with the latest amendement to the spec 24:00 is). On the other hand, it also lists exceptions to the spec. Even though I think it would make sense to support 24:00, if it's decided against it, I think we should at least document this discrepancy in the docs

@hugovk
Copy link
Member

hugovk commented Sep 19, 2024

Is this a duplicate of #102450 (or #54636)?

@eendebakpt
Copy link
Contributor

There is an open PR to allow 24:00: #105856. I can review it (but it would be nice to know beforehand whether we actually want to allow 24:00).

@pganssle @abalkin as code owners

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error
Projects
Development

No branches or pull requests

5 participants