Date imported with cellDates set to true is off by a fraction of a second #2910

Closed
opened 2023-04-06 15:02:17 +00:00 by dominic-simplan · 2 comments

I am importing an Excel file with a Date cell:
grafik

cellDates is set to true:

XLSX.read(data, {type: 'array', cellDates: true})

Accessing the cells value contains an incorrect Date object which is off by a fraction of a second:

let cell = workbook.Sheets[sheetName]["A2"];
cell.v is "2023-01-30T20:59:59.999Z" while it should be "2023-01-30T21:00:00.000Z"

Please find attached the used Excel file and the HTML example used to reporduce the issue

I am importing an Excel file with a Date cell: ![grafik](/attachments/d7d7d67e-bcb0-4b0f-929b-384aa6a4d17d) cellDates is set to true: `XLSX.read(data, {type: 'array', cellDates: true})` Accessing the cells value contains an incorrect Date object which is off by a fraction of a second: `let cell = workbook.Sheets[sheetName]["A2"];` cell.v is "2023-01-30T20:59:59.999Z" while it should be "2023-01-30T21:00:00.000Z" Please find attached the used Excel file and the HTML example used to reporduce the issue

Is there any workaround for this issue or any hint where to fix this in the source code?
Do you accept Merge Requests?

Is there any workaround for this issue or any hint where to fix this in the source code? Do you accept Merge Requests?
Owner

This should work correctly in 0.20.0, as verified on the websites https://oss.sheetjs.com/ and https://oss.sheetjs.com/sheetjs/

If you are getting the wrong results on the live website, please share your current IANA timezone (run Intl.DateTimeFormat().resolvedOptions().timeZone in your browser console) and we can take a closer look

This should work correctly in 0.20.0, as verified on the websites https://oss.sheetjs.com/ and https://oss.sheetjs.com/sheetjs/ If you are getting the wrong results on the live website, please share your current IANA timezone (run `Intl.DateTimeFormat().resolvedOptions().timeZone` in your browser console) and we can take a closer look
Sign in to join this conversation.
No Milestone
No Assignees
2 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: sheetjs/sheetjs#2910
No description provided.