From 4b52657b371b483d3555ea26a91eddeade49038d Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Wed, 27 Dec 2023 15:33:46 -0400 Subject: [PATCH] fix build with old version of time package Can't truncate timestamp resolution with that version. --- Utility/TimeStamp.hs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Utility/TimeStamp.hs b/Utility/TimeStamp.hs index 878d6f7299..3cc4d8d245 100644 --- a/Utility/TimeStamp.hs +++ b/Utility/TimeStamp.hs @@ -5,6 +5,8 @@ - License: BSD-2-clause -} +{-# LANGUAGE CPP #-} + module Utility.TimeStamp ( parserPOSIXTime, parsePOSIXTime, @@ -60,7 +62,11 @@ formatPOSIXTime fmt t = formatTime defaultTimeLocale fmt (posixSecondsToUTCTime {- Truncate the resolution to the specified number of decimal places. -} truncateResolution :: Int -> POSIXTime -> POSIXTime +#if MIN_VERSION_time(1,9,1) truncateResolution n t = secondsToNominalDiffTime $ fromIntegral ((truncate (nominalDiffTimeToSeconds t * d)) :: Integer) / d where d = 10 ^ n +#else +truncateResolution _ t = t +#endif -- 2.30.2