improvement: rtl direction, solar calendar and persian formatting added for persian users.
This commit is contained in:
45
frontend/src/lib/hooks/useAppFormatters.ts
Normal file
45
frontend/src/lib/hooks/useAppFormatters.ts
Normal file
@@ -0,0 +1,45 @@
|
||||
'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<typeof formatAppDate>[0], options?: Intl.DateTimeFormatOptions) =>
|
||||
formatAppDate(value, locale, options),
|
||||
formatTime: (value: Parameters<typeof formatAppTime>[0], options?: Intl.DateTimeFormatOptions) =>
|
||||
formatAppTime(value, locale, options),
|
||||
formatDateTime: (
|
||||
value: Parameters<typeof formatAppDateTime>[0],
|
||||
options?: Intl.DateTimeFormatOptions,
|
||||
) => formatAppDateTime(value, locale, options),
|
||||
formatTimeRange: (
|
||||
start: Parameters<typeof formatAppTimeRange>[0],
|
||||
end: Parameters<typeof formatAppTimeRange>[1],
|
||||
options?: Intl.DateTimeFormatOptions,
|
||||
) => formatAppTimeRange(start, end, locale, options),
|
||||
formatTableDate: (value: Parameters<typeof formatAppTableDate>[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],
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user