[commit: packages/time] format-widths, improve-leapseconds, master, posix-perf, tasty, wip/travis: get TAI to compile (cf576d3)

git at git.haskell.org git at git.haskell.org
Mon Feb 20 21:06:54 UTC 2017


Repository : ssh://git@git.haskell.org/time

On branches: format-widths,improve-leapseconds,master,posix-perf,tasty,wip/travis
Link       : http://git.haskell.org/packages/time.git/commitdiff/cf576d323e605122b337c64327ca047c999c7454

>---------------------------------------------------------------

commit cf576d323e605122b337c64327ca047c999c7454
Author: Ashley Yakeley <ashley at semantic.org>
Date:   Wed Feb 23 02:48:25 2005 -0800

    get TAI to compile
    
    darcs-hash:20050223104825-ac6dd-0a3e7a4109ecca08fb312f83deca2257b815310e


>---------------------------------------------------------------

cf576d323e605122b337c64327ca047c999c7454
 System/Time/TAI.hs | 17 ++++++++++-------
 1 file changed, 10 insertions(+), 7 deletions(-)

diff --git a/System/Time/TAI.hs b/System/Time/TAI.hs
index fb5df5a..501f817 100644
--- a/System/Time/TAI.hs
+++ b/System/Time/TAI.hs
@@ -13,21 +13,24 @@ module System.Time.TAI
 
 import System.Time.Clock
 
--- | TAI
-type AbsoluteTime = MkAbsoluteTime Integer
+-- | TAI as DiffTime from epoch
+newtype AbsoluteTime = MkAbsoluteTime DiffTime deriving (Eq,Ord)
 
 addAbsoluteTime :: DiffTime -> AbsoluteTime -> AbsoluteTime
+addAbsoluteTime t (MkAbsoluteTime a) = MkAbsoluteTime (t + a)
 
 diffAbsoluteTime :: AbsoluteTime -> AbsoluteTime -> DiffTime
+diffAbsoluteTime (MkAbsoluteTime a) (MkAbsoluteTime b) = a - b
 
 -- | TAI - UTC during this day
-type LeapSecondTable = ModJulianDay -> Int
+type LeapSecondTable = ModJulianDay -> Integer
 
 utcDayLength :: LeapSecondTable -> ModJulianDay -> DiffTime
 utcDayLength table day = siSecondsToTime (86400 + (table (day + 1)) - (table day))
 
-utcToTAITime :: LeapSecondTable -> UTCTime -> TAITime
-utcToTAITime table (UTCTime day dtime) = siSecondsToTime (table day) + 
-
-taiToUTCTime :: LeapSecondTable -> TAITime -> UTCTime
+utcToTAITime :: LeapSecondTable -> UTCTime -> AbsoluteTime
+utcToTAITime table (UTCTime day dtime) = MkAbsoluteTime
+	((siSecondsToTime (day * 86400 + (table day))) + dtime)
 
+taiToUTCTime :: LeapSecondTable -> AbsoluteTime -> UTCTime
+taiToUTCTime table (MkAbsoluteTime t) = undefined



More information about the ghc-commits mailing list