Browse Source

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

master
Eugen Rochko 7 years ago
parent
commit
98b83aca37
1 changed files with 12 additions and 9 deletions
  1. +12
    -9
      app/assets/javascripts/components/components/relative_timestamp.jsx

+ 12
- 9
app/assets/javascripts/components/components/relative_timestamp.jsx View File

@ -1,15 +1,18 @@
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 = { RelativeTimestamp.propTypes = {
intl: React.PropTypes.object.isRequired,
timestamp: React.PropTypes.string.isRequired timestamp: React.PropTypes.string.isRequired
}; };
export default RelativeTimestamp;
export default injectIntl(RelativeTimestamp);

Loading…
Cancel
Save