-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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 - parsing invalid string into a valid date #1748
Comments
@kossnocorp is this intended behavior? From a quick glance on |
I've no strong opinion regarding this, to be honest. As I see, not only Moment.js behaves like that: new Date('2016-03-16T08 ooo')
//=> Invalid Date
Date.parse('2016-03-16T08 ooo')
//=> NaN So I guess this is a bug. |
Alright, thanks for the clarification! I'll try attempting on this issue. |
@imballinst thanks 🙏 |
I think there may be another 'case' of this issue. It successfully parses the two digits number. '33' is not a valid ISO string (https://en.wikipedia.org/wiki/ISO_8601), so I think it should fail and return 'Invalid Date'
|
@dojchek noted -- thanks for the information! I'll try handling that case as well in my PR. |
@dojchek it seems like the 2 digits are used to represent centuries, so I guess that's intended? Lines 103 to 120 in 4cf918f
CMIIW @kossnocorp |
@imballinst Yes, I also think that's intended - although not very intuitive.. So it is in fact a valid ISO date. I still need this to "fail" in my use case - so I will check it with some regex or simply check the length of string before doing parseISO, since I only work with dates like Thank you very much for checking this out |
Hi.
I've come across this issue while using date-fns.
Current behaviour:
parseISO('2016-03-16T08 ooo') // returns Date(Wed Mar 16 2016 08:00:00 GMT+0100 (CET))
Expected behaviour (at least momentjs and some online regex-based parsers):
parseISO('2016-03-16T08 ooo') // returns Invalid Date
Is this actually a bug or for some reason current bahaviour is the expected one?
The text was updated successfully, but these errors were encountered: