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
[feature] Support for strict formatless parsing #4611
Conversation
moment(String, true)
(strict parsing)moment(String, true)
(strict parsing)
@marwahaha 🏓 Could you kindly review this PR and merge it if it's okay? 2469 is a really annoying issue. |
@@ -192,10 +192,9 @@ export function configFromRFC2822(config) { | |||
} | |||
} | |||
|
|||
// date from iso format or fallback | |||
// date from 1) ASP.NET, 2) ISO, 3) RFC 2822 formats, or 4) optional fallback if parsing isn't strict | |||
export function configFromString(config) { | |||
var matched = aspNetJsonRegex.exec(config._i); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The pr adds moment support ASP.NET dates.
The variable is setup on line 45
var aspNetJsonRegex = /^/?Date((-?\d+)/i;
It is basically a regex that matches a string like this (random number):
/Date(9897979
Not a maintainer, just adding to the conversation.
} else { | ||
// Final attempt, use Input Fallback | ||
hooks.createFromInputFallback(config); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do you enforce _strict for the InputFallback?
Will this cause breaking changes for other users. Who might not be using strict for their moment usage.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you have strict, then you'd have a format, and then you wouldn't do the fallback. So it is not breaking for existing users.
any updates? |
Any reason this hasn't been merged? It's almost 2 years and #2469 is reaaaaally annoying... |
Merged in 022dc03 |
[feature] Support for strict formatless parsing
moment(String, true)
(strict parsing)
Closes #2469