react-intl
Version:
Internationalize React apps. This library provides React components and an API to format dates, numbers, and strings, including pluralization and handling translations.
17 lines (16 loc) • 639 B
JavaScript
import "@formatjs/intl";
import * as React from "react";
import useIntl from "./useIntl.js";
import { jsx as _jsx } from "react/jsx-runtime";
const FormattedDateTimeRange = (props) => {
const intl = useIntl();
const { from, to, children, ...formatProps } = props;
const formattedValue = intl.formatDateTimeRange(from, to, formatProps);
if (typeof children === "function") {
return children(formattedValue);
}
const Text = intl.textComponent || React.Fragment;
return /* @__PURE__ */ _jsx(Text, { children: formattedValue });
};
FormattedDateTimeRange.displayName = "FormattedDateTimeRange";
export default FormattedDateTimeRange;