import { Tooltip } from "@saleor/macaw-ui/next"; import moment from "moment-timezone"; import React from "react"; import ReactMoment from "react-moment"; import { LocaleConsumer } from "../Locale"; import { TimezoneConsumer } from "../Timezone"; import { Consumer } from "./DateContext"; interface DateTimeProps { date: string; plain?: boolean; } export const DateTime: React.FC = ({ date, plain }) => { const getTitle = (value: string, locale?: string, tz?: string) => { let date = moment(value).locale(locale); if (tz !== undefined) { date = date.tz(tz); } return date.format("lll"); }; return ( {tz => ( {({ locale }) => ( {currentDate => plain ? ( getTitle(date, locale, tz) ) : (
{date}
{getTitle(date, locale, tz)}
) }
)}
)}
); }; DateTime.displayName = "DateTime"; export default DateTime;