From eed87b1637d64340856bb7f77db899f5283ca84f Mon Sep 17 00:00:00 2001 From: Luca Maraschi Date: Fri, 17 Mar 2017 17:07:19 +0100 Subject: [PATCH] fs: (+/-)Infinity and NaN invalid unixtimestamp Infinity and NaN are currently considered valid input when generating a unix time stamp but are defaulted arbitrarly to Date.now()/1000. This PR removes this behaviour and throw an exception like all the other invalid input types. PR-URL: https://github.com/nodejs/node/pull/11919 Reviewed-By: Colin Ihrig Reviewed-By: Matteo Collina Reviewed-By: James M Snell --- doc/api/fs.md | 3 +-- lib/fs.js | 4 ++-- test/parallel/test-fs-timestamp-parsing-error.js | 7 ++++--- test/parallel/test-fs-utimes.js | 10 ++++------ 4 files changed, 11 insertions(+), 13 deletions(-) diff --git a/doc/api/fs.md b/doc/api/fs.md index c6046d27313791..a527e9489672df 100644 --- a/doc/api/fs.md +++ b/doc/api/fs.md @@ -1880,8 +1880,7 @@ follow these rules: returns milliseconds, so it should be divided by 1000 before passing it in. - If the value is a numeric string like `'123456789'`, the value will get converted to the corresponding number. -- If the value is `NaN` or `Infinity`, the value will get converted to - `Date.now() / 1000`. +- If the value is `NaN`, `Infinity` or `-Infinity`, an Error will be thrown. ## fs.utimesSync(path, atime, mtime)