Skip to content

utimes doesn't seem to support subseconds times #22070

@arcanis

Description

@arcanis
  • Version: 10.7.0 / 8.11.3
  • Platform: OSX & Linux
  • Subsystem: fs

Not sure if it's an implementation issue or a documentation issue, but the following is unexpected:

> var d = new Date(1234567891234);

> fs.utimesSync('./test', d, d);
> fs.statSync('./test').mtimeMs
1234567891000

> fs.futimesSync(fs.openSync('./test', 'w'), d, d);
> fs.statSync('./test').mtimeMs
1234567891234

As you can see, the precision is lost (my systems support subsecond precisions - touch manages to change them, and both the stat utility and fs.stat can read them without issues).

The Node documentation also doesn't mention that utimes has a different behavior from futimes (it actually suggest they share the exact same behavior, since futimes redirect to utimes), except possibly in this archived post.

Additionally, the function name (utimes) seem to match the behavior of 2 utime instead of 3 utimes, which seems counterintuitive. The libuv implementation is called uv_fs_utime , which at least hints at the difference of behavior (except that they use uv_fs_futime instead of uv_fs_futimes ..).

Metadata

Metadata

Assignees

No one assigned

    Labels

    fsIssues and PRs related to the fs subsystem / file system.libuvIssues and PRs related to the libuv dependency or the uv binding.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions