Skip to content

Commit ec56cbe

Browse files
refackMylesBorins
authored andcommitted
doc: improve fs.utimes
PR-URL: #14154 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Ruben Bridgewater <[email protected]>
1 parent 6565dda commit ec56cbe

File tree

1 file changed

+12
-15
lines changed

1 file changed

+12
-15
lines changed

doc/api/fs.md

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1323,13 +1323,13 @@ changes:
13231323
-->
13241324

13251325
* `fd` {integer}
1326-
* `atime` {integer}
1327-
* `mtime` {integer}
1326+
* `atime` {number|string|Date}
1327+
* `mtime` {number|string|Date}
13281328
* `callback` {Function}
13291329
* `err` {Error}
13301330

1331-
Change the file timestamps of a file referenced by the supplied file
1332-
descriptor.
1331+
Change the file system timestamps of the object referenced by the supplied file
1332+
descriptor. See [`fs.utimes()`][].
13331333

13341334
*Note*: This function does not work on AIX versions before 7.1, it will return
13351335
the error `UV_ENOSYS`.
@@ -2354,21 +2354,18 @@ changes:
23542354
-->
23552355

23562356
* `path` {string|Buffer|URL}
2357-
* `atime` {integer}
2358-
* `mtime` {integer}
2357+
* `atime` {number|string|Date}
2358+
* `mtime` {number|string|Date}
23592359
* `callback` {Function}
23602360
* `err` {Error}
23612361

2362-
Change file timestamps of the file referenced by the supplied path.
2363-
2364-
*Note*: The arguments `atime` and `mtime` of the following related functions
2365-
follow these rules:
2362+
Change the file system timestamps of the object referenced by `path`.
23662363

2367-
- The value should be a Unix timestamp in seconds. For example, `Date.now()`
2368-
returns milliseconds, so it should be divided by 1000 before passing it in.
2369-
- If the value is a numeric string like `'123456789'`, the value will get
2370-
converted to the corresponding number.
2371-
- If the value is `NaN`, `Infinity` or `-Infinity`, an Error will be thrown.
2364+
The `atime` and `mtime` arguments follow these rules:
2365+
- Values can be either numbers representing Unix epoch time, `Date`s, or a
2366+
numeric string like `'123456789.0'`.
2367+
- If the value can not be converted to a number, or is `NaN`, `Infinity` or
2368+
`-Infinity`, a `Error` will be thrown.
23722369

23732370
## fs.utimesSync(path, atime, mtime)
23742371
<!-- YAML

0 commit comments

Comments
 (0)