Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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

Merged
guyonroche merged 4 commits intoexceljs:masterfromLibertyNJ:fix/csv-read-date-parsing
Nov 5, 2019
Merged

Fix issue # 991#1019

guyonroche merged 4 commits intoexceljs:masterfromLibertyNJ:fix/csv-read-date-parsing
Nov 5, 2019

Conversation

@LibertyNJ
Copy link
Contributor

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.

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.
@guyonrocheguyonroche merged commiteda23ae intoexceljs:masterNov 5, 2019
@damianaiamad
Copy link

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
Copy link
ContributorAuthor

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
Copy link

damianaiamad commentedNov 21, 2019
edited
Loading

One advantage of@LibertyNJ's solution is that it allows turning off automatic date parsing as follows:

workbook.csv.read(stream, {dateFormats: []})

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

No reviews

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

3 participants

@LibertyNJ@damianaiamad@guyonroche

[8]ページ先頭

©2009-2025 Movatter.jp