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.t
part
is one of:era
,:quarter
,:month
,:day_of_week
or:days_of_week
options
is a Keyword list of options
Options
:locale
is any valid locale name in the list returned byCldr.known_locale_names/1
or aCldr.LanguageTag
struct returned byCldr.Locale.new!/2
. The default isCldr.get_locale()
.backend
is any module that includesuse Cldr
and therefore is aCldr
backend module. The default isdefault_backend/0
.:format
is one of:wide
,:abbreviated
or: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"
"السبت"