Created
October 2, 2013 12:00
-
-
Save qoelet/6792617 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
-- Given a timestamp from a JSON API call | |
-- Need to convert to Epoch | |
import Control.Applicative ((<$>)) | |
import Control.Monad (liftM) | |
import Data.Time | |
import Data.Time.Clock.POSIX | |
import System.Locale | |
main = do | |
let givenTimeStamp = "2013-09-29 16:36:30" | |
tsFormat = "%F %T" | |
tsAsUTCTime = parseTime defaultTimeLocale tsFormat givenTimeStamp :: Maybe UTCTime | |
tsAsEpoch = (*1000) <$> (utcTimeToPOSIXSeconds `liftM` tsAsUTCTime) | |
print tsAsEpoch |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment