Skip to content

πŸ“† πŸ•’ PureScript library for serializing datetimes in simplified extended ISO format.

License

Notifications You must be signed in to change notification settings

dnulnets/purescript-datetime-iso

Β 
Β 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

33 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

purescript-datetime-iso

Pursuit version Build status

2018-01-31T20:15:40.343Z

Description

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.

Installation

bower install purescript-datetime-iso

Usage

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 }

Documentation

Module documentation is published on Pursuit.

About

πŸ“† πŸ•’ PureScript library for serializing datetimes in simplified extended ISO format.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • PureScript 100.0%