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 get a pretty message for the relative time difference between two dates.
Maybe relativeTime is too lame. (Or maybe you speak a different language than English!)
With relativeTimeWithOptions, you can provide your own custom messages for each time range.
(That's what relativeTime uses under the hood!)
You can provide a set of your own custom options, and use relativeTimeWithOptions instead.
Options for configuring your own relative message formats!
For example, here is how someSecondsAgo is implemented by default:
defaultSomeSecondsAgo : Int -> String
defaultSomeSecondsAgo seconds =
if seconds < 30 then
"just now"
else
toString seconds ++ " seconds ago"And here is how inSomeHours might look:
defaultInSomeHours : Int -> String
defaultInSomeHours hours =
if hours < 2 then
"in an hour"
else
"in " ++ toString hours ++ " hours"
This function takes in two times and returns the relative difference!
Here are a few examples to help: