Skip to content

Commit

Permalink
Switch to using the time package, rather than old-time
Browse files Browse the repository at this point in the history
  • Loading branch information
igfoo committed Jan 14, 2012
1 parent 601172f commit d0cab4b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 11 deletions.
18 changes: 8 additions & 10 deletions System/Directory.hs
Expand Up @@ -105,7 +105,10 @@ import Foreign.C

{-# CFILES cbits/directory.c #-}

import System.Time ( ClockTime(..) )
import Data.Time
#ifndef mingw32_HOST_OS
import Data.Time.Clock.POSIX
#endif

#ifdef __GLASGOW_HASKELL__

Expand Down Expand Up @@ -986,23 +989,18 @@ The operation may fail with:
-}

getModificationTime :: FilePath -> IO ClockTime
getModificationTime :: FilePath -> IO UTCTime
getModificationTime name = do
#ifdef mingw32_HOST_OS
-- ToDo: use Win32 API
withFileStatus "getModificationTime" name $ \ st -> do
modificationTime st
#else
stat <- Posix.getFileStatus name
let mod_time :: Posix.EpochTime
let mod_time :: Posix.EpochTime
mod_time = Posix.modificationTime stat
dbl_time :: Double
dbl_time = realToFrac mod_time
return (TOD (round dbl_time) 0)
return $ posixSecondsToUTCTime $ realToFrac mod_time
#endif
-- For info
-- round :: (RealFrac a, Integral b => a -> b
-- realToFrac :: (Real a, Fractional b) => a -> b

#endif /* __GLASGOW_HASKELL__ */

Expand All @@ -1023,7 +1021,7 @@ withFileOrSymlinkStatus loc name f = do
throwErrnoIfMinus1Retry_ loc (lstat s p)
f p

modificationTime :: Ptr CStat -> IO ClockTime
modificationTime :: Ptr CStat -> IO UTCTime
modificationTime stat = do
mtime <- st_mtime stat
let dbl_time :: Double
Expand Down
2 changes: 1 addition & 1 deletion directory.cabal
Expand Up @@ -33,7 +33,7 @@ Library {
if impl(ghc >= 7.1)
extensions: NondecreasingIndentation
build-depends: base >= 4.2 && < 4.5,
old-time >= 1.0 && < 1.1,
time < 1.5,
filepath >= 1.1 && < 1.3
if !impl(nhc98) {
if os(windows) {
Expand Down

0 comments on commit d0cab4b

Please sign in to comment.