Cldr.Calendar.localize

You're seeing just the function localize, go back to Cldr.Calendar module for more information.
Link to this function

localize(date, part, options \\ [])

View Source

Specs

localize(Date.t(), atom(), Keyword.t()) ::
  String.t() | {:error, {module(), String.t()}}

Returns a localized string for a part of a Date.t.

Arguments

  • date_ is any Date.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 by Cldr.known_locale_names/1 or a Cldr.LanguageTag struct returned by Cldr.Locale.new!/2. The default is Cldr.get_locale().

  • backend is any module that includes use Cldr and therefore is a Cldr backend module. The default is default_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"
"السبت"