Skip to content

utimes no work #30212

@haraldrudell

Description

@haraldrudell

Am I the only one seeing this?

$ node --experimental-modules src/fsPromisesUtimes.js
(node:86710) ExperimentalWarning: The ESM module loader is experimental.
{ platform: 'darwin', version: 'v12.12.0' }
Actual: 2262-04-11T23:47:16.855Z expected: 2019-01-01T00:00:00.000Z
Completed successfully

And if there is a new promises api in 2019Z, why:

  • Is there no nanoseconds that Linux has had since 2009
  • birthdate available since 2012
  • why do I have to set all times and not only mtime?
/*
© 2019-present Harald Rudell <harald.rudell@gmail.com> (http://www.haraldrudell.com)
This source code is licensed under the ISC-style license found in the LICENSE file in the root directory of this source tree.
*/
// node --experimental-modules src/fsPromisesUtimes.js
import {promises} from 'fs'
const {utimes, writeFile, stat} = promises
import {inspect} from 'util'

const file = 'deleteMe.txt'
const timeval = Date.UTC(2019) // 2019-01-01T00:00:00.000Z
const comment =  process.argv.length >= 2 ? process.argv[2] : ''
const log = console.error

testUtimes({file, comment, timeval, log})
  .then(resolution => console.error('Completed successfully'))
  .catch(reason => console.error(`Error handler:\n${inspect(reason)}`) + process.exit(1))

async function testUtimes({file, comment, timeval, log}) {
  const {platform, version} = process
  log({platform, version, ...comment ? {comment} : null})
  await writeFile(file, '')
  await utimes(file, timeval, timeval)
  const {mtime} = await stat(file)
  log(`Actual: ${mtime.toISOString()} expected: ${new Date(timeval).toISOString()}`)
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    fsIssues and PRs related to the fs subsystem / file system.questionIssues that look for answers.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions