Skip to content

Instantly share code, notes, and snippets.

@jaseemabid
Created October 30, 2015 13:43
Show Gist options
  • Select an option

  • Save jaseemabid/0bbf7ab2e0eac6c2ecaa to your computer and use it in GitHub Desktop.

Select an option

Save jaseemabid/0bbf7ab2e0eac6c2ecaa to your computer and use it in GitHub Desktop.
Get current time as an integer
-- Definitely not the best way to get current time as integer
currentPosixTime <- (getCurrentTime >>= return . utcTimeToPOSIXSeconds)
let currentTime = (round (read (init $ show(currentPosixTime)) :: Float) :: Integer)
@joehillen
Copy link
Copy Markdown

@joehillen
Copy link
Copy Markdown

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.

@jaseemabid
Copy link
Copy Markdown
Author

@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.

@jaseemabid
Copy link
Copy Markdown
Author

@joehillen Thanks for the links.

@jaseemabid
Copy link
Copy Markdown
Author

@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