1
0
Fork 0
VaultUI/src/formatDistance.ts

19 lines
442 B
TypeScript
Raw Normal View History

import { de, enGB, fr, it, nl, ru } from "date-fns/locale";
import { formatDistance as formatDistanceReal } from "date-fns";
2021-05-08 00:58:28 +01:00
import { pageState } from "./globalPageState";
2021-04-24 18:42:13 +01:00
2021-05-10 11:35:14 +01:00
function getLocale(): Locale {
2021-04-24 18:42:13 +01:00
return {
en: enGB,
fr: fr,
nl: nl,
ru: ru,
de: de,
it: it,
}[pageState.language];
2021-04-24 18:42:13 +01:00
}
2021-05-08 00:58:28 +01:00
export function formatDistance(d1: Date, d2: Date): string {
2021-04-24 18:42:13 +01:00
return formatDistanceReal(d1, d2, { locale: getLocale() });
}