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

YYYY-MM-DD with 3 digit year returns true for isValid() #1363

Closed
mikec83 opened this issue Dec 19, 2013 · 4 comments
Closed

YYYY-MM-DD with 3 digit year returns true for isValid() #1363

mikec83 opened this issue Dec 19, 2013 · 4 comments

Comments

@mikec83
Copy link

mikec83 commented Dec 19, 2013

I notice if I do the following:

moment('013-01-01', 'YYYY-MM-DD').isValid()

it returns true but I'd expect it to return false.

@chall8908
Copy link

You should use moment's strict parsing for this kind of thing. Otherwise, the parser doesn't do much checking of the input. In this case, you end up with a valid date anyways, I assume, because the returned date (January 1st, 13) is the same as the input date. Beyond that, I don't think strict mode checks to see if all the format tokens have been consumed, just that all the input has been.

@mikec83
Copy link
Author

mikec83 commented Dec 19, 2013

Yeah, I tried using strict before opening this issue.

@chall8908
Copy link

Ah, my apologies. As I said, though, I think strict parsing only ensures that all the input has been consumed, which, in this case, it has. I'm not entirely certain this is a bug, per se, but unclear behavior for sure. Even my first thought was "Oh, strict parsing should fix this" when, clearly, it doesn't.

@ichernev
Copy link
Contributor

Fixed in 19a1ceb
Would be in next release.

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