for more information visit the package's GitHub page
Package contains the following modules:
This Elm package provides a simple Date
type for working with dates without times or zones.
elm install justinmimbs/date
today
Posix
times: fromPosix
Date
values both to and from:2018 Sep 26
)2018 39 Wed
)2018 269
)"2018-09-26"
)736963
)format
, formatWithLanguage
add
, floor
, ceiling
diff
range
compare
, isBetween
, min
, max
, clamp
These examples are only meant to give a feel for the library; see the docs for the full API.
import Date
import Time exposing (Month(..))
Date.fromCalendarDate 2018 Sep 26
|> Date.format "EEEE, MMMM ddd, yyyy"
== "Wednesday, September 26th, 2018"
import Date exposing (Interval(..), Unit(..))
import Time exposing (Month(..))
Date.fromCalendarDate 2018 Sep 26
|> Date.floor Saturday
|> Date.add Weeks 1
|> Date.toIsoString
== "2018-09-29"
import Date exposing (Date, Interval(..), Unit(..))
start : Date
start =
Date.fromOrdinalDate 2019 1
thirdThursday : Date -> Date
thirdThursday date =
date |> Date.add Weeks 2 |> Date.ceiling Thursday
Date.range Month 1 start (start |> Date.add Months 6)
|> List.map thirdThursday
|> List.map Date.toIsoString
== [ "2019-01-17"
, "2019-02-21"
, "2019-03-21"
, "2019-04-18"
, "2019-05-16"
, "2019-06-20"
]