Skip to content

Commit 5dd6229

Browse files
dguoFishrock123
authored andcommitted
doc: clarify fs.utimes() arguments
Make it clear that atime and mtime should be in seconds. PR-URL: #8651 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Teddy Katz <teddy.katz@gmail.com> Reviewed-By: Ilkka Myller <ilkka.myller@nodefield.com>
1 parent 858a7bb commit 5dd6229

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

doc/api/fs.md

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1438,7 +1438,7 @@ added: v0.1.31
14381438
Asynchronous realpath(3). The `callback` gets two arguments `(err,
14391439
resolvedPath)`. May use `process.cwd` to resolve relative paths.
14401440

1441-
Only paths that can be converted to UTF8 strings are supported.
1441+
Only paths that can be converted to UTF8 strings are supported.
14421442

14431443
The optional `options` argument can be a string specifying an encoding, or an
14441444
object with an `encoding` property specifying the character encoding to use for
@@ -1637,13 +1637,15 @@ added: v0.4.2
16371637

16381638
Change file timestamps of the file referenced by the supplied path.
16391639

1640-
Note: the arguments `atime` and `mtime` of the following related functions does
1641-
follow the below rules:
1640+
Note: the arguments `atime` and `mtime` of the following related functions
1641+
follow these rules:
16421642

1643-
- If the value is a numberable string like `'123456789'`, the value would get
1644-
converted to corresponding number.
1645-
- If the value is `NaN` or `Infinity`, the value would get converted to
1646-
`Date.now()`.
1643+
- The value should be a Unix timestamp in seconds. For example, `Date.now()`
1644+
returns milliseconds, so it should be divided by 1000 before passing it in.
1645+
- If the value is a numeric string like `'123456789'`, the value will get
1646+
converted to the corresponding number.
1647+
- If the value is `NaN` or `Infinity`, the value will get converted to
1648+
`Date.now() / 1000`.
16471649

16481650
## fs.utimesSync(path, atime, mtime)
16491651
<!-- YAML

0 commit comments

Comments
 (0)