2022-05-16 19:18:48 +00:00
|
|
|
import 'dayjs/locale/en';
|
2022-06-19 05:31:16 +00:00
|
|
|
import 'dayjs/locale/lv';
|
2022-06-21 16:18:02 +00:00
|
|
|
import 'dayjs/locale/de';
|
2022-05-16 19:18:48 +00:00
|
|
|
|
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
|
|
|
|
2022-06-19 05:31:16 +00:00
|
|
|
import { getUserLanguage } from '~/utils/locale';
|
|
|
|
|
2022-02-14 10:02:17 +00:00
|
|
|
dayjs.extend(timezone);
|
|
|
|
dayjs.extend(utc);
|
|
|
|
dayjs.extend(advancedFormat);
|
2022-06-19 05:31:16 +00:00
|
|
|
dayjs.locale(getUserLanguage());
|
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,
|
|
|
|
};
|
|
|
|
}
|