woodpecker/web/src/compositions/useDate.ts
qwerty287 d1c51f4af8
Lazy-load TimeAgo locales (#2094)
1. new translation docs
2. lazy-load TimeAgo locales (used for "x min ago" messages). This 1.
reduces size and 2. provides all languages without adding them manually.
3. Remove DayJS locales, they're unused.
2023-08-03 19:25:12 +02:00

19 lines
446 B
TypeScript

import dayjs from 'dayjs';
import advancedFormat from 'dayjs/plugin/advancedFormat';
import timezone from 'dayjs/plugin/timezone';
import utc from 'dayjs/plugin/utc';
import { useI18n } from 'vue-i18n';
dayjs.extend(timezone);
dayjs.extend(utc);
dayjs.extend(advancedFormat);
export function useDate() {
function toLocaleString(date: Date) {
return dayjs(date).format(useI18n().t('time.tmpl'));
}
return {
toLocaleString,
};
}