module Data.Time.Clock.Internal.UTCDiff where

import Data.Time.Clock.Internal.NominalDiffTime
import Data.Time.Clock.Internal.UTCTime
import Data.Time.Clock.POSIX

-- | addUTCTime a b = a + b
addUTCTime :: NominalDiffTime -> UTCTime -> UTCTime
addUTCTime :: POSIXTime -> UTCTime -> UTCTime
addUTCTime POSIXTime
x UTCTime
t = POSIXTime -> UTCTime
posixSecondsToUTCTime (POSIXTime
x POSIXTime -> POSIXTime -> POSIXTime
forall a. Num a => a -> a -> a
+ (UTCTime -> POSIXTime
utcTimeToPOSIXSeconds UTCTime
t))

-- | diffUTCTime a b = a - b
diffUTCTime :: UTCTime -> UTCTime -> NominalDiffTime
diffUTCTime :: UTCTime -> UTCTime -> POSIXTime
diffUTCTime UTCTime
a UTCTime
b = (UTCTime -> POSIXTime
utcTimeToPOSIXSeconds UTCTime
a) POSIXTime -> POSIXTime -> POSIXTime
forall a. Num a => a -> a -> a
- (UTCTime -> POSIXTime
utcTimeToPOSIXSeconds UTCTime
b)