Opened 5 years ago

Closed 4 years ago

#6160 closed feature request (fixed)

support sub-second resolutions for file timestamps

Reported by: redneb Owned by:
Priority: normal Milestone: 7.6.1
Component: libraries/unix Version: 7.4.2
Keywords: Cc:
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: None/Unknown Test Case:
Blocked By: Blocking:
Related Tickets: Differential Rev(s):
Wiki Page:


Currently all file timestamps related functions (accessTime, modificationTime, statusChangeTime, setFileTimes) offer resolution of one second. Most modern posix systems support better resolutions for file timestamps.

Attachments (2)

Change History (12)

comment:1 Changed 5 years ago by redneb

The above patch introduces 3 new functions:

accessTimeHiRes       :: FileStatus -> POSIXTime
modificationTimeHiRes :: FileStatus -> POSIXTime
statusChangeTimeHiRes :: FileStatus -> POSIXTime

When I have time I will send a patch for setFileTimes.

comment:2 Changed 5 years ago by igloo

difficulty: Unknown
Status: newpatch

comment:3 Changed 5 years ago by simonmar

I see no reason not to have this, except that it introduces a dependency from unix on time (one might expect the dependency to go the other way, because time needs access to POSIX interfaces to get the current time for example, but time does its own FFI).

Any objections, or shall we just apply it?

comment:4 Changed 5 years ago by simonpj

Owner: set to pcapriotti

comment:5 Changed 5 years ago by pcapriotti

Milestone: 7.6.1
Resolution: fixed
Status: patchclosed

Applied, thanks.

commit 9acb33c819356a49068ec041c38e438d335e9781
Author: Marios Titas <>
Date:   Wed Jun 13 02:52:03 2012 -0400

    Extract high resolution timestamps from FileStatus
    Signed-off-by: Paolo Capriotti <>

comment:6 Changed 5 years ago by redneb

Owner: pcapriotti deleted
Resolution: fixed
Status: closednew

I am reopening this to post the second part of what I promised earlier, ie operations for changing file timestamps. The above patch introduces 5 new functions:

setFileTimesHiRes :: FilePath -> POSIXTime -> POSIXTime -> IO ()
setFdTimesHiRes :: Fd -> POSIXTime -> POSIXTime -> IO ()
setSymbolicLinkTimesHiRes :: FilePath -> POSIXTime -> POSIXTime -> IO ()
touchFd :: Fd -> IO ()
touchSymbolicLink :: FilePath -> IO ()

This should complete the file timestamp related operations.

comment:7 Changed 5 years ago by pcapriotti

Status: newpatch

comment:8 Changed 5 years ago by simonmar

I think it would be good to note in the documentation for these functions that they are not POSIX and therefore might not be available on all platforms, and that they might thrown an error if the platform does not support the underlying API.

comment:9 Changed 5 years ago by redneb

I updated the patch so that the documentation includes a note that some of these functions are not supported on all platforms.

By the way, there is a similar issue with the already existing setSymbolicLinkOwnerAndGroup function: currently it is exported by System.Posix.Files only on platforms that support this operation. I think it should be exported everywhere and raise an exception on platforms that do not support it.

comment:10 Changed 4 years ago by pcapriotti

Resolution: fixed
Status: patchclosed

Thank you for the patch. Applied as:

commit 62e07b8a423a78556e2f5d86d1affe7cca4c8896
Author: Marios Titas <>
Date:   Sun Aug 12 15:46:22 2012 -0400

    Add functions for setting file times with high resolution
Note: See TracTickets for help on using tickets.