adaltas / node-csv-stringify

CSV stringifier implementing the Node.js `stream.Transform` API
https://csv.js.org/stringify/
186 stars 52 forks source link

Date conversion stopped working in version 5.5.1 #116

Closed Marigold closed 4 years ago

Marigold commented 4 years ago

Describe the bug

After upgrading from 5.5.0 to 5.5.1, date conversion, unfortunately, stopped working. Downgrading back to 5.5.0 fixed the problem. Thanks!

To Reproduce

const stringify = require("csv-stringify");
const input = [[new Date()]];
const options = {
  cast: {
    date: (value) => value.toISOString(),
  },
};

stringify(input, options, (err, output) => {
  console.log(output);
  // prints 1599041632529, but should print 2020-09-02T10:14:49.819Z
});
wdavidw commented 4 years ago

Can not reproduce:

➜  ~: mkdir test-date && cd test-date
➜  test-date: yarn init
yarn init v1.22.4
question name (test-date): 
question version (1.0.0): 
question description: 
question entry point (index.js): 
question repository url: 
question author: 
question license (MIT): 
question private: 
success Saved package.json
✨  Done in 4.23s.
➜  test-date: yarn add csv-stringify
yarn add v1.22.4
info No lockfile found.
[1/4] 🔍  Resolving packages...
[2/4] 🚚  Fetching packages...
[3/4] 🔗  Linking dependencies...
warning The target of linked package "plugable" is missing. Removing link.
[4/4] 🔨  Building fresh packages...

success Saved lockfile.
success Saved 1 new dependency.
info Direct dependencies
└─ csv-stringify@5.5.1
info All dependencies
└─ csv-stringify@5.5.1
✨  Done in 0.24s.
➜  test-date: cat > test.js <<EOF
const stringify = require("csv-stringify");
const input = [[new Date()]];
const options = {
  cast: {
    date: (value) => value.toISOString(),
  },
};

stringify(input, options, (err, output) => {
  console.log(output);
  // prints 1599041632529, but should print 2020-09-02T10:14:49.819Z
});
EOF

➜  test-date: node test.js       
2020-09-02T11:27:07.176Z
Marigold commented 4 years ago

@wdavidw My bad, I was using a global legacy version. Sorry and thanks for looking into this.