Move getCurrentTime from Confd.Utils to Utils
authorMichele Tartara <mtartara@google.com>
Wed, 16 Jan 2013 13:03:01 +0000 (13:03 +0000)
committerMichele Tartara <mtartara@google.com>
Wed, 16 Jan 2013 13:56:46 +0000 (14:56 +0100)
The getCurrentTime function is of wide interest, so its moved to a more
appropriate position.

Signed-off-by: Michele Tartara <mtartara@google.com>
Reviewed-by: Iustin Pop <iustin@google.com>

src/Ganeti/Confd/Utils.hs
src/Ganeti/Utils.hs

index 770c6f6..41454ce 100644 (file)
@@ -37,7 +37,6 @@ module Ganeti.Confd.Utils
 
 import qualified Data.ByteString as B
 import qualified Text.JSON as J
-import System.Time
 
 import Ganeti.BasicTypes
 import Ganeti.Confd.Types
@@ -96,9 +95,3 @@ signMessage key salt msg =
                 , signedMsgHmac = hmac
                 }
     where hmac = computeMac key (Just salt) msg
-
--- | Returns the current time.
-getCurrentTime :: IO Integer
-getCurrentTime = do
-  TOD ctime _ <- getClockTime
-  return ctime
index 4197826..95f4280 100644 (file)
@@ -45,6 +45,7 @@ module Ganeti.Utils
   , exitUnless
   , rStripSpace
   , newUUID
+  , getCurrentTime
   , clockTimeToString
   , chompPrefix
   ) where
@@ -290,6 +291,13 @@ newUUID = do
   contents <- readFile C.randomUuidFile
   return $! rStripSpace $ take 128 contents
 
+-- | Returns the current time as an Integer representing the number of
+-- seconds from the Unix epoch.
+getCurrentTime :: IO Integer
+getCurrentTime = do
+  TOD ctime _ <- getClockTime
+  return ctime
+
 -- | Convert a ClockTime into a (seconds-only) timestamp.
 clockTimeToString :: ClockTime -> String
 clockTimeToString (TOD t _) = show t