module Network.Mux.Time
(
DiffTime
, diffTimeToMicroseconds
, microsecondsToDiffTime
, timestampMicrosecondsLow32Bits
) where
import Control.Monad.Class.MonadTime.SI (Time (..))
import Data.Time.Clock (DiffTime, diffTimeToPicoseconds,
picosecondsToDiffTime)
import Data.Word (Word32)
diffTimeToMicroseconds :: DiffTime -> Integer
diffTimeToMicroseconds :: DiffTime -> Integer
diffTimeToMicroseconds = (forall a. Integral a => a -> a -> a
`div` Integer
1000000) forall b c a. (b -> c) -> (a -> b) -> a -> c
. DiffTime -> Integer
diffTimeToPicoseconds
microsecondsToDiffTime :: Integer -> DiffTime
microsecondsToDiffTime :: Integer -> DiffTime
microsecondsToDiffTime = Integer -> DiffTime
picosecondsToDiffTime forall b c a. (b -> c) -> (a -> b) -> a -> c
. (forall a. Num a => a -> a -> a
* Integer
1000000)
timestampMicrosecondsLow32Bits :: Time -> Word32
timestampMicrosecondsLow32Bits :: Time -> Word32
timestampMicrosecondsLow32Bits (Time DiffTime
ts) =
forall a b. (Integral a, Num b) => a -> b
fromIntegral (DiffTime -> Integer
diffTimeToMicroseconds DiffTime
ts)