Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Ganeti.Utils.Time
Description
Time utility functions.
Synopsis
- getCurrentTime :: IO Integer
- getCurrentTimeUSec :: IO Integer
- clockTimeToString :: ClockTime -> String
- clockTimeToCTime :: ClockTime -> EpochTime
- clockTimeToUSec :: ClockTime -> Integer
- cTimeToClockTime :: EpochTime -> ClockTime
- diffClockTimes :: ClockTime -> ClockTime -> TimeDiff
- addToClockTime :: TimeDiff -> ClockTime -> ClockTime
- noTimeDiff :: TimeDiff
- data TimeDiff = TimeDiff {}
Documentation
getCurrentTime :: IO Integer #
Returns the current time as an Integer
representing the number
of seconds from the Unix epoch.
getCurrentTimeUSec :: IO Integer #
Returns the current time as an Integer
representing the number
of microseconds from the Unix epoch (hence the need for Integer
).
clockTimeToString :: ClockTime -> String #
Convert a ClockTime into a (seconds-only) timestamp.
clockTimeToCTime :: ClockTime -> EpochTime #
Convert a ClockTime into a (seconds-only) EpochTime
(AKA time_t
).
clockTimeToUSec :: ClockTime -> Integer #
Convert a ClockTime the number of microseconds since the epoch.
cTimeToClockTime :: EpochTime -> ClockTime #
Convert a ClockTime into a (seconds-only) EpochTime
(AKA time_t
).
diffClockTimes :: ClockTime -> ClockTime -> TimeDiff #
addToClockTime :: TimeDiff -> ClockTime -> ClockTime #
noTimeDiff :: TimeDiff #
Like TimeDiff
but misses tdYear
, tdMonth
.
Their meaning depends on the start date and causes bugs like this one:
https://github.com/haskell/old-time/issues/18
This type is much simpler and less error-prone.
Also, our tdSec
has type Integer
, which cannot overflow.
Like in original TimeDiff
picoseconds can be negative,
that is, TimeDiff's are not normalized by default.