Skip to content

utimes precision errors #13255

Description

@jorangreef

Version: v7.10.0
Platform: Windows 10 64-bit
Subsystem: fs

I was working on a fuzz test to test the accuracy of timestamps set using fs.utimes() and found the following two precision bugs on Windows:

NEGATIVE MTIME:
expect mtime=2159345162531
actual mtime=-2135622133469
INACCURATE MTIME:
expect mtime=1713037251360
actual mtime=1713037251359

Here's the gist to reproduce (on a Windows fs with support for at least millisecond timestamps):

varfs=require('fs');varpath='test-utimes-precision';fs.writeFileSync(path,'');console.log('\r\nNEGATIVE MTIME:');varmtime=2159345162531;fs.utimesSync(path,mtime/1000,mtime/1000);varstats=fs.statSync(path);console.log('expect mtime='+mtime);// 2159345162531console.log('actual mtime='+stats.mtime.getTime());// -2135622133469console.log('\r\nINACCURATE MTIME:');varmtime=1713037251360;fs.utimesSync(path,mtime/1000,mtime/1000);varstats=fs.statSync(path);console.log('expect mtime='+mtime);// 1713037251360console.log('actual mtime='+stats.mtime.getTime());// 1713037251359

On Mac, the negative mtime is also an issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    fsIssues and PRs related to the fs subsystem / file system.windowsIssues and PRs related to the Windows platform.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions