enkidatron / elm-cldr / Cldr.Format.Options

Formatting Options

Options for DateTime Formatting


type alias DateTimeOptions =
{ era : Maybe TextOption
, year : Maybe NumberOption
, month : Maybe NumberOrTextOption
, day : Maybe NumberOption
, weekday : Maybe TextOption
, period : Maybe TextOption
, dayPeriod : Maybe TextOption
, hour : Maybe NumberOption
, minute : Maybe NumberOption
, second : Maybe NumberOption
, fractionalSecondDigits : Maybe FractionalDigits
, zone : Maybe NameOption
, hour12 : Maybe HourType 
}

The options that are relevant to formatting a DateTime value.

These match the options that can be used in the Intl.DateTimeFormat JS API.

defaultDateTimeOptions : DateTimeOptions

A default record that can be used. Defaults each option to Nothing.

import Cldr.Format.Options exposing (defaultDateTimeOptions)

options =
    { defaultDateTimeOptions | hour = Just Numeric }

Options for Date Formatting


type alias DateOptions =
{ era : Maybe TextOption
, year : Maybe NumberOption
, month : Maybe NumberOrTextOption
, day : Maybe NumberOption
, weekday : Maybe TextOption 
}

The options that are relevant to formatting a Date value.

These match a subset of the options that can be used in the Intl.DateTimeFormat JS API.

defaultDateOptions : DateOptions

A default record that can be used. Defaults each option to Nothing.

import Cldr.Format.Options exposing (defaultDateOptions)

options =
    { defaultDateOptionis | year = Just Numeric }

Common Option Types


type TextOption
    = Short
    | Long
    | Narrow

A value for text-based options, such as weekday name and am/pm period.


type NumberOption
    = Numeric
    | TwoDigit

A value for number-based options, such as year or hour.


type NumberOrTextOption
    = Text TextOption
    | Number NumberOption

A value for options that can use text or numbers, such as month.


type HourType
    = Hour12
    | Hour24

A value to choose between 12 and 24 hour based formatting.


type FractionalDigits
    = One
    | Two
    | Three

A value to choose the number of fractional digits to display.


type NameOption
    = ShortName
    | LongName

Time Zone names can only be "short" or "long".