fix build with old version of time package
Can't truncate timestamp resolution with that version.
This commit is contained in:
parent
bdcc2fc93e
commit
4b52657b37
1 changed files with 6 additions and 0 deletions
|
@ -5,6 +5,8 @@
|
||||||
- License: BSD-2-clause
|
- License: BSD-2-clause
|
||||||
-}
|
-}
|
||||||
|
|
||||||
|
{-# LANGUAGE CPP #-}
|
||||||
|
|
||||||
module Utility.TimeStamp (
|
module Utility.TimeStamp (
|
||||||
parserPOSIXTime,
|
parserPOSIXTime,
|
||||||
parsePOSIXTime,
|
parsePOSIXTime,
|
||||||
|
@ -60,7 +62,11 @@ formatPOSIXTime fmt t = formatTime defaultTimeLocale fmt (posixSecondsToUTCTime
|
||||||
|
|
||||||
{- Truncate the resolution to the specified number of decimal places. -}
|
{- Truncate the resolution to the specified number of decimal places. -}
|
||||||
truncateResolution :: Int -> POSIXTime -> POSIXTime
|
truncateResolution :: Int -> POSIXTime -> POSIXTime
|
||||||
|
#if MIN_VERSION_time(1,9,1)
|
||||||
truncateResolution n t = secondsToNominalDiffTime $
|
truncateResolution n t = secondsToNominalDiffTime $
|
||||||
fromIntegral ((truncate (nominalDiffTimeToSeconds t * d)) :: Integer) / d
|
fromIntegral ((truncate (nominalDiffTimeToSeconds t * d)) :: Integer) / d
|
||||||
where
|
where
|
||||||
d = 10 ^ n
|
d = 10 ^ n
|
||||||
|
#else
|
||||||
|
truncateResolution _ t = t
|
||||||
|
#endif
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue