闭社主体 forked from https://github.com/tootsuite/mastodon
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

20 lines
614 B

  1. import React from 'react';
  2. import { injectIntl, FormattedRelative } from 'react-intl';
  3. import PropTypes from 'prop-types';
  4. const RelativeTimestamp = ({ intl, timestamp }) => {
  5. const date = new Date(timestamp);
  6. return (
  7. <time dateTime={timestamp} title={intl.formatDate(date, { hour12: false, year: 'numeric', month: 'short', day: '2-digit', hour: '2-digit', minute: '2-digit' })}>
  8. <FormattedRelative value={date} />
  9. </time>
  10. );
  11. };
  12. RelativeTimestamp.propTypes = {
  13. intl: PropTypes.object.isRequired,
  14. timestamp: PropTypes.string.isRequired,
  15. };
  16. export default injectIntl(RelativeTimestamp);