Class Index | File Index

Classes


Class jsworld.Locale

Represents a POSIX-style locale with its numeric, monetary and date/time properties. Also provides a set of locale helper methods.

The locale properties follow the POSIX standards:


Defined in: <JsWorld.js>.

Class Summary
Constructor Attributes Constructor Name and Description
 
jsworld.Locale(properties)
Creates a new locale object (POSIX-style) with the specified properties.
Method Summary
Method Attributes Method Name and Description
 
Gets the position of the local (shorthand) currency symbol relative to the amount.
 
Returns the abbreviated name of the specified month.
 
Returns the abbreviated name of the specified weekday.
 
Gets the local shorthand currency symbol.
 
Gets the decimal delimiter (radix) character for numeric quantities.
 
Gets the number of fractional digits for local (shorthand) symbol formatting.
 
Gets the internaltion currency symbol (ISO-4217 code).
 
Gets the number of fractional digits for international (ISO-4217 code) formatting.
 
Gets the decimal delimiter (radix) for monetary quantities.
 
getMonthName(monthNum)
Returns the name of the specified month.
 
getWeekdayName(weekdayNum)
Returns the name of the specified weekday.
 
Gets the position of the international (ISO-4217 code) currency symbol relative to the amount.
Class Detail
jsworld.Locale(properties)
Creates a new locale object (POSIX-style) with the specified properties.
Parameters:
{object} properties
An object containing the raw locale properties:
{String} properties.decimal_point
A string containing the symbol that shall be used as the decimal delimiter (radix character) in numeric, non-monetary formatted quantities. This property cannot be omitted and cannot be set to the empty string.
{String} properties.thousands_sep
A string containing the symbol that shall be used as a separator for groups of digits to the left of the decimal delimiter in numeric, non-monetary formatted monetary quantities.
{String} properties.grouping
Defines the size of each group of digits in formatted non-monetary quantities. The operand is a sequence of integers separated by semicolons. Each integer specifies the number of digits in each group, with the initial integer defining the size of the group immediately preceding the decimal delimiter, and the following integers defining the preceding groups. If the last integer is not -1, then the size of the previous group (if any) shall be repeatedly used for the remainder of the digits. If the last integer is -1, then no further grouping shall be performed.
{String} properties.int_curr_symbol
The first three letters signify the ISO-4217 currency code, the fourth letter is the international symbol separation character (normally a space).
{String} properties.currency_symbol
The local shorthand currency symbol, e.g. "$" for the en_US locale
{String} properties.mon_decimal_point
The symbol to be used as the decimal delimiter (radix character)
{String} properties.mon_thousands_sep
The symbol to be used as a separator for groups of digits to the left of the decimal delimiter.
{String} properties.mon_grouping
A string that defines the size of each group of digits. The operand is a sequence of integers separated by semicolons (";"). Each integer specifies the number of digits in each group, with the initial integer defining the size of the group preceding the decimal delimiter, and the following integers defining the preceding groups. If the last integer is not -1, then the size of the previous group (if any) must be repeatedly used for the remainder of the digits. If the last integer is -1, then no further grouping is to be performed.
{String} properties.positive_sign
The string to indicate a non-negative monetary amount.
{String} properties.negative_sign
The string to indicate a negative monetary amount.
{integer Number} properties.frac_digits
An integer representing the number of fractional digits (those to the right of the decimal delimiter) to be written in a formatted monetary quantity using currency_symbol.
{integer Number} properties.int_frac_digits
An integer representing the number of fractional digits (those to the right of the decimal delimiter) to be written in a formatted monetary quantity using int_curr_symbol.
{integer Number} properties.p_cs_precedes
An integer set to 1 if the currency_symbol precedes the value for a monetary quantity with a non-negative value, and set to 0 if the symbol succeeds the value.
{integer Number} properties.n_cs_precedes
An integer set to 1 if the currency_symbol precedes the value for a monetary quantity with a negative value, and set to 0 if the symbol succeeds the value.
{integer Number} properties.p_sep_by_space
Set to a value indicating the separation of the currency_symbol, the sign string, and the value for a non-negative formatted monetary quantity:

0 No space separates the currency symbol and value.

1 If the currency symbol and sign string are adjacent, a space separates them from the value; otherwise, a space separates the currency symbol from the value.

2 If the currency symbol and sign string are adjacent, a space separates them; otherwise, a space separates the sign string from the value.

{integer Number} properties.n_sep_by_space
Set to a value indicating the separation of the currency_symbol, the sign string, and the value for a negative formatted monetary quantity. Rules same as for p_sep_by_space.
{integer Number} properties.p_sign_posn
An integer set to a value indicating the positioning of the positive_sign for a monetary quantity with a non-negative value:

0 Parentheses enclose the quantity and the currency_symbol.

1 The sign string precedes the quantity and the currency_symbol.

2 The sign string succeeds the quantity and the currency_symbol.

3 The sign string precedes the currency_symbol.

4 The sign string succeeds the currency_symbol.

