module Data.Time.Clock.Internal.AbsoluteTime
(
AbsoluteTime,taiEpoch,addAbsoluteTime,diffAbsoluteTime,
taiNominalDayStart,
) where
import Data.Typeable
import Data.Data
import Control.DeepSeq
import Data.Time.Calendar.Days
import Data.Time.Clock.Internal.DiffTime
newtype AbsoluteTime = MkAbsoluteTime DiffTime deriving (Eq,Ord,Data,Typeable)
instance NFData AbsoluteTime where
rnf (MkAbsoluteTime a) = rnf a
taiEpoch :: AbsoluteTime
taiEpoch = MkAbsoluteTime 0
taiNominalDayStart :: Day -> AbsoluteTime
taiNominalDayStart day = MkAbsoluteTime $ realToFrac $ (toModifiedJulianDay day) * 86400
addAbsoluteTime :: DiffTime -> AbsoluteTime -> AbsoluteTime
addAbsoluteTime t (MkAbsoluteTime a) = MkAbsoluteTime (a + t)
diffAbsoluteTime :: AbsoluteTime -> AbsoluteTime -> DiffTime
diffAbsoluteTime (MkAbsoluteTime a) (MkAbsoluteTime b) = a - b