Renamed to ryan-haskell/date-format. It is published under that name, and new versions come out there.
Versions published as ryannhg/date-format still install under that name. 6 versions of 6 come from the new location (see their notes).
Rerouted (cache, verified). The original is gone. This copy comes from a Lamdera package cache made before it went. The Lamdera package server serves a copy recovered from a Lamdera package cache from 2021-02-13.
What we checked: Rebuilt from the unpacked sources in a Lamdera package cache (5 copies agree), which Elm only writes after the published SHA-1 checked out; elm.json is byte-identical to package.elm-lang.org's; the exposed modules match docs.json; the zip is our own, so its SHA-1 is not the published one.
The Lamdera compiler uses this copy and prints a one-line notice saying so. elm itself fails to download this version.
Details · package.elm-lang.org's zip: https://github.com/ryannhg/date-format/zipball/1.0.0/
A reliable way to format dates and times with Elm.
elm install ryannhg/date-formatdate-format?If you're coming from Javascript, you might have heard of MomentJS.
MomentJS is a great library for formatting dates!
date-format has similar formatting options as Moment, but it uses Elm's awesome type system to provide human readable names, and catch typos for you at compile time!
No need to remember the difference between mm and MM and M!
import DateFormat
import Time exposing (Posix, Zone, utc)
-- Let's create a custom formatter we can use later:
ourFormatter : Zone -> Posix -> String
ourFormatter =
DateFormat.format
[ DateFormat.monthNameFull
, DateFormat.text " "
, DateFormat.dayOfMonthSuffix
, DateFormat.text ", "
, DateFormat.yearNumber
]
-- With our formatter, we can format any date as a string!
ourTimezone : Zone
ourTimezone =
utc
-- 2018-05-20T19:18:24.911Z
ourPosixTime : Posix
ourPosixTime =
Time.millisToPosix 1526843861289
ourPrettyDate : String
ourPrettyDate =
ourFormatter ourTimezone ourPosixTimeWould make ourPrettyDate return:
"May 20th, 2018" : StringI've created a few more examples in the examples/ folder for this repo.
Here's how you can try them out:
git clone https://github.com/ryannhg/date-format
cd date-format/examples
elm reactor
Go to http://localhost:8000