From ace37e24b9c421daa0443268d981698df1ea905b Mon Sep 17 00:00:00 2001 From: Michele Tartara <mtartara@google.com> Date: Wed, 16 Jan 2013 13:03:01 +0000 Subject: [PATCH] Move getCurrentTime from Confd.Utils to Utils 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 | 7 ------- src/Ganeti/Utils.hs | 8 ++++++++ 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/Ganeti/Confd/Utils.hs b/src/Ganeti/Confd/Utils.hs index 770c6f647..41454ce23 100644 --- a/src/Ganeti/Confd/Utils.hs +++ b/src/Ganeti/Confd/Utils.hs @@ -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 diff --git a/src/Ganeti/Utils.hs b/src/Ganeti/Utils.hs index 419782645..95f4280a5 100644 --- a/src/Ganeti/Utils.hs +++ b/src/Ganeti/Utils.hs @@ -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 -- GitLab