I'm needing some Int
s to use as seed to random number generation and so I wanted to use the old trick of using the system time as seed.
So I tried to use the Data.Time package and I managed to do the following:
import Data.Time.Clock
time = getCurrentTime >>= return . utctDayTime
When I run time I get things like:
Prelude Data.Time.Clock> time
55712.00536s
The type of time
is IO DiffTime
. I expected to see an IO Something
type as this depends on things external to the program. So I have two questions:
a) Is it possible to somehow unwrap the IO and get the underlying DiffTime value?
b) How do I convert a DiffTime to an integer with it's value in seconds? There's a function secondsToDiffTime
but I couldn't find its inverse.