Skip to content

Commit cfc4373

Browse files
committed
fix(persian): scope narrow weekday formatter to fa locales
1 parent 8833e1b commit cfc4373

2 files changed

Lines changed: 15 additions & 3 deletions

File tree

examples/PersianEn.test.tsx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,10 @@ test("should render 6 rows", () => {
1717
render(<PersianEn />);
1818
expect(screen.getAllByRole("row")).toHaveLength(6);
1919
});
20+
21+
test("should render English short weekday labels", () => {
22+
render(<PersianEn />);
23+
expect(
24+
screen.getByRole("columnheader", { name: "Thursday", hidden: true }),
25+
).toHaveTextContent("Th");
26+
});

src/persian.tsx

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,16 +91,21 @@ export function DayPicker(
9191
noonSafe,
9292
overrides: dateLibProp,
9393
});
94+
const locale = localeProp ?? faIR;
95+
9496
return (
9597
<DayPickerComponent
9698
{...restProps}
97-
locale={localeProp ?? faIR}
99+
locale={locale}
98100
numerals={numerals ?? "arabext"}
99101
dir={dir ?? "rtl"}
100102
dateLib={dateLib}
101103
formatters={{
102-
formatWeekdayName: (date, _options, lib) =>
103-
(lib ?? dateLib).format(date, "ccccc"),
104+
formatWeekdayName: (date, _options, lib) => {
105+
const activeLib = lib ?? dateLib;
106+
const isPersian = activeLib.options.locale?.code?.startsWith("fa");
107+
return activeLib.format(date, isPersian ? "ccccc" : "cccccc");
108+
},
104109
...props.formatters,
105110
}}
106111
/>

0 commit comments

Comments
 (0)