UNPKG

@yamada-ui/react

Version:

React UI components of the Yamada, by the Yamada, for the Yamada built with React and Emotion

32 lines (28 loc) 1.03 kB
"use client"; import { i18nCache } from "../../providers/i18n-provider/i18n-cache.js"; import { useI18n } from "../../providers/i18n-provider/i18n-provider.js"; import { useCallback, useRef } from "react"; //#region src/components/format/use-format-date-time.ts const getFormatDateTime = i18nCache(Intl.DateTimeFormat); /** * `useFormatDateTime` is a custom hook that returns the formatted date time. * * @see https://yamada-ui.com/docs/hooks/use-format-date-time */ const useFormatDateTime = (value, options) => { return useDateTimeFormat(options)(value); }; const useDateTimeFormat = ({ locale,...options } = {}) => { const { locale: defaultLocale } = useI18n(); const memoizedOptions = useRef(options); locale ??= defaultLocale; return useCallback((value, options$1) => { return getFormatDateTime(locale, { ...memoizedOptions.current, ...options$1 }).format(value); }, [locale]); }; //#endregion export { getFormatDateTime, useDateTimeFormat, useFormatDateTime }; //# sourceMappingURL=use-format-date-time.js.map