Permalink
Browse files

UHC.Util.Time, under testing

  • Loading branch information...
1 parent 37de660 commit ba18b9ee14a345028b60370b002e71830d4d3c6b @atzedijkstra atzedijkstra committed Nov 29, 2012
Showing with 55 additions and 1 deletion.
  1. +39 −0 src/UHC/Util/Time.hs
  2. +16 −1 uhc-util.cabal
View
@@ -0,0 +1,39 @@
+{-# LANGUAGE CPP #-}
+
+-- wrapping around different versions of directory, enforcing different time packages to be used.
+
+module UHC.Util.Time
+ (
+# ifdef DIRECTORY_USES_UTCTIME
+ module Data.Time,
+ module Data.Time.Clock,
+ ClockTime,
+ diffClockTimes,
+ noTimeDiff,
+ getClockTime
+# else
+ module System.Time
+# endif
+ )
+ where
+
+#ifdef DIRECTORY_USES_UTCTIME
+import Data.Time
+import Data.Time.Clock
+#else
+import System.Time
+#endif
+
+#ifdef DIRECTORY_USES_UTCTIME
+-- | a for now alias for old-time ClockTime
+type ClockTime = UTCTime
+
+diffClockTimes = diffUTCTime
+
+noTimeDiff :: NominalDiffTime
+noTimeDiff = toEnum 0
+
+getClockTime :: IO ClockTime
+getClockTime = getCurrentTime
+#endif
+
View
@@ -13,7 +13,21 @@ Category: Development
Description: General purpose utilities for UHC and related tools
Synopsis: UHC utilities
+Flag directory-uses-UTCTime
+ Description: Use the directory version which uses UTCTime
+ Default: True
+
library
+ if flag(directory-uses-UTCTime)
+ build-depends:
+ directory >= 1.2 && < 2,
+ time >= 1.4 && < 2
+ cpp-options:
+ -DDIRECTORY_USES_UTCTIME
+ else
+ build-depends:
+ directory >= 1.1 && < 1.2,
+ old-time >= 1.1 && < 1.2
Build-Depends:
base >= 4 && < 5,
mtl >= 2 && < 3,
@@ -42,7 +56,8 @@ library
UHC.Util.PrettyUtils,
UHC.Util.Rel,
UHC.Util.ScanUtils,
- UHC.Util.Utils
+ UHC.Util.Utils,
+ UHC.Util.Time
Ghc-Options:
HS-Source-Dirs: src
Build-Tools:

0 comments on commit ba18b9e

Please sign in to comment.