2017-05-03 00:04:16 +00:00
|
|
|
import React from 'react';
|
2017-01-04 14:43:28 +00:00
|
|
|
import { injectIntl, FormattedRelative } from 'react-intl';
|
2017-04-21 18:05:35 +00:00
|
|
|
import PropTypes from 'prop-types';
|
2017-01-04 14:43:28 +00:00
|
|
|
|
|
|
|
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 16:20:52 +00:00
|
|
|
};
|
2016-08-24 19:08:00 +00:00
|
|
|
|
2016-11-16 16:20:52 +00:00
|
|
|
RelativeTimestamp.propTypes = {
|
2017-04-21 18:05:35 +00:00
|
|
|
intl: PropTypes.object.isRequired,
|
2017-05-20 15:31:47 +00:00
|
|
|
timestamp: PropTypes.string.isRequired,
|
2016-11-16 16:20:52 +00:00
|
|
|
};
|
2016-08-24 19:08:00 +00:00
|
|
|
|
2017-01-04 14:43:28 +00:00
|
|
|
export default injectIntl(RelativeTimestamp);
|