1
0
Fork 0
VaultUI/src/formatDistance.ts
2021-05-15 10:58:54 +01:00

18 lines
427 B
TypeScript

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