Not Updated For 0.19
Use ryannhg/date-format instead.
Format String for Elm
by Max Goldstein
Create format strings for dates in the Elm programming language.
format : String -> Date.Date -> String.
Date refers to Elm’s standard Date library.
String may contain any of the following directives, which will be expanded to parts of the date.
A directive consists of a percent (%) character, zero or more flags and a conversion specifier as follows.
-– don’t pad a numerical output
_– use spaces for padding
0– use zeros for padding
%Y– 4 digit year
%y– 2 digit year
%m– Zero-padded month of year, e.g.
%B– Full month name, e.g.
%b– Abbreviated month name, e.g.
%d– Zero-padded day of month, e.g
%e– Space-padded day of month, e.g
%a– Day of week, abbreviated to three letters, e.g.
%A– Day of week in full, e.g.
%H– Hour of the day, 24-hour clock, zero-padded
%k– Hour of the day, 24-hour clock, space-padded
%I– Hour of the day, 12-hour clock, zero-padded
%l– (lower ell) Hour of the day, 12-hour clock, space-padded
%p– AM or PM
%P– am or pm
%M– Minute of the hour, zero-padded
%S– Second of the minute, zero-padded
%L– Millisecond of the second, zero-padded
Date.Format also exports
localFormat : Date.Local.Local -> String -> Date.Date -> String.
This function allows to add a localization record as specified in
It can be used to display local terms for week days, months, and AM or PM.
Pull requests are welcome! Note that in addition to adding a new letter to the
massive case statement, you’ll also need to add it to the regex. Languages like
and Ruby have very comprehensive
format strings. (Luckily, they seem to agree on the encoding, which you should
follow.) I’ve tried to add the most common formats, but if you want one added,
send a PR (and add a passing test). To run the tests, run
elm test (which you
can install from the elm-test package).