diff --git a/src/types/RelativeDateTime.js b/src/types/RelativeDateTime.js new file mode 100644 index 0000000..f27707d --- /dev/null +++ b/src/types/RelativeDateTime.js @@ -0,0 +1,35 @@ +import React from 'react' +import PropTypes from 'prop-types' +import Moment from 'moment' +import DatePart from './DatePart' +import Empty from './Empty' +import {SHORTDATETIME_FORMAT} from '../utils' + +/** + * Displays a datetime relative to the current time eg. "4 days ago" or "in 3 hours" + * alongside the datetime passed in + */ +class RelativeDateTime extends React.Component { + static propTypes = { + value: PropTypes.string, + } + + render() { + const date = Moment(this.props.value) + const isValid = date.isValid() + if (isValid) { + return ( +