Cldr.DateTime.Formatter.period_flex
period_flex
, go back to Cldr.DateTime.Formatter module for more information.
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 aTime
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 periodlocale
is any valid locale name returned byCldr.known_locale_names/0
or aCldr.LanguageTag
struct. The default isCldr.get_locale/0
options
is aKeyword
list of options. The available option isperiod: :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:
Symbol | Example | Cldr 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"
Specs
period_flex(Calendar.time(), integer(), locale(), Cldr.backend(), Keyword.t()) :: String.t() | {:error, String.t()}