@udus/notion-renderer
Version:

11 lines (10 loc) • 667 B
JavaScript
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
import { zonedTimeToUtc, format as formatDate } from "date-fns-tz";
export const DateComponent = ({ date, format = "yyyy-MM-dd", }) => {
if (!date)
return null;
const time_zone = date.time_zone ?? "UTC";
const start = zonedTimeToUtc(date.start, time_zone);
const end = date.end && zonedTimeToUtc(date.end, time_zone);
return (_jsxs(_Fragment, { children: [_jsx("span", { children: formatDate(start, format) }), end && (_jsxs("span", { children: [_jsx("span", { children: " \u2192 " }), _jsx("span", { children: formatDate(end, format) })] }))] }));
};