Add an Intl polyfill

This commit is contained in:
Eugen Rochko
2016-11-17 16:34:36 +01:00
parent 7ac574d9a9
commit a6e4f754fc
7 changed files with 19 additions and 29 deletions

View File

@@ -4,21 +4,12 @@ import {
FormattedRelative
} from 'react-intl';
const RelativeTimestamp = ({ timestamp, now }) => {
const diff = (new Date(now)) - (new Date(timestamp));
if (diff < 0) {
return <FormattedMessage id='relative_time.just_now' defaultMessage='Just now' />
} else if (diff > (3600 * 24 * 7 * 1000)) {
return <FormattedDate value={timestamp} />
} else {
return <FormattedRelative value={timestamp} initialNow={now} updateInterval={0} />
}
const RelativeTimestamp = ({ timestamp }) => {
return <FormattedRelative value={new Date(timestamp)} />;
};
RelativeTimestamp.propTypes = {
timestamp: React.PropTypes.string.isRequired,
now: React.PropTypes.any
timestamp: React.PropTypes.string.isRequired
};
export default RelativeTimestamp;