{integer Number} properties.n_sign_posn
An integer set to a value indicating the positioning of the negative_sign for a negative formatted monetary quantity. Rules same as for p_sign_posn.
{integer Number} properties.int_p_cs_precedes
An integer set to 1 if the int_curr_symbol precedes the value for a monetary quantity with a non-negative value, and set to 0 if the symbol succeeds the value.
{integer Number} properties.int_n_cs_precedes
An integer set to 1 if the int_curr_symbol precedes the value for a monetary quantity with a negative value, and set to 0 if the symbol succeeds the value.
{integer Number} properties.int_p_sep_by_space
Set to a value indicating the separation of the int_curr_symbol, the sign string, and the value for a non-negative internationally formatted monetary quantity. Rules same as for p_sep_by_space.
{integer Number} properties.int_n_sep_by_space
Set to a value indicating the separation of the int_curr_symbol, the sign string, and the value for a negative internationally formatted monetary quantity. Rules same as for p_sep_by_space.
{integer Number} properties.int_p_sign_posn
An integer set to a value indicating the positioning of the positive_sign for a positive monetary quantity formatted with the international format. Rules same as for p_sign_posn.
{integer Number} properties.int_n_sign_posn
An integer set to a value indicating the positioning of the negative_sign for a negative monetary quantity formatted with the international format. Rules same as for p_sign_posn.
{String[] | String} properties.abday
The abbreviated weekday names, corresponding to the %a conversion specification. The property must be either an array of 7 strings or a string consisting of 7 semicolon-separated substrings, each surrounded by double-quotes. The first must be the abbreviated name of the day corresponding to Sunday, the second the abbreviated name of the day corresponding to Monday, and so on.
{String[] | String} properties.day
The full weekday names, corresponding to the %A conversion specification. The property must be either an array of 7 strings or a string consisting of 7 semicolon-separated substrings, each surrounded by double-quotes. The first must be the full name of the day corresponding to Sunday, the second the full name of the day corresponding to Monday, and so on.
{String[] | String} properties.abmon
The abbreviated month names, corresponding to the %b conversion specification. The property must be either an array of 12 strings or a string consisting of 12 semicolon-separated substrings, each surrounded by double-quotes. The first must be the abbreviated name of the first month of the year (January), the second the abbreviated name of the second month, and so on.
{String[] | String} properties.mon
The full month names, corresponding to the %B conversion specification. The property must be either an array of 12 strings or a string consisting of 12 semicolon-separated substrings, each surrounded by double-quotes. The first must be the full name of the first month of the year (January), the second the full name of the second month, and so on.
{String} properties.d_fmt
The appropriate date representation. The string may contain any combination of characters and conversion specifications (%).
{String} properties.t_fmt
The appropriate time representation. The string may contain any combination of characters and conversion specifications (%).
{String} properties.d_t_fmt
The appropriate date and time representation. The string may contain any combination of characters and conversion specifications (%).
{String[] | String} properties.am_pm
The appropriate representation of the ante-meridiem and post-meridiem strings, corresponding to the %p conversion specification. The property must be either an array of 2 strings or a string consisting of 2 semicolon-separated substrings, each surrounded by double-quotes. The first string must represent the ante-meridiem designation, the last string the post-meridiem designation.
Throws:
@throws Error on a undefined or invalid locale property.
Method Detail
{Boolean} currencySymbolPrecedes()
Gets the position of the local (shorthand) currency symbol relative to the amount. Assumes a non-negative amount.
Returns:
{Boolean} True if the symbol precedes the amount, false if the symbol succeeds the amount.

{String | String[]} getAbbreviatedMonthName(monthNum)
Returns the abbreviated name of the specified month.
Parameters:
{integer Number} monthNum Optional
An integer between 0 and 11. Zero corresponds to January, one to February, etc. If omitted the method will return an array of all abbreviated month names.
Throws:
Error on invalid argument.
Returns:
{String | String[]} The abbreviated name of the specified month or an array of all abbreviated month names.

{String | String[]} getAbbreviatedWeekdayName(weekdayNum)
Returns the abbreviated name of the specified weekday.
Parameters:
{integer Number} weekdayNum Optional
An integer between 0 and 6. Zero corresponds to Sunday, one to Monday, etc. If omitted the method will return an array of all abbreviated weekday names.
Throws:
Error on invalid argument.
Returns:
{String | String[]} The abbreviated name of the specified weekday or an array of all abbreviated weekday names.

{String} getCurrencySymbol()
Gets the local shorthand currency symbol.
Returns:
{String} The currency symbol.

{String} getDecimalPoint()
Gets the decimal delimiter (radix) character for numeric quantities.
Returns:
{String} The radix character.

{integer Number} getFractionalDigits()
Gets the number of fractional digits for local (shorthand) symbol formatting.
Returns:
{integer Number} The number of fractional digits.

{String} getIntCurrencySymbol()
Gets the internaltion currency symbol (ISO-4217 code).
Returns:
{String} The international currency symbol.

{integer Number} getIntFractionalDigits()
Gets the number of fractional digits for international (ISO-4217 code) formatting.
Returns:
{integer Number} The number of fractional digits.

{String} getMonetaryDecimalPoint()
Gets the decimal delimiter (radix) for monetary quantities.
Returns:
{String} The radix character.

{String | String[]} getMonthName(monthNum)
Returns the name of the specified month.
Parameters:
{integer Number} monthNum Optional
An integer between 0 and 11. Zero corresponds to January, one to February, etc. If omitted the method will return an array of all month names.
Throws:
Error on invalid argument.
Returns:
{String | String[]} The name of the specified month or an array of all month names.

{String | String[]} getWeekdayName(weekdayNum)
Returns the name of the specified weekday.
Parameters:
{integer Number} weekdayNum Optional
An integer between 0 and 6. Zero corresponds to Sunday, one to Monday, etc. If omitted the method will return an array of all weekday names.
Throws:
Error on invalid argument.
Returns:
{String | String[]} The name of the specified weekday or an array of all weekday names.

{Boolean} intCurrencySymbolPrecedes()
Gets the position of the international (ISO-4217 code) currency symbol relative to the amount. Assumes a non-negative amount.
Returns:
{Boolean} True if the symbol precedes the amount, false if the symbol succeeds the amount.

Documentation generated by JsDoc Toolkit 2.4.0