old-time 1.0.0.2 → 1.0.0.3
raw patch · 4 files changed
+62/−20 lines, 4 filesdep ~base
Dependency ranges changed: base
Files
- System/Time.hsc +9/−9
- cbits/timeUtils.c +21/−0
- include/HsTime.h +12/−0
- old-time.cabal +20/−11
System/Time.hsc view
@@ -233,6 +233,11 @@ -- ----------------------------------------------------------------------------- -- | 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 @@ #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 @@ #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 @@ #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 @@ 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 @@ -- 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__ */ @@ -731,14 +731,14 @@ type CTm = () -- struct tm #if HAVE_LOCALTIME_R-foreign import ccall unsafe "time.h localtime_r"+foreign import ccall unsafe "HsTime.h __hscore_localtime_r" localtime_r :: Ptr CTime -> Ptr CTm -> IO (Ptr CTm) #else foreign import ccall unsafe "time.h localtime" localtime :: Ptr CTime -> IO (Ptr CTm) #endif #if HAVE_GMTIME_R-foreign import ccall unsafe "time.h gmtime_r"+foreign import ccall unsafe "HsTime.h __hscore_gmtime_r" gmtime_r :: Ptr CTime -> Ptr CTm -> IO (Ptr CTm) #else foreign import ccall unsafe "time.h gmtime"@@ -750,7 +750,7 @@ #if HAVE_GETTIMEOFDAY type CTimeVal = () type CTimeZone = ()-foreign import ccall unsafe "time.h gettimeofday"+foreign import ccall unsafe "HsTime.h __hscore_gettimeofday" gettimeofday :: Ptr CTimeVal -> Ptr CTimeZone -> IO CInt #elif HAVE_FTIME type CTimeB = ()
cbits/timeUtils.c view
@@ -6,6 +6,27 @@ */ #include "HsTime.h" +#if HAVE_GETTIMEOFDAY+int __hscore_gettimeofday(struct timeval *tp, void *tzp)+{+ return gettimeofday(tp, tzp);+}+#endif++#if HAVE_GMTIME_R+struct tm *__hscore_gmtime_r(const time_t *clock, struct tm *result)+{+ return gmtime_r(clock, result);+}+#endif++#if HAVE_LOCALTIME_R+struct tm *__hscore_localtime_r(const time_t *clock, struct tm *result)+{+ return localtime_r(clock, result);+}+#endif+ #if defined(_MSC_VER) || defined(__MINGW32__) || defined(_WIN32) /* to the end */ long *__hscore_timezone( void )
include/HsTime.h view
@@ -34,4 +34,16 @@ extern long *__hscore_timezone( void ); extern char **__hscore_tzname( void ); +#if HAVE_GETTIMEOFDAY+extern int __hscore_gettimeofday(struct timeval *tp, void *tzp);+#endif++#if HAVE_GMTIME_R+extern struct tm *__hscore_gmtime_r(const time_t *clock, struct tm *result);+#endif++#if HAVE_LOCALTIME_R+extern struct tm *__hscore_localtime_r(const time_t *clock, struct tm *result);+#endif+ #endif /* __TIMEUTILS_H__ */
old-time.cabal view
@@ -1,24 +1,15 @@ name: old-time-version: 1.0.0.2+version: 1.0.0.3 license: BSD3 license-file: LICENSE maintainer: libraries@haskell.org+bug-reports: http://hackage.haskell.org/trac/ghc/newticket?component=libraries/old-time synopsis: Time library category: System description: This package provides the old time library. For new code, the new time library is recommended. build-type: Configure-exposed-modules:- System.Time-c-sources:- cbits/timeUtils.c-include-dirs: include-includes: HsTime.h-install-includes: HsTime.h HsTimeConfig.h-extensions: CPP, ForeignFunctionInterface-build-depends: base, old-locale-nhc98-options: -K2M extra-source-files: config.guess config.sub install-sh configure.ac configure@@ -26,3 +17,21 @@ extra-tmp-files: config.log config.status autom4te.cache include/HsTimeConfig.h+Cabal-Version: >= 1.6++Library+ exposed-modules:+ System.Time+ c-sources:+ cbits/timeUtils.c+ include-dirs: include+ includes: HsTime.h+ install-includes: HsTime.h HsTimeConfig.h+ extensions: CPP, ForeignFunctionInterface+ build-depends: base >= 3 && < 5, old-locale+ nhc98-options: -K2M++source-repository head+ type: darcs+ location: http://darcs.haskell.org/packages/old-time/+