Remove pageState in formatDistance.ts.
This commit is contained in:
parent
89bedc8be5
commit
4e390d3e96
|
@ -1,8 +1,7 @@
|
|||
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 {
|
||||
function getLocale(language: string): Locale {
|
||||
return {
|
||||
en: enGB,
|
||||
fr: fr,
|
||||
|
@ -10,9 +9,9 @@ function getLocale(): Locale {
|
|||
ru: ru,
|
||||
de: de,
|
||||
it: it,
|
||||
}[pageState.language];
|
||||
}[language];
|
||||
}
|
||||
|
||||
export function formatDistance(d1: Date, d2: Date): string {
|
||||
return formatDistanceReal(d1, d2, { locale: getLocale() });
|
||||
export function formatDistance(d1: Date, d2: Date, language: string): string {
|
||||
return formatDistanceReal(d1, d2, { locale: getLocale(language) });
|
||||
}
|
||||
|
|
|
@ -118,7 +118,7 @@ document.addEventListener(
|
|||
interpolation: {
|
||||
format: function (value: unknown, format, _): string {
|
||||
if (format === "until_date" && value instanceof Date)
|
||||
return formatDistance(new Date(), new Date(value));
|
||||
return formatDistance(new Date(), new Date(value), pageState.language);
|
||||
return value as string;
|
||||
},
|
||||
},
|
||||
|
|
Loading…
Reference in a new issue