Openstatus www.openstatus.dev
at main 32 lines 847 B view raw
1import { HoverCardTimestamp } from "@/components/common/hover-card-timestamp"; 2import { cn } from "@/lib/utils"; 3import { format } from "date-fns"; 4 5export function TableCellDate({ 6 value, 7 className, 8 formatStr = "LLL dd, y HH:mm:ss", 9 ...props 10}: React.ComponentProps<"div"> & { value: unknown; formatStr?: string }) { 11 if (value instanceof Date) { 12 return ( 13 <HoverCardTimestamp date={value}> 14 <div className={cn("text-muted-foreground", className)} {...props}> 15 {format(value, formatStr)} 16 </div> 17 </HoverCardTimestamp> 18 ); 19 } 20 if (typeof value === "string") { 21 return ( 22 <div className={cn("text-muted-foreground", className)} {...props}> 23 {value} 24 </div> 25 ); 26 } 27 return ( 28 <div className={cn("text-muted-foreground", className)} {...props}> 29 - 30 </div> 31 ); 32}