mirror of
https://github.com/NginxProxyManager/nginx-proxy-manager.git
synced 2026-01-21 19:25:43 +00:00
Fix frontend locale tests after date-fns changed intl formatting
and also attempt to format dates in locale
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import cn from "classnames";
|
||||
import { differenceInDays, isPast } from "date-fns";
|
||||
import { useLocaleState } from "src/context";
|
||||
import { formatDateTime, parseDate } from "src/locale";
|
||||
|
||||
interface Props {
|
||||
@@ -8,6 +9,7 @@ interface Props {
|
||||
highlistNearlyExpired?: boolean;
|
||||
}
|
||||
export function DateFormatter({ value, highlightPast, highlistNearlyExpired }: Props) {
|
||||
const { locale } = useLocaleState();
|
||||
const d = parseDate(value);
|
||||
const dateIsPast = d ? isPast(d) : false;
|
||||
const days = d ? differenceInDays(d, new Date()) : 0;
|
||||
@@ -15,5 +17,5 @@ export function DateFormatter({ value, highlightPast, highlistNearlyExpired }: P
|
||||
"text-danger": highlightPast && dateIsPast,
|
||||
"text-warning": highlistNearlyExpired && !dateIsPast && days <= 30 && days >= 0,
|
||||
});
|
||||
return <span className={cl}>{formatDateTime(value)}</span>;
|
||||
return <span className={cl}>{formatDateTime(value, locale)}</span>;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user