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 :: NominalDiffTime -> UTCTime -> UTCTime
addUTCTime NominalDiffTime
x UTCTime
t = NominalDiffTime -> UTCTime
posixSecondsToUTCTime (NominalDiffTime
x NominalDiffTime -> NominalDiffTime -> NominalDiffTime
forall a. Num a => a -> a -> a
+ (UTCTime -> NominalDiffTime
utcTimeToPOSIXSeconds UTCTime
t))

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