UNPKG

angular-l10n

Version:

An Angular library to translate messages, dates and numbers

57 lines 1.45 kB
/** * @fileoverview added by tsickle * @suppress {checkTypes,extraRequire,uselessCode} checked by tsc */ /** * Provides the methods to check if Intl APIs are supported. */ export class IntlAPI { /** * @return {?} */ static hasIntl() { /** @type {?} */ const hasIntl = typeof Intl === "object" && !!Intl; return hasIntl; } /** * @return {?} */ static hasDateTimeFormat() { return IntlAPI.hasIntl() && Intl.hasOwnProperty("DateTimeFormat"); } /** * @return {?} */ static hasTimezone() { if (IntlAPI.hasIntl() && IntlAPI.hasDateTimeFormat()) { try { new Intl.DateTimeFormat('en-US', { timeZone: 'America/Los_Angeles' }).format(new Date()); } catch (e) { return false; } return true; } return false; } /** * @return {?} */ static hasNumberFormat() { return IntlAPI.hasIntl() && Intl.hasOwnProperty("NumberFormat"); } /** * @return {?} */ static hasCollator() { return IntlAPI.hasIntl() && Intl.hasOwnProperty("Collator"); } /** * @return {?} */ static hasRelativeTimeFormat() { return IntlAPI.hasIntl() && Intl.hasOwnProperty("RelativeTimeFormat"); } } //# sourceMappingURL=intl-api.js.map