From 0d825194c50c50ccca85213514f16e37c84dfe6c Mon Sep 17 00:00:00 2001 From: jaimergp Date: Wed, 6 Nov 2024 15:12:14 +0100 Subject: [PATCH] guard against firefox lack of weekInfo --- .pre-commit-config.yaml | 2 +- src/components/Calendar/index.jsx | 14 ++++++++------ 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index b4e2771..2e624bd 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -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 diff --git a/src/components/Calendar/index.jsx b/src/components/Calendar/index.jsx index 90a6bca..34f3724 100644 --- a/src/components/Calendar/index.jsx +++ b/src/components/Calendar/index.jsx @@ -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 (