import { Box, BoxProps, forwardRef } from "@chakra-ui/react"; import { format } from "date-fns"; export type TimeOptions = { date: Date; format?: string; formattedDate?: string; }; export interface TimeProps extends BoxProps, TimeOptions {} export const Time = forwardRef( ({ date, format: formatString, formattedDate, ...boxProps }, ref) => { return ( {formattedDate ?? format(date, formatString ?? "")} ); } ); Time.displayName = "Time";