@carbon/utilities
Version:
Utilities and helpers to drive consistency across software products using the Carbon Design System
2 lines (1 loc) • 379 B
JavaScript
const a=new Map;function s(t){const e=a.get(t);if(e)return e;const n=new Intl.DateTimeFormat(t,{year:"numeric",month:"long"}).formatToParts(new Date(2e3,0,1)),d=n.findIndex(r=>r.type==="month"),h=n.findIndex(r=>r.type==="year"),o=d<h?"month-year":"year-month";return a.set(t,o),o}const m=t=>s(t)==="month-year",c={getMonthYearOrder:s,isMonthFirst:m};export{c as datePartsOrder};