diff options
author | Refael Ackermann <refack@gmail.com> | 2017-05-23 19:15:56 +0300 |
---|---|---|
committer | James M Snell <jasnell@gmail.com> | 2017-06-07 23:38:04 +0300 |
commit | c756efb25a0ceb5cd1723581b9701676682b0e62 (patch) | |
tree | 9d552c0a056e1014d5f6e2e7dc298b4bb4688461 /doc/api/fs.md | |
parent | 4b2c756bfc4dea51236161d7e0c519a0c6918221 (diff) |
fs: expose Stats times as Numbers
PR-URL: https://github.com/nodejs/node/pull/13173
Fixes: https://github.com/nodejs/node/issues/8276
Refs: https://github.com/nodejs/node/pull/12607
Refs: https://github.com/nodejs/node/pull/12818
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Brian White <mscdex@mscdex.net>
Diffstat (limited to 'doc/api/fs.md')
-rw-r--r-- | doc/api/fs.md | 28 |
1 files changed, 18 insertions, 10 deletions
diff --git a/doc/api/fs.md b/doc/api/fs.md index 5361f06f209..1decabbc39b 100644 --- a/doc/api/fs.md +++ b/doc/api/fs.md @@ -301,10 +301,14 @@ argument to `fs.createReadStream()`. If `path` is passed as a string, then ## Class: fs.Stats <!-- YAML added: v0.1.21 +changes: + - version: REPLACEME + pr-url: https://github.com/nodejs/node/pull/13173 + description: Added times as numbers. --> -Objects returned from [`fs.stat()`][], [`fs.lstat()`][] and [`fs.fstat()`][] and their -synchronous counterparts are of this type. +Objects returned from [`fs.stat()`][], [`fs.lstat()`][] and [`fs.fstat()`][] and +their synchronous counterparts are of this type. - `stats.isFile()` - `stats.isDirectory()` @@ -329,20 +333,23 @@ Stats { size: 527, blksize: 4096, blocks: 8, + atimeMs: 1318289051000.1, + mtimeMs: 1318289051000.1, + ctimeMs: 1318289051000.1, + birthtimeMs: 1318289051000.1, atime: Mon, 10 Oct 2011 23:24:11 GMT, mtime: Mon, 10 Oct 2011 23:24:11 GMT, ctime: Mon, 10 Oct 2011 23:24:11 GMT, birthtime: Mon, 10 Oct 2011 23:24:11 GMT } ``` -Please note that `atime`, `mtime`, `birthtime`, and `ctime` are -instances of [`Date`][MDN-Date] object and appropriate methods should be used -to compare the values of these objects. For most general uses -[`getTime()`][MDN-Date-getTime] will return the number of milliseconds elapsed -since _1 January 1970 00:00:00 UTC_ and this integer should be sufficient for -any comparison, however there are additional methods which can be used for -displaying fuzzy information. More details can be found in the -[MDN JavaScript Reference][MDN-Date] page. +*Note*: `atimeMs`, `mtimeMs`, `ctimeMs`, `birthtimeMs` are [numbers][MDN-Number] +that hold the corresponding times in milliseconds. Their precision is platform +specific. `atime`, `mtime`, `ctime`, and `birthtime` are [`Date`][MDN-Date] +object alternate representations of the various times. The `Date` and number +values are not connected. Assigning a new number value, or mutating the `Date` +value, will not be reflected in the corresponding alternate representation. + ### Stat Time Values @@ -2841,6 +2848,7 @@ The following constants are meant for use with the [`fs.Stats`][] object's [FS Constants]: #fs_fs_constants_1 [MDN-Date-getTime]: https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Date/getTime [MDN-Date]: https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Date +[MDN-Number]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Number_type [MSDN-Rel-Path]: https://msdn.microsoft.com/en-us/library/windows/desktop/aa365247.aspx#fully_qualified_vs._relative_paths [Readable Stream]: stream.html#stream_class_stream_readable [Writable Stream]: stream.html#stream_class_stream_writable |