MCPcopy Create free account
hub / github.com/dailydotdev/apps / DateFormat

Function DateFormat

packages/shared/src/components/utilities/DateFormat.tsx:14–45  ·  view source on GitHub ↗
({
  date,
  type,
  className,
  prefix,
}: DateFormatProps)

Source from the content-addressed store, hash-verified

12 prefix?: string;
13}
14export 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};

Callers

nothing calls this directly

Calls 2

isValidDateFunction · 0.90
formatDateFunction · 0.90

Tested by

no test coverage detected