1
0
Fork 0
VaultUI/src/formatDistance.ts
2021-05-10 11:35:14 +01:00

18 lines
452 B
TypeScript

import { de, enGB, fr, it, nl, ru } from 'date-fns/locale'
import { formatDistance as formatDistanceReal} from 'date-fns';
import { pageState } from "./globalPageState";
function getLocale(): Locale {
return {
"en": enGB,
"fr": fr,
"nl": nl,
"ru": ru,
"de": de,
"it": it,
}[pageState.language];
}
export function formatDistance(d1: Date, d2: Date): string {
return formatDistanceReal(d1, d2, { locale: getLocale() });
}