Skip to content

Commit

Permalink
UHC.Util.Time, under testing
Browse files Browse the repository at this point in the history
  • Loading branch information
atzedijkstra committed Nov 29, 2012
1 parent 37de660 commit ba18b9e
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 1 deletion.
39 changes: 39 additions & 0 deletions src/UHC/Util/Time.hs
@@ -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

17 changes: 16 additions & 1 deletion uhc-util.cabal
Expand Up @@ -13,7 +13,21 @@ Category: Development
Description: General purpose utilities for UHC and related tools Description: General purpose utilities for UHC and related tools
Synopsis: UHC utilities Synopsis: UHC utilities


Flag directory-uses-UTCTime
Description: Use the directory version which uses UTCTime
Default: True

library 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: Build-Depends:
base >= 4 && < 5, base >= 4 && < 5,
mtl >= 2 && < 3, mtl >= 2 && < 3,
Expand Down Expand Up @@ -42,7 +56,8 @@ library
UHC.Util.PrettyUtils, UHC.Util.PrettyUtils,
UHC.Util.Rel, UHC.Util.Rel,
UHC.Util.ScanUtils, UHC.Util.ScanUtils,
UHC.Util.Utils UHC.Util.Utils,
UHC.Util.Time
Ghc-Options: Ghc-Options:
HS-Source-Dirs: src HS-Source-Dirs: src
Build-Tools: Build-Tools:
Expand Down

0 comments on commit ba18b9e

Please sign in to comment.