Last active
August 29, 2015 14:00
-
-
Save nurpax/11369860 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
name: aeson-test | |
version: 0.1 | |
license: AllRightsReserved | |
build-type: Simple | |
cabal-version: >=1.8 | |
executable install-test | |
hs-source-dirs: . | |
main-is: AesonTest.hs | |
build-depends: base >= 4.5 && < 5 | |
, aeson >= 0.7.0.3 | |
, time |
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
{-# LANGUAGE ScopedTypeVariables, OverloadedStrings #-} | |
import Data.Aeson | |
import Data.Time (UTCTime) | |
main = do | |
let Just (t :: [UTCTime]) = decode' "[\"2014-04-28T05:05:05.000Z\"]" | |
print t | |
let Just (t :: [UTCTime]) = decode' "[\"2014-04-28T05:05:05Z\"]" | |
print t | |
-- The below examples do not parse with aeson 0.7.0.3 | |
-- Format used by Python 2.7's datetime.__str__() | |
print $ (read "2014-04-28 15:20:28.391413" :: UTCTime) | |
print $ (read "2014-04-28 15:20:28" :: UTCTime) | |
let Just (t :: [UTCTime]) = decode' "[\"2014-04-28 15:20:28.391413\"]" | |
print t | |
let Just (t :: [UTCTime]) = decode' "[\"2014-04-28 15:20:28\"]" | |
print t |
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
from datetime import datetime | |
d = datetime.now() | |
print datetime.now() | |
print datetime.now().__str__() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment