Revision a6e054a8 src/Ganeti/Utils.hs
b/src/Ganeti/Utils.hs | ||
---|---|---|
46 | 46 |
, rStripSpace |
47 | 47 |
, newUUID |
48 | 48 |
, getCurrentTime |
49 |
, getCurrentTimeUSec |
|
49 | 50 |
, clockTimeToString |
50 | 51 |
, chompPrefix |
51 | 52 |
, wrap |
... | ... | |
293 | 294 |
contents <- readFile C.randomUuidFile |
294 | 295 |
return $! rStripSpace $ take 128 contents |
295 | 296 |
|
296 |
-- | Returns the current time as an Integer representing the number of
|
|
297 |
-- seconds from the Unix epoch. |
|
297 |
-- | Returns the current time as an 'Integer' representing the number
|
|
298 |
-- of seconds from the Unix epoch.
|
|
298 | 299 |
getCurrentTime :: IO Integer |
299 | 300 |
getCurrentTime = do |
300 | 301 |
TOD ctime _ <- getClockTime |
301 | 302 |
return ctime |
302 | 303 |
|
304 |
-- | Returns the current time as an 'Integer' representing the number |
|
305 |
-- of microseconds from the Unix epoch (hence the need for 'Integer'). |
|
306 |
getCurrentTimeUSec :: IO Integer |
|
307 |
getCurrentTimeUSec = do |
|
308 |
TOD ctime pico <- getClockTime |
|
309 |
-- pico: 10^-12, micro: 10^-6, so we have to shift seconds left and |
|
310 |
-- picoseconds right |
|
311 |
return $ ctime * 1000000 + pico `div` 1000000 |
|
312 |
|
|
303 | 313 |
-- | Convert a ClockTime into a (seconds-only) timestamp. |
304 | 314 |
clockTimeToString :: ClockTime -> String |
305 | 315 |
clockTimeToString (TOD t _) = show t |
Also available in: Unified diff