UNPKG

@formatjs/intl-enumerator

Version:
14 lines (13 loc) 564 B
import { createMemoizedDateTimeFormat } from "@formatjs/ecma402-abstract"; import { calendars } from "./calendars.generated.js"; function isSupportedCalendar(item, locale = "en") { try { const dateTimeFormat = createMemoizedDateTimeFormat(`${locale}-u-ca-${item}`); const options = dateTimeFormat.resolvedOptions().calendar; if (item !== "gregory" || options !== "gregory") return true; } catch {} return false; } export function getSupportedCalendars(localePrefix) { return calendars.filter((calendar) => isSupportedCalendar(calendar, localePrefix)); }