2022-05-16 19:18:48 +00:00
|
|
|
import 'dayjs/locale/en';
|
|
|
|
|
2022-02-14 10:02:17 +00:00
|
|
|
import dayjs from 'dayjs';
|
|
|
|
import advancedFormat from 'dayjs/plugin/advancedFormat';
|
|
|
|
import timezone from 'dayjs/plugin/timezone';
|
|
|
|
import utc from 'dayjs/plugin/utc';
|
2022-05-16 19:18:48 +00:00
|
|
|
import { useI18n } from 'vue-i18n';
|
2022-02-14 10:02:17 +00:00
|
|
|
|
|
|
|
dayjs.extend(timezone);
|
|
|
|
dayjs.extend(utc);
|
|
|
|
dayjs.extend(advancedFormat);
|
2022-05-16 19:18:48 +00:00
|
|
|
dayjs.locale(navigator.language.split('-')[0]);
|
2022-02-14 10:02:17 +00:00
|
|
|
|
|
|
|
export function useDate() {
|
|
|
|
function toLocaleString(date: Date) {
|
2022-05-16 19:18:48 +00:00
|
|
|
return dayjs(date).format(useI18n().t('time.tmpl'));
|
2022-02-14 10:02:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return {
|
|
|
|
toLocaleString,
|
|
|
|
};
|
|
|
|
}
|