Skip to content

Instantly share code, notes, and snippets.

@nurpax
Last active August 29, 2015 14:00
Show Gist options
  • Save nurpax/11369860 to your computer and use it in GitHub Desktop.
Save nurpax/11369860 to your computer and use it in GitHub Desktop.
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
{-# 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
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