gitscope
← marzneshin / v0.5.0 / dashboard/src/components/info-table/date-table-row.tsx
https://dev.kronoz.win/r/marzneshin.git
dashboard/src/components/info-table/date-table-row.tsx · TypeScript
Blame Raw
 1import type { FC } from "react";
 2import { TableRowWithCell } from "./table-row-with-cell";
 3import { format, isValid } from "date-fns";
 4
 5export const DateTableRow: FC<{
 6    label: string;
 7    withTime?: boolean;
 8    date?: Date | null | string;
 9}> = ({ label, date, withTime = false }) => {
10    let formattedDate = "";
11    if (date && isValid(new Date(date))) {
12        formattedDate = format(new Date(date + "Z"), withTime ? "Ppp" : "P");
13    }
14    return <TableRowWithCell label={label} value={formattedDate} />;
15};