'use client'; import { useMemo } from 'react'; import { useLocale } from 'next-intl'; import { APP_DATE, formatAppDate, formatAppDateTime, formatAppNumber, formatAppTableDate, formatAppTime, formatAppTimeRange, createAppDateFormatter, } from '@/lib/i18n/format'; export function useAppFormatters() { const locale = useLocale(); return useMemo( () => ({ locale, formatDate: (value: Parameters[0], options?: Intl.DateTimeFormatOptions) => formatAppDate(value, locale, options), formatTime: (value: Parameters[0], options?: Intl.DateTimeFormatOptions) => formatAppTime(value, locale, options), formatDateTime: ( value: Parameters[0], options?: Intl.DateTimeFormatOptions, ) => formatAppDateTime(value, locale, options), formatTimeRange: ( start: Parameters[0], end: Parameters[1], options?: Intl.DateTimeFormatOptions, ) => formatAppTimeRange(start, end, locale, options), formatTableDate: (value: Parameters[0]) => formatAppTableDate(value, locale), formatNumber: (value: number, options?: Intl.NumberFormatOptions) => formatAppNumber(value, locale, options), dateFormatter: (options: Intl.DateTimeFormatOptions = APP_DATE.chartDay) => createAppDateFormatter(locale, options), presets: APP_DATE, }), [locale], ); }