Commit ae66f3a9 authored by Klaus Aehlig's avatar Klaus Aehlig
Browse files

Add constructor function for Timestamp



Provide means to get Ganeti's internal timestamps
from standard clock time.
Signed-off-by: default avatarKlaus Aehlig <aehlig@google.com>
Reviewed-by: default avatarPetr Pudlak <pudlak@google.com>
parent 370f63be
......@@ -33,6 +33,7 @@ module Ganeti.JQueue
, queuedJobFromOpCodes
, cancelQueuedJob
, Timestamp
, fromClockTime
, noTimestamp
, currentTimestamp
, setReceivedTimestamp
......@@ -107,11 +108,14 @@ type Timestamp = (Int, Int)
noTimestamp :: Timestamp
noTimestamp = (-1, -1)
-- | Obtain a Timestamp from a given clock time
fromClockTime :: ClockTime -> Timestamp
fromClockTime (TOD ctime pico) =
(fromIntegral ctime, fromIntegral $ pico `div` 1000000)
-- | Get the current time in the job-queue timestamp format.
currentTimestamp :: IO Timestamp
currentTimestamp = do
TOD ctime pico <- getClockTime
return (fromIntegral ctime, fromIntegral $ pico `div` 1000000)
currentTimestamp = fromClockTime `liftM` getClockTime
-- | An input opcode.
data InputOpCode = ValidOpCode MetaOpCode -- ^ OpCode was parsed successfully
......
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