Cldr.Calendar.localize
localize, go back to Cldr.Calendar module for more information.
Specs
Returns a localized string for a part of
a Date.t.
Arguments
date_is anyDate.tpartis one of:era,:quarter,:month,:day_of_weekor:days_of_weekoptionsis a Keyword list of options
Options
:localeis any valid locale name in the list returned byCldr.known_locale_names/1or aCldr.LanguageTagstruct returned byCldr.Locale.new!/2. The default isCldr.get_locale().backendis any module that includesuse Cldrand therefore is aCldrbackend module. The default isdefault_backend/0.:formatis one of:wide,:abbreviatedor:narrow. The default is:abbreviated.
Returns
A string representing the localized date part, or
A list of strings representing the days of the week for the part
:days_of_week. The days are in week order for the given date's calendar{error, {exception_module, message}}if an error is detected
Examples
iex> Cldr.Calendar.localize ~D[2019-01-01], :era
"AD"
iex> Cldr.Calendar.localize ~D[2019-01-01], :day_of_week
"Tue"
iex> Cldr.Calendar.localize ~D[0001-01-01], :day_of_week
"Mon"
iex> Cldr.Calendar.localize ~D[2019-01-01], :days_of_week
[{1, "Mon"}, {2, "Tue"}, {3, "Wed"}, {4, "Thu"}, {5, "Fri"}, {6, "Sat"}, {7, "Sun"}]
iex> Cldr.Calendar.localize ~D[2019-06-01], :era
"AD"
iex> Cldr.Calendar.localize ~D[2019-06-01], :quarter
"Q2"
iex> Cldr.Calendar.localize ~D[2019-06-01], :month
"Jun"
iex> Cldr.Calendar.localize ~D[2019-06-01], :day_of_week
"Sat"
iex> Cldr.Calendar.localize ~D[2019-06-01], :day_of_week, format: :wide
"Saturday"
iex> Cldr.Calendar.localize ~D[2019-06-01], :day_of_week, format: :narrow
"S"
iex> Cldr.Calendar.localize ~D[2019-06-01], :day_of_week, locale: "ar"
"السبت"