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>
import qualified Data.ByteString as B
import qualified Text.JSON as J
-import System.Time
import Ganeti.BasicTypes
import Ganeti.Confd.Types
, signedMsgHmac = hmac
}
where hmac = computeMac key (Just salt) msg
-
--- | Returns the current time.
-getCurrentTime :: IO Integer
-getCurrentTime = do
- TOD ctime _ <- getClockTime
- return ctime
, exitUnless
, rStripSpace
, newUUID
+ , getCurrentTime
, clockTimeToString
, chompPrefix
) where
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