Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Osc related timing functions.
Osc timestamps are 64-bit Ntp
values, http://ntp.org/.
Synopsis
- type Ntp64 = Word64
- type NtpReal = Double
- type PosixReal = Double
- ntpr_to_ntpi :: NtpReal -> Ntp64
- ntpi_to_ntpr :: Ntp64 -> NtpReal
- ntp_posix_epoch_diff :: Num n => n
- posix_to_ntpi :: PosixReal -> Ntp64
- posix_to_ntpr :: Num n => n -> n
- ntpr_to_posix :: Num n => n -> n
- ntpi_to_posix :: Ntp64 -> PosixReal
- ntpr_to_posixtime :: NtpReal -> POSIXTime
- posixtime_to_ntpr :: POSIXTime -> NtpReal
- posix_epoch :: UTCTime
- utc_to_posix :: Fractional n => UTCTime -> n
- getCurrentTimeAsPosix :: IO PosixReal
- getPosixTimeAsPosix :: IO PosixReal
- currentTime :: IO NtpReal
Temporal types
Type for binary (integeral) representation of a 64-bit Ntp timestamp (ie. ntpi). The Ntp epoch is January 1, 1900. Ntp v4 also includes a 128-bit format, which is not used by Osc.
type PosixReal = Double Source #
Unix/Posix
time in real-valued (fractional) form.
The Unix/Posix epoch is January 1, 1970.
Time conversion
ntpr_to_ntpi :: NtpReal -> Ntp64 Source #
Convert an NtpReal timestamp to an Ntp64 timestamp.
ntpr_to_ntpi 0 == 0 fmap ntpr_to_ntpi time
ntpi_to_ntpr :: Ntp64 -> NtpReal Source #
Convert an Ntp64
timestamp to a real-valued Ntp timestamp.
ntpi_to_ntpr 0 == 0.0
ntp_posix_epoch_diff :: Num n => n Source #
Difference (in seconds) between Ntp and Posix epochs.
ntp_posix_epoch_diff / (24 * 60 * 60) == 25567 25567 `div` 365 == 70
posix_to_ntpi :: PosixReal -> Ntp64 Source #
Convert a PosixReal timestamp to an Ntp64 timestamp.
posix_to_ntpr :: Num n => n -> n Source #
Convert Unix/Posix
to Ntp
.
ntpr_to_posix :: Num n => n -> n Source #
Convert Ntp
to Unix/Posix
.
Time
inter-operation.
posix_epoch :: UTCTime Source #
The time at 1970-01-01:00:00:00 which is the Unix/Posix epoch.
utc_to_posix :: Fractional n => UTCTime -> n Source #
Convert UTCTime
to Unix/Posix
.
Clock operations
getCurrentTimeAsPosix :: IO PosixReal Source #
utc_to_posix of Clock.getCurrentTime.
getPosixTimeAsPosix :: IO PosixReal Source #
realToFrac of Clock.Posix.getPOSIXTime
get_ct = getCurrentTimeAsPosix get_pt = getPosixTimeAsPosix (ct,pt) <- get_ct >>= \t0 -> get_pt >>= \t1 -> return (t0,t1) print (pt - ct,pt - ct < 1e-5)
currentTime :: IO NtpReal Source #
Read current real-valued Ntp
timestamp.