- Notifications
You must be signed in to change notification settings - Fork1.9k
Fix issue # 991#1019
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Fix issue # 991#1019
Uh oh!
There was an error while loading.Please reload this page.
Conversation
Proves that the current implementation of csv.readFile parses stringsthat satisfy the regex /^\d{4}-?\d/ as if they were dates.Passes tests for issue 991. Dayjs and momentjs do not have identicalAPIs. Original implementation of dayjs substituted all references to"momentjs" with "dayjs". There is no dayjs.ISO_8601 constant. Dayjsmust be extended with a plugin to customize date parsing format. Dayjsdoes not accept an array of date formats as an argument.
Adjusts default dateFormat strings to be aligned with intendeddefault behavior.
damianaiamad commentedNov 12, 2019
I'm a bit late to this party, sorry. I think I've identified a further problem with dayjs that means this fix does not fully solve the problem. Please see#991 |
LibertyNJ commentedNov 12, 2019
Can confirm, 'D/M/YY' pattern breaks test with 'NZ1019316'. Dayjs appears to have further issues as@damianaiamad identified in#991. Reverting to moment is definitely a solution (wasn't broke, why fix it?), if the size of that module is not still a concern as it was in issue#794. |
damianaiamad commentedNov 21, 2019 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
One advantage of@LibertyNJ's solution is that it allows turning off automatic date parsing as follows:
|
There is an issue where the csv.read/readFile method will incorrectly parse certain strings as dates that should not be dates. This may stem from differences in the API of momentjs and dayjs that were not addressed after migration.
By default dayjs will transform any string that matches the regex /^\d{4}-?\d/ into a valid date, whether it makes sense for that string to be interpreted as a date or not. This appears to be intended behavior on the part of dayjs, as it lets the module parse dates from strings in non-standard formats. If this is not the intended behavior of the csv.read/readFile methods, the default options.map method needs some more logic to help decide when to return a date.