Package

purescript-simple-datetime

Repository
felixmulder/purescript-simple-datetime
License
MIT
Uploaded by
felixmulder
Published on
2018-07-27T20:37:22Z

Build status

A simplified version of DateTime

Installation

$ bower install purescript-simple-datetime --save

Parsing a date

If your date is on the format "YYYY-MM-DDTHH:mm:ss.SSSZ" then you can simply do:

import Data.SimpleDateTime
import Data.SimpleDateTime as SDT
import Effect.Exception (Error)

parsedDate :: Either Error SimpleDateTime
parsedDate = SDT.parse "2018-07-27T16:20:38.469Z"

Parsing from a custom format

Parsing from your own format, let's say: "YYYY-MM-DD" is as simple as:

format :: SDT.DateFormat
format = SDT.DateFormat "YYYY-MM-DD"

parsedDate :: Either Error SimpleDateTime
parsedDate = SDT.parseFormat format "2018-01-14"

Using SimpleDateTime

Standard functions for getting the time, date, day of the week etc all exist on this simple type:

hours :: SimpleDateTime -> Int
hours = SDT.getHours

minutes :: SimpleDateTime -> Int
minutes = SDT.getMinutes