UNPKG

@carbon/utilities

Version:

Utilities and helpers to drive consistency across software products using the Carbon Design System

2 lines (1 loc) 812 B
function i(l,t){return new Intl.DateTimeFormat(t?.locale,{timeStyle:t?.style??"short",timeZone:t?.timeZone}).format(l)}function r(l,t){return new Intl.DateTimeFormat(t?.locale,{dateStyle:t?.style??"medium",timeZone:t?.timeZone}).format(l)}function o(l,t){const e=t?.timeStyle??(t?.style==="tooltip"?"long":t?.style)??"short",m=t?.dateStyle??(t?.style==="tooltip"?"full":t?.style)??"medium";return new Intl.DateTimeFormat(t?.locale,{timeStyle:e,dateStyle:m,timeZone:t?.timeZone}).format(l)}function y(l,t,e){const m=e?.timeStyle===null?void 0:e?.timeStyle??e?.style??"short",a=e?.dateStyle===null?void 0:e?.dateStyle??e?.style??"medium";return new Intl.DateTimeFormat(e?.locale,{timeStyle:m,dateStyle:a,timeZone:e?.timeZone}).formatRange(l,t)}export{o as format,r as formatDate,y as formatRange,i as formatTime};