This repository has been archived by the owner on Apr 22, 2023. It is now read-only.
fs.stat calls should return sub-second precision timestamps #3284
Labels
Comments
Linux fstat manpage suggests that this will be enabled with It seems like we could support this on the platforms that have access to it. This will likely need a tracking issue in joyent/libuv as well |
For reference: joyent/libuv@5ff2b61 and joyent/libuv@7ca524e. |
Landed in 51f128d |
@bnoordhuis is there another issue with this? On Mac (El Capitan) using node.js 6.5.0 I always get 1s resolution for stats.mtime: |
@bpasero OS X generally seems to round or truncate to the nearest second. What does |
|
There you go. You can double-check with the program below but it will probably only confirm what stat(1) says. #include <stdio.h>
#include <sys/stat.h>
int main(int argc, char **argv) {
struct stat s;
int i;
for (i = 1; i < argc; i++)
if (stat(argv[i], &s))
perror(argv[i]);
else
printf("%s %lu.%lu %lu.%lu %lu.%lu\n",
argv[i],
s.st_atimespec.tv_sec, s.st_atimespec.tv_nsec,
s.st_ctimespec.tv_sec, s.st_ctimespec.tv_nsec,
s.st_mtimespec.tv_sec, s.st_mtimespec.tv_nsec);
return 0;
} |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Currently, fs.stat returns timestamps with only seconds, the milliseconds being always zero. However, many filesystems record and expose sub-second timestamps. It would be nice if nodejs exposed these, atleast up to the millisecond resolution.
Concretely, the stats object is filled by:
The nanosecond timestamps should be accessible as s->st_mtimensec, or possibly s->st_mtime.nsec. There are probably some platform differences.
The text was updated successfully, but these errors were encountered: