17 lines
414 B
JavaScript
17 lines
414 B
JavaScript
import { useI18n } from 'vue-i18n';
|
|
|
|
export default function (value, options = {}) {
|
|
if (!value) return;
|
|
|
|
if (!options.dateStyle && !options.timeStyle) {
|
|
options.day = '2-digit';
|
|
options.month = '2-digit';
|
|
options.year = 'numeric';
|
|
}
|
|
|
|
const { locale } = useI18n();
|
|
const date = new Date(value);
|
|
|
|
return new Intl.DateTimeFormat(locale.value, options).format(date);
|
|
}
|