-
-
Notifications
You must be signed in to change notification settings - Fork 33.7k
Closed
Labels
docIssues and PRs related to the documentations.Issues and PRs related to the documentations.fsIssues and PRs related to the fs subsystem / file system.Issues and PRs related to the fs subsystem / file system.
Description
- Version: v6.5.0
- Platform: Linux dell 4.4.20-1-MANJARO deps: update openssl to 1.0.1j #1 SMP PREEMPT Wed Sep 7 19:11:34 UTC 2016 x86_64 GNU/Linux
- Subsystem:
Could the documentation of fs.utimes (It says the type is Integer, and NaN or Infinity, will be converted to Date.now()) be more clear about the arguments? It looks like I can pass new Date(), but Date.now() needs to be divided by 1000. According to MDN Date.prototype.valueOf() and Date.now() both return: "The number of milliseconds between 1 January 1970 00:00:00 UTC and the given date.". It would be nice if the documentation mentioned that if the value is an Integer, it will be handled as a timestamp with precision of seconds.
var fs = require('fs');
fs.writeFileSync('test.txt', 'abc');
console.log(' ok', fs.statSync('test.txt').atime.getTime());
fs.utimesSync('test.txt', new Date(), new Date());
console.log(' ok', fs.statSync('test.txt').atime.getTime());
console.log(' ok', Date.now());
fs.utimesSync('test.txt', Date.now(), Date.now());
console.log('not ok', fs.statSync('test.txt').atime.getTime());
fs.utimesSync('test.txt', Date.now() / 1000, Date.now() / 1000);
console.log(' ok', fs.statSync('test.txt').atime.getTime());
Output
ok 1474133782000
ok 1474133783000
ok 1474133783702
not ok 1474133783702000
ok 1474133783000
Metadata
Metadata
Assignees
Labels
docIssues and PRs related to the documentations.Issues and PRs related to the documentations.fsIssues and PRs related to the fs subsystem / file system.Issues and PRs related to the fs subsystem / file system.