A simplified version of DateTime
$ bower install purescript-simple-datetime --save
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 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"
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