@formatjs/intl-enumerator
Version:
Intl.Enumerator polyfill
19 lines (18 loc) • 696 B
JavaScript
import { createMemoizedDateTimeFormat } from '@formatjs/ecma402-abstract';
import { calendars } from './calendars.generated';
function isSupportedCalendar(item, locale) {
if (locale === void 0) { locale = 'en'; }
try {
var dateTimeFormat = createMemoizedDateTimeFormat("".concat(locale, "-u-ca-").concat(item));
var options = dateTimeFormat.resolvedOptions().calendar;
if (item !== 'gregory' || options !== 'gregory')
return true;
}
catch (_err) { }
return false;
}
export function getSupportedCalendars(localePrefix) {
return calendars.filter(function (calendar) {
return isSupportedCalendar(calendar, localePrefix);
});
}