improvement: rtl direction, solar calendar and persian formatting added for persian users.

This commit is contained in:
2026-07-14 01:27:11 +03:30
parent 27eae25f61
commit ec2b23f4b1
50 changed files with 1410 additions and 528 deletions

View 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],
);
}