Class Index | File Index

Classes


Class Currency

Create a new currency information instance. Instances of this class encode information about a particular currency.

Note: that if you are looking to format currency for display, please see the number formatting class {NumFmt}. This class only gives information about currencies.

The options can contain any of the following properties:

When searching for a currency by its sign, this class cannot guarantee that it will return info about a specific currency. The reason is that currency signs are sometimes shared between different currencies and the sign is therefore ambiguous. If you need a guarantee, find the currency using the code instead.

The way this class finds a currency by sign is the following. If the sign is unambiguous, then the currency is returned. If there are multiple currencies that use the same sign, and the current locale uses that sign, then the default currency for the current locale is returned. If there are multiple, but the current locale does not use that sign, then the currency with the largest circulation is returned. For example, if you are in the en-GB locale, and the sign is "$", then this class will notice that there are multiple currencies with that sign (USD, CAD, AUD, HKD, MXP, etc.) Since "$" is not used in en-GB, it will pick the one with the largest circulation, which in this case is the US Dollar (USD).

If neither the code or sign property is set, the currency that is most common for the locale will be used instead. If the locale is not set, the default locale will be used. If the code is given, but it is not found in the list of known currencies, this constructor will throw an exception. If the sign is given, but it is not found, this constructor will default to the currency for the current locale. If both the code and sign properties are given, then the sign property will be ignored and only the code property used. If the locale is given, but it is not a known locale, this class will default to the default locale instead.


Defined in: ilib-full-dyn.js.

Class Summary
Constructor Attributes Constructor Name and Description
 
Currency(options)
Method Summary
Method Attributes Method Name and Description
<static>  
Return an array of the ids for all ISO 4217 currencies that this copy of ilib knows about.
 
Return the ISO 4217 currency code for this instance.
 
Return the default number of fraction digits that is typically used with this type of currency.
 
Return the locale for this currency.
 
Return the name of the currency in English.
 
Return the sign commonly used to represent this currency.
Class Detail
Currency(options)
Parameters:
options
{Object} a set of properties to govern how this instance is constructed.
Throws:
"currency xxx is unknown" when the given currency code is not in the list of known currencies. xxx is replaced with the requested code.
Method Detail
<static> {Array.<string>} Currency.getAvailableCurrencies()
Return an array of the ids for all ISO 4217 currencies that this copy of ilib knows about.
Returns:
{Array.<string>} an array of currency ids that this copy of ilib knows about.

{string} getCode()
Return the ISO 4217 currency code for this instance.
Returns:
{string} the ISO 4217 currency code for this instance

{number} getFractionDigits()
Return the default number of fraction digits that is typically used with this type of currency.
Returns:
{number} the number of fraction digits for this currency

{Locale} getLocale()
Return the locale for this currency. If the options to the constructor included a locale property in order to find the currency that is appropriate for that locale, then the locale is returned here. If the options did not include a locale, then this method returns undefined.
Returns:
{Locale} the locale used in the constructor of this instance, or undefined if no locale was given in the constructor

{string} getName()
Return the name of the currency in English.
Returns:
{string} the name of the currency in English

{string} getSign()
Return the sign commonly used to represent this currency.
Returns:
{string} the sign commonly used to represent this currency

Documentation generated by JsDoc Toolkit 2.4.0 on Tue Feb 02 2016 15:53:54 GMT-0800 (PST)