UNPKG

@formatjs/intl-datetimeformat

Version:
20 lines (19 loc) 738 B
// eslint-disable-next-line import/no-cycle import { DateTimeFormat } from "./core.js"; import { ToDateTimeOptions } from "./abstract/ToDateTimeOptions.js"; /** * Number.prototype.toLocaleString ponyfill * https://tc39.es/ecma402/#sup-number.prototype.tolocalestring */ export function toLocaleString(x, locales, options) { const dtf = new DateTimeFormat(locales, options); return dtf.format(x); } export function toLocaleDateString(x, locales, options) { const dtf = new DateTimeFormat(locales, ToDateTimeOptions(options, "date", "date")); return dtf.format(x); } export function toLocaleTimeString(x, locales, options) { const dtf = new DateTimeFormat(locales, ToDateTimeOptions(options, "time", "time")); return dtf.format(x); }