https://github.com/jmackie/purescript-datetime-iso
📆 🕒 PureScript library for serializing datetimes in simplified extended ISO format.
https://github.com/jmackie/purescript-datetime-iso
date-formatting iso8601 purescript
Last synced: 4 months ago
JSON representation
📆 🕒 PureScript library for serializing datetimes in simplified extended ISO format.
- Host: GitHub
- URL: https://github.com/jmackie/purescript-datetime-iso
- Owner: jmackie
- License: mit
- Created: 2018-01-09T17:08:23.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2020-10-02T11:05:07.000Z (over 5 years ago)
- Last Synced: 2026-01-13T14:41:51.666Z (5 months ago)
- Topics: date-formatting, iso8601, purescript
- Language: PureScript
- Homepage: http://pursuit.purescript.org/packages/purescript-datetime-iso
- Size: 20.5 KB
- Stars: 10
- Watchers: 0
- Forks: 18
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# purescript-datetime-iso
[](https://pursuit.purescript.org/packages/purescript-datetime-iso)
[](https://travis-ci.org/jmackie/purescript-datetime-iso)
```
2018-01-31T20:15:40.343Z
```
## Description
Provides a minimal [`DateTime`](https://github.com/purescript/purescript-datetime/) wrapper that encodes/decodes to/from the *simplified* extended ISO format ([`ISO 8601`](https://en.wikipedia.org/wiki/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](https://github.com/slamdata/purescript-formatters) package instead.
## Installation
```
bower install purescript-datetime-iso
```
## Usage
Here's a motivating example:
```purescript
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](http://pursuit.purescript.org/packages/purescript-datetime-iso).