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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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); | ||
|
||
if (matched !== null) { | ||
config._d = new Date(+matched[1]); | ||
return; | ||
|
@@ -215,8 +214,12 @@ export function configFromString(config) { | |
return; | ||
} | ||
|
||
// Final attempt, use Input Fallback | ||
hooks.createFromInputFallback(config); | ||
if (config._strict) { | ||
config._isValid = false; | ||
} else { | ||
// Final attempt, use Input Fallback | ||
hooks.createFromInputFallback(config); | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why do you enforce _strict for the InputFallback? There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. |
||
} | ||
|
||
hooks.createFromInputFallback = deprecate( | ||
|
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.