Skip to content
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

Still a problem with date parsing #1005

Open
svendeckers opened this issue Feb 21, 2018 · 6 comments
Open

Still a problem with date parsing #1005

svendeckers opened this issue Feb 21, 2018 · 6 comments

Comments

@svendeckers
Copy link

svendeckers commented Feb 21, 2018

I've read issues similar to mine, but I haven't found a solution yet.
I made a CSV-file in a texteditor, VI, so no Excel-involvement here.
I entered a date in DD/MM/YYYY notation ("01/04/2018"), so this is the first of April.
Any way I try to read the date, I always get the 4th of January returned:

let workbook = XLSX.readFile("./dateTest.csv", {cellDates:true,dateNF:'dd/mm/yyyy'});
let worksheet = workbook.Sheets[workbook.SheetNames[0]];
let cell = worksheet["A2"];
console.log(cell.w);
Results in "04/01/2018".

dateTest.csv:
DATE;
01/04/2018;

It seems the value is interpreted in the local settings, regardless of the dateNF.
I cannot ask my clients to change their settings.
Am I missing something or are we waiting for the locale option to be passed with readFile?

@sangeethaharidass
Copy link

Use xlsx.read function procedure to read a file.

@svendeckers
Copy link
Author

svendeckers commented Apr 5, 2018

I'm glad you took the effort, but unfortunately to no avail.

When I read the file using fs.readFile and I print the contents, I get this:
01/04/2018
Then I do:
let workbook = XLSX.read(contents, {cellDates:true,dateNF:'dd/mm/yyyy'});
let worksheet = workbook.Sheets[workbook.SheetNames[0]];
let jsonData = XLSX.utils.sheet_to_json(worksheet, {header: headers, defval: ''});
and print the jsonData and I get:
04/01/2018

@ArturPrzybysz
Copy link

Any progress on the topic?

@svendeckers
Copy link
Author

Not from my side

@bean5
Copy link

bean5 commented Sep 19, 2018

I am seeing DateTimes in CSV treated differently than those in XLSX files. See also: SheetJS/SheetJS.github.io#14

@louis-nguyen-97
Copy link

Any update on this issue? I faced the same problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants