Skip to content

Commit 281ac8b

Browse files
committed
guarda against firefox lack of weekInfo
1 parent 1ac3349 commit 281ac8b

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

src/components/Calendar/index.jsx

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,21 @@
11
import { React, useEffect, useState } from "react";
22

3-
43
export default function Calendar() {
54
const [state, setState] = useState({
65
firstDay: 1,
7-
timezone: 'UTC',
6+
timezone: "UTC",
87
});
9-
useEffect(() => {
10-
const locale = Intl.DateTimeFormat().resolvedOptions().locale;
11-
const firstDay = (new Intl.Locale(locale)).weekInfo.firstDay + 1;
12-
const timezone = Intl.DateTimeFormat().resolvedOptions().timeZone;
13-
setState({firstDay: firstDay, timezone: timezone});
14-
})
8+
if (Intl) {
9+
useEffect(() => {
10+
const locale = Intl.DateTimeFormat().resolvedOptions().locale;
11+
const firstDay = (new Intl.Locale(locale)?.weekInfo?.firstDay ?? 0) + 1;
12+
const timezone = Intl.DateTimeFormat().resolvedOptions().timeZone;
13+
setState({ firstDay: firstDay, timezone: timezone });
14+
});
15+
}
1516
return (
1617
<iframe
17-
src={ `https://calendar.google.com/calendar/embed?height=500&wkst=${state.firstDay}&ctz=${state.timezone}&showTitle=0&showTz=1&showPrint=0&src=ODgwNTU3MGE0ZTFjYTIzMTk4NDI5NzFkYjQzODBlZDUxOGM0OTA1NzdjMDY0NTRhZGYyMzAzNzM0NTA2ZjM5N0Bncm91cC5jYWxlbmRhci5nb29nbGUuY29t&color=%2333b679` }
18+
src={`https://calendar.google.com/calendar/embed?height=500&wkst=${state.firstDay}&ctz=${state.timezone}&showTitle=0&showTz=1&showPrint=0&src=ODgwNTU3MGE0ZTFjYTIzMTk4NDI5NzFkYjQzODBlZDUxOGM0OTA1NzdjMDY0NTRhZGYyMzAzNzM0NTA2ZjM5N0Bncm91cC5jYWxlbmRhci5nb29nbGUuY29t&color=%2333b679`}
1819
width="100%"
1920
height="500"
2021
frameborder="0"

0 commit comments

Comments
 (0)