({
date,
type,
className,
prefix,
}: DateFormatProps)
| 12 | prefix?: string; |
| 13 | } |
| 14 | export const DateFormat = ({ |
| 15 | date, |
| 16 | type, |
| 17 | className, |
| 18 | prefix, |
| 19 | }: DateFormatProps): ReactElement | null => { |
| 20 | if (date === null || date === undefined) { |
| 21 | return null; |
| 22 | } |
| 23 | |
| 24 | const convertedDate = new Date(date); |
| 25 | |
| 26 | if (!isValidDate(convertedDate)) { |
| 27 | return null; |
| 28 | } |
| 29 | |
| 30 | const renderDate = formatDate({ value: convertedDate, type }); |
| 31 | |
| 32 | return ( |
| 33 | <time |
| 34 | title={format(convertedDate, 'EEE MMM dd yyyy HH:mm:ss OOOO')} |
| 35 | className={classNames( |
| 36 | 'inline-block h-4 align-middle leading-4', |
| 37 | className, |
| 38 | )} |
| 39 | dateTime={convertedDate.toISOString()} |
| 40 | > |
| 41 | {prefix} |
| 42 | {renderDate} |
| 43 | </time> |
| 44 | ); |
| 45 | }; |
nothing calls this directly
no test coverage detected