Skip to content

Commit f064747

Browse files
authored
Fix Calendar when Saturday or Sunday are the first day of the week (#2358)
1 parent 9212a4a commit f064747

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/components/Calendar/index.jsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,11 @@ export default function Calendar() {
99
useEffect(() => {
1010
if (Intl) {
1111
const locale = Intl.DateTimeFormat().resolvedOptions().locale;
12-
setFirstDay((new Intl.Locale(locale)?.weekInfo?.firstDay ?? 0) + 1);
12+
// firstDay API returns 1 for Monday and 7 for Sunday
13+
// Google Calendar expects 1 for Sunday and 6 for Saturday
14+
let day = (new Intl.Locale(locale)?.weekInfo?.firstDay ?? 0) + 1;
15+
if (day === 8) day = 1; // Sunday
16+
setFirstDay(day);
1317
setTimezone(Intl.DateTimeFormat().resolvedOptions().timeZone);
1418
}
1519
setThemeMode(colorMode);

0 commit comments

Comments
 (0)