UNPKG

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.

19 lines (18 loc) 934 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var tslib_1 = require("tslib"); var React = tslib_1.__importStar(require("react")); var injectIntl_1 = require("./injectIntl"); var utils_1 = require("../utils"); var FormattedDateTimeRange = function (props) { return (React.createElement(injectIntl_1.Context.Consumer, null, function (intl) { utils_1.invariantIntlContext(intl); var from = props.from, to = props.to, children = props.children, formatProps = tslib_1.__rest(props, ["from", "to", "children"]); var formattedValue = intl.formatDateTimeRange(from, to, formatProps); if (typeof children === 'function') { return children(formattedValue); } var Text = intl.textComponent || React.Fragment; return React.createElement(Text, null, formattedValue); })); }; FormattedDateTimeRange.displayName = 'FormattedDateTimeRange'; exports.default = FormattedDateTimeRange;