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

Incorrect parsing "24" hour #99

Open
vakhet opened this issue Nov 2, 2020 · 1 comment
Open

Incorrect parsing "24" hour #99

vakhet opened this issue Nov 2, 2020 · 1 comment

Comments

@vakhet
Copy link

vakhet commented Nov 2, 2020

Hello!

Stumbled on this strange behavior, consider myself as a bug, what do you think?

Python 3.8.1 (v3.8.1:1b293b6006, Dec 18 2019, 14:08:53)
[Clang 6.0 (clang-600.0.57)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import ciso8601
>>> ciso8601.parse_datetime("2020-02-28T23:00:00Z")
datetime.datetime(2020, 2, 28, 23, 0, tzinfo=datetime.timezone.utc)
>>> ciso8601.parse_datetime("2020-02-28T24:00:00Z")
datetime.datetime(2020, 2, 29, 0, 0, tzinfo=datetime.timezone.utc)
>>> ciso8601.parse_datetime("2020-02-28T25:00:00Z")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ValueError: hour must be in 0..23

It is not only passes "24" hour, but also returns different date. Logic is obvious (next day, 00 hour), but behavior is incorrect IMHO
"2020-02-28T24:00:00Z" != datetime.datetime(2020, 2, 29, 0, 0, tzinfo=datetime.timezone.utc)

Also, 24 is not in range 00..23

@movermeyer
Copy link
Collaborator

This actually was a valid ISO 8601 datetime.

Prior to ISO 8601-1:2019, 24:00 was a valid time in ISO 8601.

However, as of ISO 8601-1:2019, it has been explicitly disallowed.

We haven't figured out how exactly to handle this evolution of the specification within ciso8601's interface.

Tracking this in #100

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants