Cldr v0.1.0 Cldr.Currency

Defines a currency structure and a set of functions to manage the validity of a currency code.

Summary

Functions

Returns the currency metadata for the requested currency code

Returns the currency metadata for a locale

Returns a list of all known currency codes

Returns a boolean indicating if the supplied currency code is known

Normalizes the representation of a currency code

Types

code()
code() :: String.t
format()
format ::
  :standard |
  :accounting |
  :short |
  :long |
  :percent |
  :scientific
t()
t() :: %Cldr.Currency{cash_digits: pos_integer, cash_rounding: pos_integer, code: code, count: %{}, digits: pos_integer, name: String.t, narrow_symbol: String.t, rounding: pos_integer, symbol: String.t, tender: boolean}

Functions

for_code(currency, locale \\ Cldr.get_locale())
for_code(code, Cldr.locale) :: %{}

Returns the currency metadata for the requested currency code.

The currency code is a string representation of an ISO 4217 currency code.

Examples

iex> Cldr.Currency.for_code("AUD")
%Cldr.Currency{cash_digits: 2, cash_rounding: 0, code: "AUD",
count: %{one: "Australian dollar", other: "Australian dollars"},
digits: 2, name: "Australian Dollar", narrow_symbol: "$",
rounding: 0, symbol: "A$", tender: true}

iex> Cldr.Currency.for_code("THB")
%Cldr.Currency{cash_digits: 2, cash_rounding: 0, code: "THB",
count: %{one: "Thai baht", other: "Thai baht"}, digits: 2,
name: "Thai Baht", narrow_symbol: "฿", rounding: 0, symbol: "THB",
tender: true}
for_locale(locale)
for_locale(Cldr.locale) :: %{}

Returns the currency metadata for a locale.

known_currencies()

Returns a list of all known currency codes.

Example

iex> Cldr.Currency.known_currencies |> Enum.count
298
known_currency?(currency)
known_currency?(code) :: boolean

Returns a boolean indicating if the supplied currency code is known.

Examples

iex> Cldr.Currency.known_currency? "AUD"
true

iex> Cldr.Currency.known_currency? "GGG"
false
normalize_currency_code(currency)
normalize_currency_code(binary) :: atom

Normalizes the representation of a currency code.

The normalized form is an ISO4217 code in an atom form.