This Elm packages provides locale-aware formatting of Dates and times. Formats for each locale are taken from the Unicode CLDR Project. It is intended to be accessible to developers who are familiar with the JS Intl API.
elm install enkidatron/elm-cldr
Locale from a locale identifier string to store in your Model: fromStringenDate from justinmimbs/date: Format.Date.formatPosix from elm/time: Format.DateTime.formatSee examples directory for full examples.
import Cldr.Format.Date
import Cldr.Format.Length exposing (Length(..))
import Cldr.Locale exposing (root)
import Date
import Time
localeStringFromFlags = "ru"
locale = Cldr.Locale.fromString Cldr.Locale.allLocales localeStringFromFlags
date = Date.fromCalendarDate 2022 Time.Jan 10
formatted = Cldr.Format.Date.format Short (Maybe.withDefault root locale) date
The Cldr.Locale file is automatically generated from the CLDR JSON. In order to keep this library repo clean, the code for that generation can be found at enkidatron/elm-cldr-generator