Describe the bug
Using csv-parse: 5.0.4
When cast_date is set to true, if you parse a string that ends with a number, the string is cast to a date.
According to the docs https://csv.js.org/parse/options/cast_date/, "The implementation relies on Date.parse. The CSV value is left untouched if the function returns NaN."
Date.parse("Test 2") => NaN, however the parsed field is returned as 2001-02-01T00:00:00.000Z
To Reproduce
with file test.csv
and implementation
async parseCsv<T>(filePath: string): Promise<T[]> {
const content: Buffer = await fs.readFile(filePath)
const parsed: T[] = parse(content, {
cast: true,
cast_date: true,
columns: true,
})
return parsed
}
returned data is:
{
title: 2001-02-01T00:00:00.000Z,
}