Cldr.Date.to_string-exclamation-mark

You're seeing just the function to_string-exclamation-mark, go back to Cldr.Date module for more information.
Link to this function

to_string!(date, backend \\ Cldr.Date.default_backend(), options \\ [])

View Source

Specs

to_string!(map(), Cldr.backend() | Keyword.t(), Keyword.t()) ::
  String.t() | no_return()

Formats a date according to a format string as defined in CLDR and described in TR35

Arguments

  • date is a %Date{} struct or any map that contains the keys year, month, day and calendar

  • backend is any module that includes use Cldr and therefore is a Cldr backend module. The default is Cldr.default_backend/0.

  • options is a keyword list of options for formatting.

Options

  • format: :short | :medium | :long | :full or a format string. The default is :medium

  • 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

  • number_system: a number system into which the formatted date digits should be transliterated

Returns

  • formatted_date or

  • raises an exception.

Examples

iex> Cldr.Date.to_string! ~D[2017-07-10], MyApp.Cldr, format: :medium, locale: "en"
"Jul 10, 2017"

iex> Cldr.Date.to_string! ~D[2017-07-10], MyApp.Cldr, locale: "en"
"Jul 10, 2017"

iex> Cldr.Date.to_string! ~D[2017-07-10], MyApp.Cldr, format: :full,locale: "en"
"Monday, July 10, 2017"

iex> Cldr.Date.to_string! ~D[2017-07-10], MyApp.Cldr, format: :short, locale: "en"
"7/10/17"

iex> Cldr.Date.to_string! ~D[2017-07-10], MyApp.Cldr, format: :short, locale: "fr"
"10/07/2017"

iex> Cldr.Date.to_string! ~D[2017-07-10], MyApp.Cldr, format: :long, locale: "af"
"10 Julie 2017"