module Bindings.Posix.Time where
import Foreign.Ptr (Ptr,FunPtr,plusPtr)
import Foreign.Ptr (wordPtrToPtr,castPtrToFunPtr)
import Foreign.Storable
import Foreign.C.Types
import Foreign.C.String (CString,CStringLen,CWString,CWStringLen)
import Foreign.Marshal.Alloc (alloca)
import Foreign.Marshal.Array (peekArray,pokeArray)
import Data.Int
import Data.Word
data C'tm = C'tm{
c'tm'tm_sec :: CInt
,
c'tm'tm_min :: CInt
,
c'tm'tm_hour :: CInt
,
c'tm'tm_mday :: CInt
,
c'tm'tm_mon :: CInt
,
c'tm'tm_year :: CInt
,
c'tm'tm_wday :: CInt
,
c'tm'tm_yday :: CInt
,
c'tm'tm_isdst :: CInt
} deriving (Eq,Show)
instance Storable C'tm where
sizeOf _ = 44
alignment = sizeOf
peek p = do
v0 <- peekByteOff p 0
v1 <- peekByteOff p 4
v2 <- peekByteOff p 8
v3 <- peekByteOff p 12
v4 <- peekByteOff p 16
v5 <- peekByteOff p 20
v6 <- peekByteOff p 24
v7 <- peekByteOff p 28
v8 <- peekByteOff p 32
return $ C'tm v0 v1 v2 v3 v4 v5 v6 v7 v8
poke p (C'tm v0 v1 v2 v3 v4 v5 v6 v7 v8) = do
pokeByteOff p 0 v0
pokeByteOff p 4 v1
pokeByteOff p 8 v2
pokeByteOff p 12 v3
pokeByteOff p 16 v4
pokeByteOff p 20 v5
pokeByteOff p 24 v6
pokeByteOff p 28 v7
pokeByteOff p 32 v8
return ()
c'CLOCKS_PER_SEC = 1000000
c'CLOCKS_PER_SEC :: (Num a) => a
foreign import ccall "clock" c'clock
:: IO CClock
foreign import ccall "&clock" p'clock
:: FunPtr (IO CClock)
foreign import ccall "difftime" c'difftime
:: CTime -> CTime -> IO CDouble
foreign import ccall "&difftime" p'difftime
:: FunPtr (CTime -> CTime -> IO CDouble)
foreign import ccall "gmtime" c'gmtime
:: Ptr CTime -> IO (Ptr C'tm)
foreign import ccall "&gmtime" p'gmtime
:: FunPtr (Ptr CTime -> IO (Ptr C'tm))
foreign import ccall "localtime" c'localtime
:: Ptr CTime -> IO (Ptr C'tm)
foreign import ccall "&localtime" p'localtime
:: FunPtr (Ptr CTime -> IO (Ptr C'tm))
foreign import ccall "mktime" c'mktime
:: Ptr C'tm -> IO CTime
foreign import ccall "&mktime" p'mktime
:: FunPtr (Ptr C'tm -> IO CTime)
foreign import ccall "strftime" c'strftime
:: CString -> CSize -> CString -> Ptr C'tm -> IO CSize
foreign import ccall "&strftime" p'strftime
:: FunPtr (CString -> CSize -> CString -> Ptr C'tm -> IO CSize)
foreign import ccall "time" c'time
:: Ptr CTime -> IO CTime
foreign import ccall "&time" p'time
:: FunPtr (Ptr CTime -> IO CTime)