core: use Int64 in time calculations (#2143)

* core: use Int64 in time calculations

* remove import

* make interval Int64
This commit is contained in:
Evgeny Poberezkin
2023-04-04 14:26:31 +01:00
committed by GitHub
parent 12fb2a4ec5
commit 2148d50393
6 changed files with 10 additions and 32 deletions
+1 -1
View File
@@ -113,7 +113,7 @@ data ChatConfig = ChatConfig
hostEvents :: Bool,
logLevel :: ChatLogLevel,
testView :: Bool,
ciExpirationInterval :: Int -- microseconds
ciExpirationInterval :: Int64 -- microseconds
}
data DefaultAgentServers = DefaultAgentServers
+2 -23
View File
@@ -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