1 | import React from "react";
|
2 |
|
3 | import { format } from "date-fns";
|
4 | import { arSA } from "date-fns/locale";
|
5 | import { DayPicker, FormatOptions } from "react-day-picker";
|
6 |
|
7 | const NU_LOCALE = "ar-u-nu-arab";
|
8 |
|
9 | const formatDay = (day: Date) => day.getDate().toLocaleString(NU_LOCALE);
|
10 |
|
11 | const formatWeekNumber = (weekNumber: number) => {
|
12 | return weekNumber.toLocaleString(NU_LOCALE);
|
13 | };
|
14 |
|
15 | const formatMonthCaption = (date: Date, options: FormatOptions | undefined) => {
|
16 | const y = date.getFullYear().toLocaleString(NU_LOCALE);
|
17 | const m = format(date, "LLLL", { locale: options?.locale });
|
18 | return `${m} ${y}`;
|
19 | };
|
20 |
|
21 | export function NumberingSystem() {
|
22 | return (
|
23 | <DayPicker
|
24 | locale={arSA}
|
25 | dir="rtl"
|
26 | showWeekNumber
|
27 | formatters={{ formatDay, formatMonthCaption, formatWeekNumber }}
|
28 | />
|
29 | );
|
30 | }
|