fix build with old version of time package
authorJoey Hess <joeyh@joeyh.name>
Wed, 27 Dec 2023 19:33:46 +0000 (15:33 -0400)
committerJoey Hess <joeyh@joeyh.name>
Wed, 27 Dec 2023 19:33:46 +0000 (15:33 -0400)
Can't truncate timestamp resolution with that version.

Utility/TimeStamp.hs

index 878d6f7299940ec4bd219c1466f249bb0711dadb..3cc4d8d24596daa2cbc8e013ed93f7e0a694cf01 100644 (file)
@@ -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