@carbon/utilities
Version:
Utilities and helpers to drive consistency across software products using the Carbon Design System
22 lines (21 loc) • 773 B
JavaScript
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
//#region src/datePartsOrder/datePartsOrder.ts
const _orderCache = /* @__PURE__ */ new Map();
function getMonthYearOrder(locale) {
const cached = _orderCache.get(locale);
if (cached) return cached;
const parts = new Intl.DateTimeFormat(locale, {
year: "numeric",
month: "long"
}).formatToParts(new Date(2e3, 0, 1));
const order = parts.findIndex((p) => p.type === "month") < parts.findIndex((p) => p.type === "year") ? "month-year" : "year-month";
_orderCache.set(locale, order);
return order;
}
const isMonthFirst = (locale) => getMonthYearOrder(locale) === "month-year";
const datePartsOrder = {
getMonthYearOrder,
isMonthFirst
};
//#endregion
exports.datePartsOrder = datePartsOrder;