Can't get a consistent result when parsing dates #1324

Open
opened 2018-10-24 08:58:34 +00:00 by clasqui · 2 comments
clasqui commented 2018-10-24 08:58:34 +00:00 (Migrated from github.com)

I'm trying to import a spreadsheet file, then convert it to json with the util XLSX.utils.sheet_to_json() to iterate through the rows.
I'm getting unexpected results when getting the value of a cell I know it's a date:

  • When the file is imported as xls, the dates show as m/d/yyyy
  • When the same file is imported as csv, the dates show as d/m/yyyy

In my file, using both file types, the dates show as dd/mm/yyyy and I'm using the following options when parsing the file and exporting the WB:

XLSX.utils.sheet_to_json(ws, {header:1, range: 1, dateNF: 'DD/MM/YYYY', cellText: false, raw: false});

I think this is a bug because you can get unexpected results from different inputs and there is no way to uniform it.

I'm trying to import a spreadsheet file, then convert it to json with the util `XLSX.utils.sheet_to_json()` to iterate through the rows. I'm getting unexpected results when getting the value of a cell I know it's a date: - When the file is imported as _xls_, the dates show as `m/d/yyyy` - When the same file is imported as _csv_, the dates show as `d/m/yyyy` In my file, using both file types, the dates show as dd/mm/yyyy and I'm using the following options when parsing the file and exporting the WB: ```javascript XLSX.utils.sheet_to_json(ws, {header:1, range: 1, dateNF: 'DD/MM/YYYY', cellText: false, raw: false}); ``` I think this is a bug because you can get unexpected results from different inputs and there is no way to uniform it.
SheetJSDev commented 2018-10-30 07:56:16 +00:00 (Migrated from github.com)

CSV dates fall back on the browser implementation of date parsing, which is unfortunately very forgiving for some browsers like Chrome

> new Date("This is not a date 1")
Mon Jan 01 2001 00:00:00 GMT-0500 (Eastern Standard Time)

The closest thing we've found to a date specification is the MS-VBAL definition of a date token.

CSV dates fall back on the browser implementation of date parsing, which is unfortunately very forgiving for some browsers like Chrome ```js > new Date("This is not a date 1") Mon Jan 01 2001 00:00:00 GMT-0500 (Eastern Standard Time) ``` The closest thing we've found to a date specification is the `MS-VBAL` definition of a date token.
clasqui commented 2018-10-30 12:05:55 +00:00 (Migrated from github.com)

Sorry for not specifying it. My implementation is on a Node.js server, so I don't think this bug has nothing to do with the browser.

Sorry for not specifying it. My implementation is on a Node.js server, so I don't think this bug has nothing to do with the browser.
Sign in to join this conversation.
No Milestone
No Assignees
1 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#1324
No description provided.