Skip to content

regression: fs.utimes/futimes for dates before unix epoch #14017

Closed
@isaacs

Description

@isaacs

As of Node v4, fs.utimes and fs.utimes are truncating the atime and mtime values to a positive integer.

This is incorrect, and makes it impossible to set atime and mtime values before 1970-01-01T00:00:00.000Z without creating a Date object.

It looks like this is the culprit:

function toUnixTimestamp(time) {
  // eslint-disable-next-line eqeqeq
  if (typeof time === 'string' && +time == time) {
    return +time;
  }
  if (Number.isFinite(time)) {
    if (time < 0) {
      return Date.now() / 1000;

Metadata

Metadata

Assignees

No one assigned

    Labels

    fsIssues and PRs related to the fs subsystem / file system.regressionIssues related to regressions.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions