signal-desktop/ts/components/conversation/LinkPreviewDate.tsx
2020-10-12 18:10:08 -04:00

23 lines
565 B
TypeScript

import * as React from 'react';
import moment, { Moment } from 'moment';
import { isLinkPreviewDateValid } from '../../linkPreviews/isLinkPreviewDateValid';
interface Props {
date: null | number;
className?: string;
}
export const LinkPreviewDate: React.FC<Props> = ({
date,
className = '',
}: Props) => {
const dateMoment: Moment | null = isLinkPreviewDateValid(date)
? moment(date)
: null;
return dateMoment ? (
<time className={className} dateTime={dateMoment.toISOString()}>
{dateMoment.format('ll')}
</time>
) : null;
};