CLDRex v0.0.3 CLDRex.Date

Provide date localization for common date formats.

Summary

Functions

Shortcut for localize/3 when passed the length: :full option

Convert the given date into the corresponding CLDR format

Shortcut for localize/3 when passed the length: :long option

Shortcut for localize/3 when passed the length: :medium option

Shortcut for localize/3 when passed the length: :short option

Types

date ::
  Ecto.Date.type |
  Timex.Date.t |
  {number, number, number}
locale :: atom | String.t

Functions

full(date, locale, calendar \\ :gregorian)

Specs

full(date, locale, atom) :: String.t

Shortcut for localize/3 when passed the length: :full option.

Examples

iex> CLDRex.Date.full({2016, 07, 11}, :de)
"Montag, 11. Juli 2016"
localize(date, locale, options \\ %{})

Specs

localize(date, locale, Map.t) :: String.t

Convert the given date into the corresponding CLDR format.

Accepted options are:

  • calendar: the calendar to use. default: :gregorian
  • length: the date format to use. default: :full commonly available:

    • :full
    • :long
    • :medium
    • :short

Examples

iex> CLDRex.Date.localize({2016, 07, 11}, :en)
"Monday, July 11, 2016"
iex> CLDRex.Date.localize(Timex.Date.today, :fr)
"lundi 11 juillet 2016"
iex> CLDRex.Date.localize({2016, 07, 11}, :fr, length: :medium)
"11 juil. 2016"
long(date, locale, calendar \\ :gregorian)

Specs

long(date, locale, atom) :: String.t

Shortcut for localize/3 when passed the length: :long option.

Examples

iex> CLDRex.Date.long({2016, 07, 11}, :fr)
"11 juillet 2016"
medium(date, locale, calendar \\ :gregorian)

Specs

medium(date, locale, atom) :: String.t

Shortcut for localize/3 when passed the length: :medium option.

Examples

iex(7)> CLDRex.Date.medium({2016, 07, 11}, :es)
"11 jul. 2016"
short(date, locale, calendar \\ :gregorian)

Specs

short(date, locale, atom) :: String.t

Shortcut for localize/3 when passed the length: :short option.

Examples

iex> CLDRex.Date.short({2016, 07, 11}, :en)
"7/11/2016"