[commit: packages/time] ghc,master: get building on 32-bit (5615013)

git at git.haskell.org git at git.haskell.org
Fri Apr 21 16:57:37 UTC 2017


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

On branches: ghc,master
Link       : http://git.haskell.org/packages/time.git/commitdiff/5615013af73347f0260038e9618370efe21f8e5f

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

commit 5615013af73347f0260038e9618370efe21f8e5f
Author: Ashley Yakeley <ashley at yakeley.org>
Date:   Fri Mar 10 11:09:40 2017 -0800

    get building on 32-bit


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

5615013af73347f0260038e9618370efe21f8e5f
 lib/Data/Time/LocalTime/Internal/TimeZone.hs | 15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)

diff --git a/lib/Data/Time/LocalTime/Internal/TimeZone.hs b/lib/Data/Time/LocalTime/Internal/TimeZone.hs
index fe434b7..e09a248 100644
--- a/lib/Data/Time/LocalTime/Internal/TimeZone.hs
+++ b/lib/Data/Time/LocalTime/Internal/TimeZone.hs
@@ -96,13 +96,24 @@ getTimeZoneCTime ctime = with 0 (\pdst -> with nullPtr (\pcname -> do
             return (TimeZone (div (fromIntegral secs) 60) (dst == 1) name)
     ))
 
+toCTime :: Int64 -> IO CTime
+toCTime t = let
+    tt = fromIntegral t
+    t' = fromIntegral tt
+    -- there's no instance Bounded CTime, so this is the easiest way to check for overflow
+    in if t' == t then return $ CTime tt else fail "Data.Time.LocalTime.Internal.TimeZone.toCTime: Overflow" where
+
 -- | Get the local time-zone for a given time (varying as per summertime adjustments).
 getTimeZoneSystem :: SystemTime -> IO TimeZone
-getTimeZoneSystem = getTimeZoneCTime . CTime . systemSeconds
+getTimeZoneSystem t = do
+    ctime <- toCTime $ systemSeconds t
+    getTimeZoneCTime ctime
 
 -- | Get the local time-zone for a given time (varying as per summertime adjustments).
 getTimeZone :: UTCTime -> IO TimeZone
-getTimeZone = getTimeZoneCTime . fromInteger . floor . utcTimeToPOSIXSeconds
+getTimeZone t = do
+    ctime <- toCTime $ floor $ utcTimeToPOSIXSeconds t
+    getTimeZoneCTime ctime
 
 -- | Get the current time-zone.
 getCurrentTimeZone :: IO TimeZone



More information about the ghc-commits mailing list