hometown/app/javascript/mastodon/components/relative_timestamp.js

21 lines
614 B
JavaScript
Raw Normal View History

import React from 'react';
import { injectIntl, FormattedRelative } from 'react-intl';
import PropTypes from 'prop-types';
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-08-24 19:08:00 +00:00
RelativeTimestamp.propTypes = {
intl: PropTypes.object.isRequired,
timestamp: PropTypes.string.isRequired,
};
2016-08-24 19:08:00 +00:00
export default injectIntl(RelativeTimestamp);