UNPKG

@arctics/utils

Version:

A JavaScript/TypeScript package providing utilities around certain functionalities

49 lines (48 loc) 1.96 kB
/** * The Localization class provides methods to handle locale-specific formatting for numbers and dates. */ export declare class Localization { /** * The current locale code. * @type {string} * @private * @default 'en-US' */ private static currentLocale; /** * Sets the current locale to the provided locale code. * @param {string} localeCode - The locale code to set. */ static setLocale(localeCode: string): void; /** * Returns the current locale code. * @returns {string} The current locale code. */ static getLocale(): string; /** * Formats a number according to the current locale. * @param {number} number - The number to format. * @returns {string} The formatted number. */ static formatNumber(number: number): string; /** * Formats a number as currency according to the current locale. * @param {number} number - The number to format. * @param {string} [currencyCode] - The currency code to use for formatting. Defaults to 'USD' if not provided. * @returns {string} The formatted currency. */ static formatCurrency(number: number, currencyCode?: string): string; /** * Formats a date according to the current locale. * @param {Date | string} date - The date to format, either as a Date object or a string. * @param {Intl.DateTimeFormatOptions} [options] - Options for date formatting as per Intl.DateTimeFormatOptions. * @returns {string} The formatted date. */ static formatDate(date: Date | string, options?: Intl.DateTimeFormatOptions): string; /** * Formats a phone number according to the specified region or the current locale. * @param {string} phoneNumber - The phone number to format. * @returns {string} The formatted phone number, or the original number if formatting fails. */ static formatPhoneNumber(phoneNumber: string): string; }