Commit ace37e24 authored by Michele Tartara's avatar Michele Tartara

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: default avatarMichele Tartara <mtartara@google.com>
Reviewed-by: default avatarIustin Pop <iustin@google.com>
parent 43a840a3
......@@ -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
......@@ -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
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment