mirror of
https://github.com/NginxProxyManager/nginx-proxy-manager.git
synced 2025-12-06 00:16:49 +00:00
20 lines
664 B
TypeScript
20 lines
664 B
TypeScript
import cn from "classnames";
|
|
import { differenceInDays, isPast } from "date-fns";
|
|
import { formatDateTime, parseDate } from "src/locale";
|
|
|
|
interface Props {
|
|
value: string;
|
|
highlightPast?: boolean;
|
|
highlistNearlyExpired?: boolean;
|
|
}
|
|
export function DateFormatter({ value, highlightPast, highlistNearlyExpired }: Props) {
|
|
const d = parseDate(value);
|
|
const dateIsPast = d ? isPast(d) : false;
|
|
const days = d ? differenceInDays(d, new Date()) : 0;
|
|
const cl = cn({
|
|
"text-danger": highlightPast && dateIsPast,
|
|
"text-warning": highlistNearlyExpired && !dateIsPast && days <= 30 && days >= 0,
|
|
});
|
|
return <span className={cl}>{formatDateTime(value)}</span>;
|
|
}
|