[project @ 2002-02-05 17:32:24 by simonmar]
[haskell-directory.git] / System / Time.hsc
index 45cb695..326d4f7 100644 (file)
@@ -8,7 +8,7 @@
 -- Stability   :  provisional
 -- Portability :  portable
 --
--- $Id: Time.hsc,v 1.5 2001/08/17 12:50:34 simonmar Exp $
+-- $Id: Time.hsc,v 1.7 2002/02/05 17:32:27 simonmar Exp $
 --
 -- The standard Time library.
 --
@@ -205,9 +205,9 @@ noTimeDiff = TimeDiff 0 0 0 0 0 0 0
 getClockTime = do
   allocaBytes (#const sizeof(struct timeval)) $ \ p_timeval -> do
     throwErrnoIfMinus1_ "getClockTime" $ gettimeofday p_timeval nullPtr
-    sec  <- (#peek struct timeval,tv_sec)  p_timeval :: IO Int32
-    usec <- (#peek struct timeval,tv_usec) p_timeval :: IO Int32
-    return (TOD (fromIntegral sec) ((fromIntegral usec) * 1000))
+    sec  <- (#peek struct timeval,tv_sec)  p_timeval :: IO CTime
+    usec <- (#peek struct timeval,tv_usec) p_timeval :: IO CTime
+    return (TOD (fromIntegral sec) ((fromIntegral usec) * 1000000))
  
 #elif HAVE_FTIME
 getClockTime = do
@@ -215,7 +215,7 @@ getClockTime = do
   ftime p_timeb
   sec  <- (#peek struct timeb,time) p_timeb :: IO CTime
   msec <- (#peek struct timeb,millitm) p_timeb :: IO CUShort
-  return (TOD (fromIntegral sec) (fromIntegral msec * 1000{-ToDo: correct???-}))
+  return (TOD (fromIntegral sec) (fromIntegral msec * 1000000000))
 
 #else /* use POSIX time() */
 getClockTime = do
@@ -321,8 +321,6 @@ foreign label tzname :: Ptr (Ptr CChar)
 #  else
 foreign import "ghcTimezone" unsafe timezone :: Ptr CLong
 foreign import "ghcTzname" unsafe tzname :: Ptr (Ptr CChar)
-#   def inline long  *ghcTimezone(void) { return &_timezone; }
-#   def inline char **ghcTzname(void) { return _tzname; }
 #  endif
 zone x = do 
   dst <- (#peek struct tm,tm_isdst) x
@@ -470,7 +468,7 @@ toClockTime (CalendarTime year mon mday hour min sec psec
         -- 
         gmtoff <- gmtoff p_tm
        let res = fromIntegral t - tz + fromIntegral gmtoff
-       return (TOD (fromIntegral res) 0)
+       return (TOD (fromIntegral res) psec)
 
 -- -----------------------------------------------------------------------------
 -- Converting time values to strings.