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>
  );
};

RelativeTimestamp.propTypes = {
  intl: PropTypes.object.isRequired,
  timestamp: PropTypes.string.isRequired,
};

export default injectIntl(RelativeTimestamp);

@@ -127,164 +127,31 @@
 nst 
-RelativeTimestamp = (%7B intl, timestamp %7D) =%3E %7B%0A  const date = new Date(timestamp);%0A%0A  return (%0A    %3Ctime dateTime=%7Btimestamp%7D title=%7Bintl.formatDate(date, %7B
+dateFormatOptions = %7B%0A 
  hou
@@ -161,16 +161,18 @@
 : false,
+%0A 
  year: '
@@ -180,16 +180,18 @@
 umeric',
+%0A 
  month: 
@@ -198,16 +198,18 @@
 'short',
+%0A 
  day: '2
@@ -216,16 +216,18 @@
 -digit',
+%0A 
  hour: '
@@ -235,16 +235,18 @@
 -digit',
+%0A 
  minute:
@@ -259,94 +259,74 @@
 git'
- %7D)%7D%3E%0A      %3CFormattedRelative value=%7Bdate%7D /%3E%0A    %3C/time%3E%0A  );%0A%7D;%0A%0ARelativeTimestamp.
+,%0A%7D;%0A%0Aclass RelativeTimestamp extends React.Component %7B%0A%0A  static 
 prop
@@ -337,16 +337,18 @@
 s = %7B%0A  
+ 
+ 
 intl: Pr
@@ -374,16 +374,18 @@
 quired,%0A
+  
   timest
@@ -418,18 +418,578 @@
 quired,%0A
+  %7D;%0A%0A  shouldComponentUpdate (nextProps) %7B%0A    // As of right now the locale doesn't change without a new page load,%0A    // but we might as well check in case that ever changes.%0A    return this.props.timestamp !== nextProps.timestamp %7C%7C%0A      this.props.intl.locale !== nextProps.intl.locale;%0A  %7D%0A%0A  render () %7B%0A    const %7B timestamp, intl %7D = this.props;%0A    const date = new Date(timestamp);%0A%0A    return (%0A      %3Ctime dateTime=%7Btimestamp%7D title=%7Bintl.formatDate(date, dateFormatOptions)%7D%3E%0A        %3CFormattedRelative value=%7Bdate%7D /%3E%0A      %3C/time%3E%0A    );%0A  %7D%0A%0A
 %7D
-;
 %0A%0Aexport

implement shouldComponentUpdate for relative_timestamp (#3320)