CLDRex v0.0.7 CLDRex.Time

Provide time localization for common time formats.

Summary

Functions

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

Convert the given time 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

locale :: atom | String.t
time :: Time.t | {number, number, number}

Functions

full(time, locale, calendar \\ nil)

Specs

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

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

Examples

iex> CLDRex.Time.long({17, 2, 3}, :en)
"5:02:03 PM zzzz"
localize(time, locale, options \\ [])

Specs

localize(time, locale, Keyword.t) :: String.t

Convert the given time into the corresponding CLDR format.

Accepted options are:

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

    • full
    • long
    • medium
    • short

Examples

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

iex> CLDRex.Time.localize(time, :en)
"9:38:43 PM"
iex> CLDRex.Time.localize({1, 2, 3}, :en)
"1:02:03 AM"
iex> CLDRex.Time.localize({1, 2, 3}, :es)
"1:02:03"
iex> CLDRex.Time.localize({17, 2, 3}, :en)
"5:02:03 PM"
long(time, locale, calendar \\ nil)

Specs

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

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

Examples

iex> CLDRex.Time.long({17, 2, 3}, :en)
"5:02:03 PM z"
medium(time, locale, calendar \\ nil)

Specs

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

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

Examples

iex> CLDRex.Time.medium({17, 2, 3}, :en)
"5:02:03 PM"
short(time, locale, calendar \\ nil)

Specs

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

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

Examples

iex> CLDRex.Time.short({17, 2, 3}, :en)
"5:02 PM"