Skip to content

felixmulder/purescript-simple-datetime

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

purescript-simple-datetime

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

About

A simplified version of DateTime

Resources

License

Stars

Watchers

Forks

Packages

No packages published