2018-01-31T20:15:40.343Z
Provides a minimal DateTime
wrapper that encodes/decodes to/from the simplified extended ISO format (ISO 8601
); specifically YYYY-MM-DDTHH:mm:ss[.sss]Z
where hyphens and colons can be omitted.
If you're handling dates that aren't in this format you should check out the purescript-formatters package instead.
bower install purescript-datetime-iso
Here's a motivating example:
module Data.Event where
import Prelude
import Data.DateTime.ISO (ISO, unwrapISO)
import Data.Argonaut.Decode (class DecodeJson, decodeJson, (.?))
import Data.DateTime (DateTime)
import Data.Newtype (unwrap)
newtype Event = Event
{ timestamp :: DateTime
, description :: String
}
instance decodeJsonEvent :: DecodeJson Event where
decodeJson json = do
obj <- decodeJson json
timestamp <- obj .? "timestamp" <#> unwrapISO
description <- obj .? "description"
pure $ Event { timestamp, description }
Module documentation is published on Pursuit.