UNPKG

@maz-ui/utils

Version:

Utils of maz-ui for JavaScript/TypeScript users

22 lines (21 loc) 547 B
const a = { month: "short", day: "numeric", year: "numeric" }; function n(t, r, o) { if (r === void 0) throw new TypeError("[maz-ui](FilterDate) The `locale` attribute is required."); if (typeof r != "string") throw new TypeError("[maz-ui](FilterDate) The `locale` attribute must be a string."); const i = o ?? a; try { const e = t instanceof Date ? t : new Date(t); return new Intl.DateTimeFormat(r, i).format(e); } catch (e) { throw new Error(`[maz-ui](FilterDate) ${e}`); } } export { n as formatDate };