mirror of
https://github.com/simplex-chat/simplex-chat.git
synced 2024-12-17 17:20:21 +01:00
core: use Int64 in time calculations (#2143)
* core: use Int64 in time calculations * remove import * make interval Int64
This commit is contained in:
committed by
GitHub
parent
12fb2a4ec5
commit
2148d50393
@@ -113,7 +113,7 @@ data ChatConfig = ChatConfig
|
||||
hostEvents :: Bool,
|
||||
logLevel :: ChatLogLevel,
|
||||
testView :: Bool,
|
||||
ciExpirationInterval :: Int -- microseconds
|
||||
ciExpirationInterval :: Int64 -- microseconds
|
||||
}
|
||||
|
||||
data DefaultAgentServers = DefaultAgentServers
|
||||
|
||||
@@ -1,27 +1,6 @@
|
||||
{-# LANGUAGE NumericUnderscores #-}
|
||||
module Simplex.Chat.Util (week) where
|
||||
|
||||
module Simplex.Chat.Util
|
||||
( diffInMicros,
|
||||
diffInSeconds,
|
||||
week,
|
||||
)
|
||||
where
|
||||
|
||||
import Data.Fixed (Fixed (MkFixed), Pico)
|
||||
import Data.Time (NominalDiffTime, nominalDiffTimeToSeconds)
|
||||
import Data.Time.Clock (UTCTime, diffUTCTime)
|
||||
|
||||
diffInSeconds :: UTCTime -> UTCTime -> Int
|
||||
diffInSeconds a b = (`div` 1000000_000000) $ diffInPicos a b
|
||||
|
||||
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
|
||||
import Data.Time (NominalDiffTime)
|
||||
|
||||
week :: NominalDiffTime
|
||||
week = 7 * 86400
|
||||
|
||||
Reference in New Issue
Block a user