import "choerodon-ui/lib/tooltip/style";
import _Tooltip from "choerodon-ui/lib/tooltip";

/**
 * hover 显示时间
 */
import React, { memo } from 'react';
import TimeAgo from 'timeago-react';
import { Choerodon } from '@choerodon/boot';
import { formatDate } from "../../utils";

function TimePopover(_ref) {
  var content = _ref.content,
      style = _ref.style;
  var timestamp = content && typeof content === 'string' ? Math.min(Date.now(), new Date(content.replace(/-/g, '/')).getTime()) : false;
  return /*#__PURE__*/React.createElement("div", {
    style: style
  }, /*#__PURE__*/React.createElement(_Tooltip, {
    title: formatDate(timestamp || content)
  }, /*#__PURE__*/React.createElement(TimeAgo, {
    datetime: timestamp || content,
    locale: Choerodon.getMessage('zh_CN', 'en')
  })));
}

export default /*#__PURE__*/memo(TimePopover);