{"size": 739, "ext": "js", "max_stars_repo_path": "src/components/cells/DateCell.js", "max_stars_repo_name": "ejoubaud/modjo-logbook", "max_stars_repo_stars_event_min_datetime": "2018-10-18T05:14:39.000Z", "max_stars_repo_stars_event_max_datetime": "2018-10-18T05:14:39.000Z", "max_issues_repo_path": "src/components/cells/DateCell.js", "max_issues_repo_name": "ejoubaud/modjo-logbook", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/components/cells/DateCell.js", "max_forks_repo_name": "ejoubaud/modjo-logbook", "max_forks_repo_forks_event_min_datetime": "2020-06-29T08:33:41.000Z", "max_forks_repo_forks_event_max_datetime": "2020-06-29T08:33:41.000Z"}
{"max_stars_count": 1, "max_issues_count": null, "max_forks_count": 1, "avg_line_length": 30.7916666667, "max_line_length": 69, "alphanum_fraction": 0.700947226}
import React from 'react';
import Tooltip from '@material-ui/core/Tooltip';
import formatDistance from 'date-fns/distance_in_words';
import differenceInDays from 'date-fns/difference_in_days';
import format from 'date-fns/format';
import fr from 'date-fns/locale/fr';

import { sharedTooltipTouchConfig } from '../shared';

const dateFormat = 'ddd DD/MM HH:mm';

const DateCell = ({ date }) => {
  const now = new Date();
  const formatted = format(date, dateFormat, { locale: fr });
  if (differenceInDays(date, now) > 2) return <span>formatted</span>;
  return (
    <Tooltip title={formatted} {...sharedTooltipTouchConfig}>
      <span>{formatDistance(date, now, { locale: fr })}</span>
    </Tooltip>
  );
};

export default DateCell;
