Created
November 26, 2012 13:14
-
-
Save aslatter/4148129 to your computer and use it in GitHub Desktop.
getModificationTime shim
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| {-# LANGUAGE CPP #-} | |
| import Data.Functor ((<$>)) | |
| import Data.Time | |
| import System.Directory | |
| #if !(MIN_VERSION_time(1,2,0)) | |
| import Data.Time.Clock.POSIX | |
| import System.Time (ClockTime(..)) | |
| #endif | |
| getModificationTimeUTC :: FilePath -> IO UTCTime | |
| #if MIN_VERSION_time(1,2,0) | |
| getModificationTimeUTC = getModificationTime | |
| #else | |
| getModificationTimeUTC fp = | |
| clockTimeToUTCTime <$> getModificationTime fp | |
| clockTimeToUTCTime :: ClockTime -> UTCTime | |
| clockTimeToUTCTime (TOD unixTime unixPico) = | |
| let diff = fromInteger unixTime + fromRational ((fromInteger unixPico)/1000000000000) | |
| in posixSecondsToUTCTime diff | |
| #endif |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment