Created
October 30, 2015 13:43
-
-
Save jaseemabid/0bbf7ab2e0eac6c2ecaa to your computer and use it in GitHub Desktop.
Get current time as an integer
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Definitely not the best way to get current time as integer | |
currentPosixTime <- (getCurrentTime >>= return . utcTimeToPOSIXSeconds) | |
let currentTime = (round (read (init $ show(currentPosixTime)) :: Float) :: Integer) |
FWIW, if you think you ever need to call read
on the result of show
, you can be certain you're on the wrong track.
@joehillen Of course I knew I was wrong, but hoogle didn't give me a UTCTime -> Int
or POSIXTime -> Int
and this had to be done quick.
@joehillen Thanks for the links.
@joehillen seems like an exceptionally large package for the job. I might have to copy required functions verbatim.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
https://hackage.haskell.org/package/MissingH-1.3.0.1/docs/System-Time-Utils.html