mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2024-06-12 18:39:33 +00:00
7d7d75d7e5
* Add support for localization * Add docs & format code * Add lib to docs
23 lines
521 B
TypeScript
23 lines
521 B
TypeScript
import 'dayjs/locale/en';
|
|
|
|
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);
|
|
dayjs.locale(navigator.language.split('-')[0]);
|
|
|
|
export function useDate() {
|
|
function toLocaleString(date: Date) {
|
|
return dayjs(date).format(useI18n().t('time.tmpl'));
|
|
}
|
|
|
|
return {
|
|
toLocaleString,
|
|
};
|
|
}
|