Skip to content

Commit

Permalink
guard against firefox lack of weekInfo
Browse files Browse the repository at this point in the history
  • Loading branch information
jaimergp committed Nov 6, 2024
1 parent d347767 commit 0d82519
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ repos:
# verify github syntaxes
- id: check-github-workflows
- repo: https://github.com/codespell-project/codespell
# see setup.cfg
# see pyproject.toml
rev: v2.3.0
hooks:
- id: codespell
Expand Down
14 changes: 8 additions & 6 deletions src/components/Calendar/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,14 @@ export default function Calendar() {
firstDay: 1,
timezone: "UTC",
});
useEffect(() => {
const locale = Intl.DateTimeFormat().resolvedOptions().locale;
const firstDay = new Intl.Locale(locale).weekInfo.firstDay + 1;
const timezone = Intl.DateTimeFormat().resolvedOptions().timeZone;
setState({ firstDay: firstDay, timezone: timezone });
});
if (Intl) {
useEffect(() => {
const locale = Intl.DateTimeFormat().resolvedOptions().locale;
const firstDay = ((new Intl.Locale(locale))?.weekInfo?.firstDay ?? 0) + 1;
const timezone = Intl.DateTimeFormat().resolvedOptions().timeZone;
setState({firstDay: firstDay, timezone: timezone});
})
}
return (
<iframe
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`}
Expand Down

0 comments on commit 0d82519

Please sign in to comment.