UNPKG

@kcuf/intl-formatter

Version:
16 lines (15 loc) 615 B
import { formatDateFallback, getFormatDateOptions, getFormatDateFallbackPattern } from './util'; /** * 格式化日期时间 * * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DateTimeFormat */ export default function formatDate(date, format) { var locale = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'en-US'; try { return new Intl.DateTimeFormat(locale, getFormatDateOptions(format)).format(date); } catch (_err) { return formatDateFallback(date, getFormatDateFallbackPattern(format)); } } //# sourceMappingURL=format-date.js.map