haskell-github-trust/thyme

getPOSIXTime usually produces incorrect values

Closed this issue · 2 comments

The struct timeval needs to be zeroed out before use, otherwise tv_usec usually has garbage data in it. Gotta love C!

Are you running on a 32-bit architecture perchance? I was suspicious of the CLongs, but that's what "time" had, even though gettimeofday(2) says they should be time_t and suseconds_t. (Which ought to correspond to CTime and CSUSeconds from Foreign.C.Types.)

Could you try running https://gist.github.com/liyang/10334780 and let me know what it outputs?

CTime: 8
CUSeconds: 4
CSUSeconds: 4
timeval: 16
tv_sec: 8
tv_usec: 4
(1397092454,985159)

I'm on an early 2013 MBP, running OSX Mavericks which to the best of my knowledge is 64-bit. I don't know why tv_usec is an int instead of a long.