module Sound.Osc.Time.System where
import Data.Int
import Data.Word
import qualified Data.Time.Clock.System as Clock.System
import Sound.Osc.Time
getSystemTimeAsNtpReal :: IO NtpReal
getSystemTimeAsNtpReal :: IO NtpReal
getSystemTimeAsNtpReal = do
SystemTime
tm <- IO SystemTime
Clock.System.getSystemTime
forall (m :: * -> *) a. Monad m => a -> m a
return (forall a b. (Integral a, Num b) => a -> b
fromIntegral (SystemTime -> Int64
Clock.System.systemSeconds SystemTime
tm) forall a. Num a => a -> a -> a
+ (forall a b. (Integral a, Num b) => a -> b
fromIntegral (SystemTime -> Word32
Clock.System.systemNanoseconds SystemTime
tm) forall a. Num a => a -> a -> a
* NtpReal
1.0e-9))
getSystemTimeInMicroseconds :: IO (Int64, Word32)
getSystemTimeInMicroseconds :: IO (Int64, Word32)
getSystemTimeInMicroseconds = do
SystemTime
tm <- IO SystemTime
Clock.System.getSystemTime
let sec :: Int64
sec = SystemTime -> Int64
Clock.System.systemSeconds SystemTime
tm
usec :: Word32
usec = SystemTime -> Word32
Clock.System.systemNanoseconds SystemTime
tm forall a. Integral a => a -> a -> a
`div` Word32
1000
forall (m :: * -> *) a. Monad m => a -> m a
return (Int64
sec, Word32
usec)