import React from "react";
import moment from "moment";
import Moment from "react-moment";
import { Tooltip } from "antd";

export function DateFormatter(props) {
  return props.children ? (
    <Moment format="MM/DD/YYYY ">{props.children}</Moment>
  ) : null;
}

export function DateTimeFormatter(props) {
  return props.children ? (
    <Moment format="MM/DD/YYYY hh:mm a">{props.children}</Moment>
  ) : null;
}

export function TimeAgoFormatter(props) {
  const m = moment(props.children);
  return props.children ? (
    <Tooltip placement="top" title={m.format("MM/DD/YYY hh:mm A")}>
      {m.fromNow()}
    </Tooltip>
  ) : null;
}
