signal-desktop/ts/components/conversation/LinkPreviewDate.tsx

24 lines
565 B
TypeScript
Raw Normal View History

2020-09-28 23:46:31 +00:00
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;
};