Cldr.DateTime.Formatter.period_noon_midnight

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

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

View Source

Specs

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

Returns the formatting of the time period as either noon, midnight or am/pm (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 variant of localised "noon" and "midnight" if one is available

Notes

If the langauge doesn't support "noon" or "midnight" then am/pm is used for all time periods.

May be upper or lowercase depending on the locale and other options. If the locale doesn't have the notion of a unique noon == 12:00, then the PM form may be substituted. Similarly for midnight == 00:00 and the AM form.

Format Symbol

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

SymbolExampleCldr Format
b, bb, bbb"mid."Abbreviated
bbbb"midnight"Wide
bbbbb"md"Narrow

Examples

iex> Cldr.DateTime.Formatter.period_noon_midnight %{hour: 12, minute: 0}
"noon"

iex> Cldr.DateTime.Formatter.period_noon_midnight %{hour: 0, minute: 0}
"midnight"

iex> Cldr.DateTime.Formatter.period_noon_midnight %{hour: 11, minute: 0}
"in the morning"

iex> Cldr.DateTime.Formatter.period_noon_midnight %{hour: 16, minute: 0}
"PM"
Link to this function

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

View Source

Specs

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