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

HH token does not support the number 24, even though the documentation says it should (00 to 24) #703

Closed
ceorcham opened this issue Oct 30, 2019 · 3 comments · Fixed by #705
Labels

Comments

@ceorcham
Copy link
Contributor

According to ISO 8601 arrow.get('2019-10-29T24:00:00') should parse to October 30, 2019 (2019-10-30T00:00:00), but instead is throwing an exception ValueError: hour must be in 0..23

It also fails when doing explicit formatting (same exception)
arrow.get('2013-12-31T24:00:00', ['YYYY-MM-DD[T]HH:mm:ss'])

If you look at the docs at https://arrow.readthedocs.io/en/latest/#supported-tokens it says HH token is from 00 to 24

if this is accepted as a bug, it seems a fix for this can be done at arrow/parser.py inside the _build_datetime function ( I can do it, including unit tests)

@jadchaar
Copy link
Member

jadchaar commented Oct 30, 2019

Hey @ceorcham, you seem to be correct. On the Wikipedia page it says:

Midnight is a special case and may be referred to as either "00:00" or "24:00". The notation "00:00" is used at the beginning of a calendar day and is the more frequently used. At the end of a day use "24:00". "2007-04-05T24:00" is the same instant as "2007-04-06T00:00".

If you'd like to take this on, go for it!

We should ensure that the new functionality works for both the parser and the formatter.

@jadchaar jadchaar added the bug label Oct 30, 2019
ceorcham added a commit to ceorcham/arrow that referenced this issue Oct 31, 2019
ceorcham added a commit to ceorcham/arrow that referenced this issue Oct 31, 2019
@ceorcham
Copy link
Contributor Author

@jadchaar I just made a PR (#705) with the changes for the parser, now 24:00 will become 00:00 next day. Don't hesitate requesting any changes if needed, I'm happy to help.

I think changes for the formatter are not needed because the 24:00 is just another way to represent next day 00:00, so when formatting HH at midnight will always be 00

@jadchaar
Copy link
Member

jadchaar commented Nov 1, 2019

Ah yes you are correct! Thanks for the PR by the way--I am reviewing it right now.

ceorcham added a commit to ceorcham/arrow that referenced this issue Nov 1, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants