Skip to content

Commit

Permalink
doc: clarify fs.utimes() arguments
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
dguo authored and Fishrock123 committed Oct 11, 2016
1 parent 858a7bb commit 5dd6229
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions doc/api/fs.md
Original file line number Diff line number Diff line change
Expand Up @@ -1438,7 +1438,7 @@ added: v0.1.31
Asynchronous realpath(3). The `callback` gets two arguments `(err,
resolvedPath)`. May use `process.cwd` to resolve relative paths.

Only paths that can be converted to UTF8 strings are supported.
Only paths that can be converted to UTF8 strings are supported.

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

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

Note: the arguments `atime` and `mtime` of the following related functions does
follow the below rules:
Note: the arguments `atime` and `mtime` of the following related functions
follow these rules:

- If the value is a numberable string like `'123456789'`, the value would get
converted to corresponding number.
- If the value is `NaN` or `Infinity`, the value would get converted to
`Date.now()`.
- The value should be a Unix timestamp in seconds. For example, `Date.now()`
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`.

## fs.utimesSync(path, atime, mtime)
<!-- YAML
Expand Down

0 comments on commit 5dd6229

Please sign in to comment.