mirror of
https://github.com/simplex-chat/simplex-chat.git
synced 2026-04-05 15:26:14 +00:00
* docs: disappearing messages rfc * change schema * word * wip * wip * todos * todos * remove cancel, refactor * revert prefs * CITimed * schema * time on send direct * time on send group * add ttl to msg container, refactor * timed on receive * time on read * getTimedItems, fix tests * mark read in terminal - view, input, output, fix tests * refactor * comment * util * insert atomically * refactor * use guards * refactor startTimedItemThread Co-authored-by: Evgeny Poberezkin <2769109+epoberezkin@users.noreply.github.com>
18 lines
464 B
Haskell
18 lines
464 B
Haskell
module Simplex.Chat.Util
|
|
( diffInMicros,
|
|
)
|
|
where
|
|
|
|
import Data.Fixed (Fixed (MkFixed), Pico)
|
|
import Data.Time (nominalDiffTimeToSeconds)
|
|
import Data.Time.Clock (UTCTime, diffUTCTime)
|
|
|
|
diffInMicros :: UTCTime -> UTCTime -> Int
|
|
diffInMicros a b = (`div` 1000000) $ diffInPicos a b
|
|
|
|
diffInPicos :: UTCTime -> UTCTime -> Int
|
|
diffInPicos a b = fromInteger . fromPico . nominalDiffTimeToSeconds $ diffUTCTime a b
|
|
|
|
fromPico :: Pico -> Integer
|
|
fromPico (MkFixed i) = i
|