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.
If our users don't speak English, printing out "Monday" or "Tuesday" might not be a great fit.
Thanks to a great recommendation, date-format now supports multilingual output!
All you need to do is provide your own options, and format will use your preferences instead:
For a complete example, check out the FormatWithOptions.elm in the examples folder.
These are the available options for formatting our dates.
Here's an example for creating Spanish FormatOptions:
spanishFullMonthName : Time.Month -> String
spanishFullMonthName month =
case month of
Jan ->
"Enero"
Feb ->
"Febrero"
Mar ->
"Marzo"
Apr ->
"Abril"
May ->
"Mayo"
Jun ->
"Junio"
Jul ->
"Julio"
Aug ->
"Agosto"
Sep ->
"Septiembre"
Oct ->
"Octubre"
Nov ->
"Noviembre"
Dec ->
"Diciembre"
spanishDayOfWeekName : Time.Weekday -> String
spanishDayOfWeekName weekday =
case weekday of
Mon ->
"Lunes"
Tue ->
"Martes"
Wed ->
"Miércoles"
Thu ->
"Jueves"
Fri ->
"Viernes"
Sat ->
"Sábado"
Sun ->
"Domingo"
spanishOptions : DateFormat.FormatOptions
spanishOptions =
{ fullMonthName = spanishFullMonthName
, dayOfWeekName = spanishDayOfWeekName
}These are the available tokens to help you format dates.
Get the numeric value of the month.
Examples: 1, 2, 3, ... 11, 12
Get the numeric value of the month, with a suffix at the end.
Examples: 1st, 2nd, 3rd, ... 11th, 12th
Get the numeric value of the month, fixed to two places.
Examples: 01, 02, 03, ... 11, 12
Get the name of the month, but just the first three letters.
Examples: Jan, Feb, Mar, ... Nov, Dec
Get the full name of the month.
Examples: January, February, ... December
Get the numeric value of the day of the month.
Examples: 1, 2, 3, ... 30, 31
Get the numeric value of the day of the month, with a suffix at the end.
Examples: 1st, 2nd, 3rd, ... 30th, 31st
Get the numeric value of the day of the month, fixed to two places.
Examples: 01, 02, 03, ... 30, 31
Get the numeric value of the day of the year.
Examples: 1, 2, 3, ... 364, 365
Get the numeric value of the day of the year, with a suffix at the end.
Examples: 1st, 2nd, 3rd, ... 364th, 365th
Get the numeric value of the day of the year, fixed to three places.
Examples: 001, 002, 003, ... 364, 365
Get the numeric value of the day of the week.
Examples: 0, 1, 2, ... 5, 6
Get the numeric value of the day of the week, with a suffix at the end.
Examples: 0th, 1st, 2nd, ... 5th, 6th
Gets the name of the day of the week, but just the first two letters.
Examples: Su, Mo, Tu, ... Fr, Sa
Gets the name of the day of the week, but just the first three letters.
Examples: Sun, Mon, Tue, ... Fri, Sat
Gets the full name of the day of the week.
Examples: Sunday, Monday, ... Friday, Saturday
Get the year, but just the last two letters.
Examples: 70, 71, ... 29, 30
Get the year.
Examples: 1970, 1971, ... 2018, ... 9999, ...
Get the numeric value for the quarter of the year.
Examples: 1, 2, 3, 4
Get the numeric value for the quarter of the year, with a suffix.
Examples: 1st, 2nd, 3rd, 4th
Get the numeric value for the week of the year.
Examples: 1, 2, 3, ... 51, 52
Get the numeric value for the week of the year, with a suffix at the end.
Examples: 1st, 2nd, 3rd, ... 51st, 52nd
Get the numeric value for the week of the year, fixed to two places.
Examples: 01, 02, 03, ... 51, 52
Get the AM / PM value of the hour, in uppercase.
Examples: AM, PM
Get the AM / PM value of the hour, in uppercase.
Examples: am, pm
Get the hour of the 24-hour day.
Examples: 0, 1, 2, ... 22, 23
Get the hour of the 24-hour day, fixed to two places.
Examples: 00, 01, 02, ... 22, 23
Get the hour of the 12-hour day.
Examples: 0, 1, 2, ... 11, 12
Get the hour of the 12-hour day, fixed to two places.
Examples: 00, 01, 02, ... 11, 12
Get the hour of the 24-hour day, starting from one.
Examples: 1, 2, ... 23, 24
Get the hour of the 24-hour day, starting from one, fixed to two places.
Examples: 01, 02, ... 23, 24
Get the minute of the hour.
Examples: 0, 1, 2, ... 58, 59
Get the minute of the hour, fixed to two places.
Examples: 00, 01, 02, ... 58, 59
Get the second of the minute.
Examples: 0, 1, 2, ... 58, 59
Get the second of the minute, fixed to two places.
Examples: 00, 01, 02, ... 58, 59
This function takes in a list of tokens,
Zone, andPosixto create your formatted string!Let's say
ourPosixValueis November 15, 1993 at 15:06.