Skip to content
Snippets Groups Projects
Commit f1e4046a authored by simonpj@microsoft.com's avatar simonpj@microsoft.com
Browse files

Commit to Double for the default in realToInteger

parent 32b8989c
No related branches found
No related tags found
No related merge requests found
......@@ -233,6 +233,11 @@ noTimeDiff = TimeDiff 0 0 0 0 0 0 0
-- -----------------------------------------------------------------------------
-- | returns the current time in its internal representation.
realToInteger :: Real a => a -> Integer
realToInteger ct = round (realToFrac ct :: Double)
-- CTime, CClock, CUShort etc are in Real but not Fractional,
-- so we must convert to Double before we can round it
getClockTime :: IO ClockTime
#ifdef __HUGS__
getClockTime = do
......@@ -241,7 +246,6 @@ getClockTime = do
#elif HAVE_GETTIMEOFDAY
getClockTime = do
let realToInteger = round . realToFrac :: Real a => a -> Integer
allocaBytes (#const sizeof(struct timeval)) $ \ p_timeval -> do
throwErrnoIfMinus1_ "getClockTime" $ gettimeofday p_timeval nullPtr
sec <- (#peek struct timeval,tv_sec) p_timeval :: IO CTime
......@@ -250,7 +254,6 @@ getClockTime = do
#elif HAVE_FTIME
getClockTime = do
let realToInteger = round . realToFrac :: Real a => a -> Integer
allocaBytes (#const sizeof(struct timeb)) $ \ p_timeb -> do
ftime p_timeb
sec <- (#peek struct timeb,time) p_timeb :: IO CTime
......@@ -260,7 +263,6 @@ getClockTime = do
#else /* use POSIX time() */
getClockTime = do
secs <- time nullPtr -- can't fail, according to POSIX
let realToInteger = round . realToFrac :: Real a => a -> Integer
return (TOD (realToInteger secs) 0)
#endif
......@@ -385,7 +387,6 @@ foreign import ccall "&timezone" timezone :: Ptr CTime
gmtoff x = do
dst <- (#peek struct tm,tm_isdst) x
tz <- if dst then peek altzone else peek timezone
let realToInteger = round . realToFrac :: Real a => a -> Integer
return (-fromIntegral (realToInteger tz))
# else /* ! HAVE_DECL_ALTZONE */
......@@ -567,8 +568,7 @@ toClockTime (CalendarTime year mon mday hour minute sec psec
-- result.
--
gmtoffset <- gmtoff p_tm
let realToInteger = round . realToFrac :: Real a => a -> Integer
res = realToInteger t - fromIntegral tz + fromIntegral gmtoffset
let res = realToInteger t - fromIntegral tz + fromIntegral gmtoffset
return (TOD res psec)
#endif /* ! __HUGS__ */
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment