getModificationTime and directory-1.2
ganesh at earth.li
Wed Sep 12 08:04:18 CEST 2012
directory 1.2 switches to being based on 'time' rather than 'old-time'.
Because time values are exposed in its external API, this is causing
some disruption. In particular something like this pattern seems
getModTime :: FilePath -> IO EpochTime
getModTime path = do
(TOD s _) <- getModificationTime path
return $! fromIntegral s
i.e. get the modification time of a file in seconds since the UNIX epoch.
The replacement is something like:
t <- getModificationTime path
return $! fromInteger $ floor
$ t `diffUTCTime` UTCTime (fromGregorian 1970 1 1) 0
But if you want to be backwards compatible then cabal flags and CPP are
needed, so it's all a bit verbose.
Amongst the dependencies of darcs, I've found myself making a similar
change to three packages now (unix-compat, tar, zip-archive), so I
wonder if it's worth putting this function somewhere central?
One problem is that it's too late to put it in directory, because
18.104.22.168 was shipped with ghc 7.6.1 and so packages need to work against
How do people feel about a small package, e.g. 'directory-time' or
'modtime'? Or is there some cleaner workaround that I've missed?
More information about the Libraries