File tree Expand file tree Collapse file tree 1 file changed +10
-9
lines changed Expand file tree Collapse file tree 1 file changed +10
-9
lines changed Original file line number Diff line number Diff line change 1
1
import { React , useEffect , useState } from "react" ;
2
2
3
-
4
3
export default function Calendar ( ) {
5
4
const [ state , setState ] = useState ( {
6
5
firstDay : 1 ,
7
- timezone : ' UTC' ,
6
+ timezone : " UTC" ,
8
7
} ) ;
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
+ }
15
16
return (
16
17
< 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` }
18
19
width = "100%"
19
20
height = "500"
20
21
frameborder = "0"
You can’t perform that action at this time.
0 commit comments