Globalization

This API obtains information and performs operations specific to the user's locale, language, and timezone.

Usage
Globalization.getPreferredLanguage()
    .then(res => console.log(res.value))
    .catch(e => console.log(e));

...

Globalization.getDateNames()
    .then(res => console.log(res.value))
    .catch(e => console.log(e));
window.Globalization.getPreferredLanguage()
    .then((res) => console.log(res.value))
    .catch((e) => console.log(e));

...

window.Globalization.getDateNames()
    .then((res) => console.log(res.value))
    .catch((e) => console.log(e));
window.Globalization.getPreferredLanguage()
    .then((res) => console.log(res.value))
    .catch((e) => console.log(e));

...

window.Globalization.getDateNames()
    .then((res) => console.log(res.value))
    .catch((e) => console.log(e));
(<any>window).Globalization.getPreferredLanguage()
    .then((res) => console.log(res.value))
    .catch((e) => console.log(e));

...

(<any>window).Globalization.getDateNames()
    .then((res) => console.log(res.value))
    .catch((e) => console.log(e));
window.Globalization.getPreferredLanguage()
    .then((res) => console.log(res.value))
    .catch((e) => console.log(e));

...

window.Globalization.getDateNames()
    .then((res) => console.log(res.value))
    .catch((e) => console.log(e));

Classes


Globalization

dateToString
dateToString(date: Date, options: GlobalizationOptions): Promise <ObjectResult>

Converts date to string


PARAMETERS
date: Date
options: GlobalizationOptions

RETURN
returns: Promise <ObjectResult>
getCurrencyPattern
getCurrencyPattern(currencyCode: string): Promise <GetCurrencyPatternResult>

Returns a pattern string to format and parse currency values according to the client's user preferences and ISO 4217 currency code.


PARAMETERS
currencyCodestring

RETURN
returns: Promise <GetCurrencyPatternResult>
getDateNames
getDateNames(options: DateNamesOptions): Promise <ObjectResult>

Returns an array of the names of the months or days of the week, depending on the client's user preferences and calendar.


PARAMETERS
option: DateNamesOptions

RETURN
returns: Promise <ObjectResult>
getDatePattern
getDatePattern(options: GlobalizationOptions): Promise <ObjectResult>

Returns a pattern string to format and parse dates according to the client's user preferences.


RETURN
returns: Promise <ObjectResult>
getFirstDayOfWeek
getFirstDayOfWeek(): Promise <ObjectResult>

Returns the first day of the week according to the client's user preferences and calendar.


RETURN
returns: Promise <ObjectResult>
getLocaleName
getLocaleName(): Promise <ObjectResult>

Returns the BCP 47 compliant locale identifier string to the successCallback with a properties object as a parameter.


RETURN
returns: Promise <ObjectResult>
getNumberPattern
getNumberPattern(options: GetNumberPatternOptions): Promise <GetNumberPatternResult>

Returns a pattern string to format and parse numbers according to the client's user preferences.


PARAMETERS
options: GetNumberPatternOptions

RETURN
returns: Promise <GetNumberPatternResult>
getPreferredLanguage
getPreferredLanguage(): Promise <ObjectResult>

Returns the BCP-47 compliant language identifier tag with properties object as a parameter. That object should have a value property with a String value.


PARAMETERS

RETURN
returns: Promise <ObjectResult>
isDayLightSavingsTime
isDayLightSavingsTime(date: Date): Promise <IsDayLightSavingsTimeResult>

Indicates whether daylight savings time is in effect for a given date using the client's time zone and calendar.


PARAMETERS
date: Date

RETURN
returns: Promise <IsDayLightSavingsTimeResult>
numberToString
numberToString(numberToConvert: int, options: NumberToStringOptions): Promise <ObjectResult>

Returns a number formatted as a string according to the client's user preferences.


PARAMETERS
numberToConvert: int
options: NumberToStringOptions

RETURN
returns: Promise <ObjectResult>
stringToDate
stringToDate(dateString: string, options: StringToDateOptions): Promise <StringToDateResult>

Parses a date formatted as a string, according to the client's user preferences and calendar using the time zone of the client, and returns the corresponding date object.


PARAMETERS
options: StringToDateOptions

RETURN
returns: Promise <StringToDateResult>
stringToNumber
stringToNumber(stringToConvert: string, options: StringToNumberOptions): Promise <ObjectResult>

PARAMETERS
stringToConvert: string
options: StringToNumberOptions

RETURN
returns: Promise <ObjectResult>

Interfaces

DateToStringResult

interface DateToStringResult {
    // Date you wish to convert
    date: Date;
    // Options for the converted date. Length, selector
    options: GlobalizationOptions;
}

GetDateNamesOptions

interface GetDateNamesOptions {
    item: string;
    type: string;
}

GetCurrencyPatternResult

interface GetCurrencyPatternResult {
    pattern: string;
    code: string;
    fraction: int;
    rounding: int;
    decimal: string;
    grouping: string;
}

ObjectResult

interface ObjectResult {
    value: string;
}

GetNumberPatternOptions

interface GetNumberPatternOptions {
    // Can be decimal, percent, or currency
    type: GlobalizationOptions;
}

GetNumberPatternResult

interface GetNumberPatternResult {
    // Can be decimal, percent, or currency
    type: string;
}

IsDayLightSavingsTimeResult

interface IsDayLightSavingsTimeResult {
    // Indicates whether or not daylight savings time is in effect
    dst: boolean;
}

NumberToStringOptions

interface NumberToStringOptions {
    type: string;
}

StringToDateOptions

interface StringToDateOptions {
    // Date as a string to be converted
    dateString: string;
    // Options for the converted date. Length, selector
    options: GlobalizationOptions;
}

StringToDateResult

interface StringToDateResult {
    // The four digit year
    year: int;
    // The month from (0-11)
    month: int;
    // The day from (1-31)
    day: int;
    // The hour from (0-23)
    hour: int;
    // The minute from (0-59)
    minute: int;
    // The second from (0-59)
    second: int;
    // The milliseconds (from 0-999)
    millisecond: int;
}

StringToNumberOptions

interface StringToNumberOptions {
    type: string;
}

GlobalizationOptions

interface GlobalizationOptions {
    formatLength: string;
    selector: string;
}