node-csv icon indicating copy to clipboard operation
node-csv copied to clipboard

Date parse bug

Open t1a2l opened this issue 2 years ago • 2 comments

when the parse function gets a date string it parse it incorrectly.

for example if i have the string "2023-12-11" - it will be converted as 11/12/2023 02:00:00

the issue is instead of a 00:00:00 time i get 02:00:00, and i don't understand why.

t1a2l avatar Dec 12 '23 12:12 t1a2l

Please refer to the cast_date documentation which states that the option use the Date.parse function. It is implemented here.

My guess, it is the same date, just the timezone is different. I invite you to provide a 3-4 lines example to get further help.

wdavidw avatar Dec 12 '23 20:12 wdavidw

@wdavidw It is connected to the time zone, can you maybe add an option that if cast_date is true, i can maybe a timezone option so i get the correct result? Date.parse("2023-12-11") -> Mon Dec 11 2023 02:00:00 GMT+0200 Date.parse("2023-12-11 GMT+2") -> Mon Dec 11 2023 00:00:00 GMT+0200

I am getting a date string from csv and i want to parse it in local time. why not use moment or soemthing like that instead?

t1a2l avatar Dec 14 '23 09:12 t1a2l