Hi,
Pretty dumb question I know, but..how to I display fractions of a second from a datediff?
ie:
main = do starttime <- gettime
-- do something here that takes a few seconds
endtime <- gettime
let timediff = diffClockTimes endtime starttime
let timediffstring = show( tdSec timediff) ++ " " ++ show( realToFrac(tdPicosec timediff) / 1000000000 )
putStrLn( show(timediffstring) )
return ()
tdPicosec is negative??? ... but sometimes it is positive... so it's really unclear what the appropriate way to handle this is!
Example outputs:
"1 -62.0"
"0
921.0"
... it could be that the time in seconds in the second example is "0.921", but for the first, is it "1.062" (adding the absolute milliseconds) or is it "0.938" (adding the negative milliseconds)?
Tried to figure this out by generating timeDiffs myself then normalizing them, but this doesnt seem to do anything useful ;-) :
Prelude> normalizeTimeDiff $ TimeDiff 0 0 0 0 0 0 1000000000000000000000000000000
0000
TimeDiff {tdYear = 0, tdMonth = 0, tdDay = 0, tdHour = 0, tdMin = 0, tdSec = 0,
tdPicosec = 10000000000000000000000000000000000}