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

parseISO parses number '30' when it should error. #3763

Open
sheki opened this issue Apr 10, 2024 · 2 comments
Open

parseISO parses number '30' when it should error. #3763

sheki opened this issue Apr 10, 2024 · 2 comments

Comments

@sheki
Copy link

sheki commented Apr 10, 2024

Behavior

const { parseISO} = require('date-fns');
console.log(parseISO('30')); // prints '3000-01-01T08:00:00.000Z'

This should error/return invalid date instead of parsing.

Similar code in golang returns an error when parsing '30'.
https://go.dev/play/p/L8_zo40vNNA

@piet-maier
Copy link

The documentation states:

Function accepts complete ISO 8601 formats as well as partial implementations.

In other words: This is the expected behavior.

@stanleyk
Copy link

Well... Although formally correct, this substantially reduces the usability of such parsing. The likelihood of "30" and such being an intentional representation of "30th century" is virtually zero. It would help a lot, if this behavior were an opt in.

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

3 participants