Skip to content
Snippets Groups Projects
Commit 98b83aca authored by Eugen Rochko's avatar Eugen Rochko
Browse files

Fix #391 - relative timestamps now contain an exact datetime in title

parent 2b0b7ff1
Branches
Tags
No related merge requests found
import {
FormattedMessage,
FormattedDate,
FormattedRelative
} from 'react-intl';
const RelativeTimestamp = ({ timestamp }) => {
return <FormattedRelative value={new Date(timestamp)} />;
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>
);
};
RelativeTimestamp.propTypes = {
intl: React.PropTypes.object.isRequired,
timestamp: React.PropTypes.string.isRequired
};
export default RelativeTimestamp;
export default injectIntl(RelativeTimestamp);
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment