This repository has been archived on 2022-08-14. You can view files and clone it, but cannot push or open issues or pull requests.
Files
outline/shared/components/Time.js
Tom Moor 2fd8b35ca9 Fixed: Modified time display on dashboard
New Time component for relative time formatting with accessibility
2018-07-01 19:56:58 -07:00

21 lines
471 B
JavaScript

// @flow
import * as React from 'react';
import distanceInWordsToNow from 'date-fns/distance_in_words_to_now';
import format from 'date-fns/format';
type Props = {
dateTime: string,
children?: React.Node,
};
function Time({ dateTime, children }: Props) {
const date = new Date(dateTime);
return (
<time dateTime={dateTime} title={format(date, 'MMMM Do, YYYY h:mm a')}>
{children || distanceInWordsToNow(date)}
</time>
);
}
export default Time;