2017-01-04 15:43:28 +01:00
|
|
|
import { injectIntl, FormattedRelative } from 'react-intl';
|
|
|
|
|
|
|
|
const RelativeTimestamp = ({ intl, timestamp }) => {
|
|
|
|
const date = new Date(timestamp);
|
|
|
|
|
|
|
|
return (
|
|
|
|
<time dateTime={timestamp} title={intl.formatDate(date, { hour12: false, year: 'numeric', month: 'short', day: '2-digit', hour: '2-digit', minute: '2-digit' })}>
|
|
|
|
<FormattedRelative value={date} />
|
|
|
|
</time>
|
|
|
|
);
|
2016-11-16 17:20:52 +01:00
|
|
|
};
|
2016-08-24 21:08:00 +02:00
|
|
|
|
2016-11-16 17:20:52 +01:00
|
|
|
RelativeTimestamp.propTypes = {
|
2017-01-04 15:43:28 +01:00
|
|
|
intl: React.PropTypes.object.isRequired,
|
2016-11-17 16:34:36 +01:00
|
|
|
timestamp: React.PropTypes.string.isRequired
|
2016-11-16 17:20:52 +01:00
|
|
|
};
|
2016-08-24 21:08:00 +02:00
|
|
|
|
2017-01-04 15:43:28 +01:00
|
|
|
export default injectIntl(RelativeTimestamp);
|