统计时间值


🌐 Stat time values

atimeMsmtimeMsctimeMsbirthtimeMs 属性是数值类型,用于保存对应时间的毫秒值。它们的精度取决于平台。当在生成该对象的方法中传入 bigint: true 时,这些属性将为 大整数,否则为 数字

🌐 The atimeMs, mtimeMs, ctimeMs, birthtimeMs properties are numeric values that hold the corresponding times in milliseconds. Their precision is platform specific. When bigint: true is passed into the method that generates the object, the properties will be bigints, otherwise they will be numbers.

atimeNsmtimeNsctimeNsbirthtimeNs 属性是 大整数,用于以纳秒为单位保存对应的时间。它们仅在向生成对象的方法传入 bigint: true 时才会出现。它们的精度取决于平台。

🌐 The atimeNs, mtimeNs, ctimeNs, birthtimeNs properties are bigints that hold the corresponding times in nanoseconds. They are only present when bigint: true is passed into the method that generates the object. Their precision is platform specific.

atimemtimectimebirthtimeDate 对象的各种时间的备用表示。Date 和数字值之间没有关联。分配一个新的数字值或更改 Date 值,不会反映在对应的备用表示中。

统计对象中的时间具有以下语义:

🌐 The times in the stat object have the following semantics:

  • atime “访问时间”:文件数据最后一次被访问的时间。可被 mknod(2)、utimes(2) 和 read(2) 系统调用修改。
  • mtime “修改时间”:文件数据最后被修改的时间。由 mknod(2)、utimes(2) 和 write(2) 系统调用更改。
  • ctime “更改时间”:文件状态最后一次更改的时间(inode 数据修改)。可由 chmod(2)、chown(2)、link(2)、mknod(2)、rename(2)、unlink(2)、utimes(2)、read(2) 和 write(2) 系统调用修改。
  • birthtime “创建时间”:文件创建的时间。文件创建时设置一次。在不支持 birthtime 的文件系统上,该字段可能会存储 ctime1970-01-01T00:00Z(即 Unix 纪元时间戳 0)。在这种情况下,该值可能大于 atimemtime。在 Darwin 和其他 FreeBSD 变体上,如果使用 utimes(2) 系统调用显式将 atime 设置为早于当前 birthtime 的值,也会进行设置。

在 Node.js 0.12 之前,Windows 系统上的 ctime 保存了 birthtime。从 0.12 版本开始,ctime 并不是“创建时间”,在 Unix 系统上,它也从来不是。

🌐 Prior to Node.js 0.12, the ctime held the birthtime on Windows systems. As of 0.12, ctime is not "creation time", and on Unix systems, it never was.