CLDRex v0.0.7 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 :: Date.t | {number, number, number}
locale :: atom | String.t

Functions

full(date, locale, calendar \\ nil)

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, Keyword.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. commonly available:

    • full
    • long
    • medium
    • short

Examples

iex> {date, time} = :calendar.universal_time
{{2016, 7, 17}, {9, 38, 43}}

iex> CLDRex.Date.localize(date, :en)
"Sunday, July 17, 2016"
iex> CLDRex.Date.localize({2016, 07, 11}, :en)
"Monday, July 11, 2016"
iex> CLDRex.Date.localize({2016, 07, 11}, :fr, length: "medium")
"11 juil. 2016"
long(date, locale, calendar \\ nil)

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 \\ nil)

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 \\ nil)

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"