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

Parsing with H and zero hour fails #87

Closed
lukebaker opened this issue Apr 30, 2021 · 2 comments
Closed

Parsing with H and zero hour fails #87

lukebaker opened this issue Apr 30, 2021 · 2 comments

Comments

@lukebaker
Copy link

Tested on node 14.15.1:

> fecha.parse("4/18/2021 01:41:42", "M/D/YYYY HH:mm:ss")
2021-04-18T05:41:42.000Z
> fecha.parse("4/18/2021 00:41:42", "M/D/YYYY HH:mm:ss")
2021-04-18T04:41:42.000Z
> fecha.parse("4/18/2021 1:41:42", "M/D/YYYY H:mm:ss")
2021-04-18T05:41:42.000Z
> fecha.parse("4/18/2021 0:41:42", "M/D/YYYY H:mm:ss")
null

The first three parse as expected, but the last one fails to parse. I would have expected it to be: 2021-04-18T04:41:42.000Z. Looking at the code, it appears the H when parsing uses the twoDigitsOptional regular expression, which only matches if it starts with a digit 1-9, whereas the documentation suggestions that H can parse 0 1 ... 22 23.

@taylorhakes
Copy link
Owner

Thanks for catching this @lukebaker . If you create a PR I will happily merge it

@taylorhakes
Copy link
Owner

Fixed issue in 4.2.2

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