[Haskell-cafe] Working with multiple time zones

Ryan Ingram ryani.spam at gmail.com
Sat Feb 16 20:25:25 EST 2008

I don't have anything to answer for the "interesting" part of your
question, but if you're just interested in getting something

On Feb 16, 2008 3:13 PM, Dave Hinton <beakerchu at googlemail.com> wrote:
> 2. If GHC's implementation is working as designed, how do I translate
> the C program above into Haskell?

You can use the FFI to call localtime() directly; see
There's information on the types to use here:

Something along the lines of:

{-# INCLUDE <time.h> #-}
import Foreign
import Foreign.C

data CStructTm = ... -- implement struct tm here
instance Storable CStructTm where ...

foreign import ccall unsafe "localtime" c_localtime :: Ptr CTime -> IO
(Ptr CStructTm)

localtime :: CTime -> IO CStructTm
localtime = do ... -- marshal time into a pointer, call c_localtime,
marshal structure back into a CStructTm and return it.

More information about the Haskell-Cafe mailing list