-
Notifications
You must be signed in to change notification settings - Fork 30.1k
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
doc: improve fs.utimes #14154
doc: improve fs.utimes #14154
Conversation
/cc @nodejs/documentation |
9fdfe32
to
555d21b
Compare
- Values can be either numbers representing Unix epoch time, `Date`s, or a | ||
numeric string like `'123456789.0'`. | ||
- If the value can not be converted to a number, or is `NaN`, `Infinity` or | ||
`-Infinity`, a `Error` will be thrown. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Still "an Error
"?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What happens if Invalid Date
is passed?
Also, if we can pass a string that gets coerced to numbers, then I'm not sure we should put string
in the docs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Still an
Error
inmaster
- https://github.com/nodejs/node/blob/master/lib/fs.js#L1196 - Even a
Date
is converted (or coerced) tonumber
so the sentence still stands true (Number(new Date("foo")) === NaN
), just missing an explicit mention.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@refack Sorry, I meant a nit, still "an", not "a")
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@benjamingr the string
note was alway there. As for the arg type I think it's better to explicitly state string
but this is JS1.0 semantics so we need to ask ourselves WWDCD?
What Would Douglas Crockford Do
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@refack Sorry, I meant a nit, still "an", not "a")
Ack. But I'm not pushing a fix yet, so the string
conversation will stay open.
No:
var fs = require('fs')
fs.utimes(process.argv[2], 1, 2, () => {
const stat = fs.statSync(process.argv[2])
console.log(`file modified at ${stat.mtime} and accessed at ${stat.atime}`)
})
|
That's surprising since intuitively I'd assume |
Where do we stand here? |
@refack as far as I see it there is little to do to get this ready to land, right? I would otherwise close the PR sometime soon. |
Landed in 64e97b2 |
PR-URL: #14154 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
PR-URL: nodejs#14154 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
PR-URL: #14154 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
PR-URL: nodejs/node#14154 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
PR-URL: #14154 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
PR-URL: #14154 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
AFAICT the internal conversion helper
toUnixTimestamp
has always been able to convertDate
s - https://github.com/nodejs/node/commit/1d5ff15Currently precision is platform dependant, but that could be fixed.
@nodejs/platform-aix - Should the#14154 (comment)AIX >= 7.1
note be added toutimes
as well?/cc @bnoordhuis @nodejs/fs
Checklist
mdlint
passesAffected core subsystem(s)
doc,fs