Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fs.utimes arguments documentation #8638

Closed
fcostarodrigo opened this issue Sep 17, 2016 · 1 comment
Closed

fs.utimes arguments documentation #8638

fcostarodrigo opened this issue Sep 17, 2016 · 1 comment
Labels
doc Issues and PRs related to the documentations. fs Issues and PRs related to the fs subsystem / file system.

Comments

@fcostarodrigo
Copy link

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
@targos targos added the fs Issues and PRs related to the fs subsystem / file system. label Sep 17, 2016
@Fishrock123 Fishrock123 added doc Issues and PRs related to the documentations. docs-requested labels Sep 17, 2016
@MylesBorins
Copy link
Contributor

this was fixed by 99ab686

closing

@sam-github sam-github added doc Issues and PRs related to the documentations. and removed doc Issues and PRs related to the documentations. labels Dec 1, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
doc Issues and PRs related to the documentations. fs Issues and PRs related to the fs subsystem / file system.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants