Cldr.DateTime.Formatter.period_flex

You're seeing just the function period_flex, go back to Cldr.DateTime.Formatter module for more information.
Link to this function

period_flex(period_flex, n \\ 1, options \\ [])

View Source

Specs

period_flex(Calendar.time(), integer(), Keyword.t()) ::
  String.t() | {:error, String.t()}

Returns the formatting of the time period as a string, for example at night (format symbol B).

Arguments

  • time is a Time struct or any map that contains at least the key :second

  • n in an integer between 1 and 5 that determines the format of the time period

  • locale is any valid locale name returned by Cldr.known_locale_names/0 or a Cldr.LanguageTag struct. The default is Cldr.get_locale/0

  • options is a Keyword list of options. The available option is period: :variant which will use a veriant of localised flexible time period names if one is available

Notes

The time period may be upper or lowercase depending on the locale and other options. Often there is only one width that is customarily used.

Format Symbol

The representation of the time period is made in accordance with the following table:

SymbolExampleCldr Format
B, BB, BBB"at night"Abbreviated
BBBB"at night"Wide
BBBBB"at night"Narrow

Examples

iex> Cldr.DateTime.Formatter.period_flex %{hour: 11, minute: 5, second: 23}
"in the morning"

iex> Cldr.DateTime.Formatter.period_flex %{hour: 16, minute: 5, second: 23}
"in the afternoon"

iex> Cldr.DateTime.Formatter.period_flex %{hour: 23, minute: 5, second: 23}
"at night"
Link to this function

period_flex(time, n, locale, backend, options \\ [])

View Source

Specs

period_flex(Calendar.time(), integer(), locale(), Cldr.backend(), Keyword.t()) ::
  String.t() | {:error, String.t()}