-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor timezone detection and formatting functions
- Loading branch information
Showing
3 changed files
with
354 additions
and
161 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { useState, useEffect } from 'react'; | ||
|
||
export function useTimezone() { | ||
const [timezone, setTimezone] = useState<string | null>(null); | ||
const [isLoading, setIsLoading] = useState(true); | ||
|
||
useEffect(() => { | ||
try { | ||
// Get timezone on client side | ||
const browserTimezone = Intl.DateTimeFormat().resolvedOptions().timeZone; | ||
console.log('Browser timezone detected:', browserTimezone); | ||
setTimezone(browserTimezone); | ||
} catch (error) { | ||
console.error('Error detecting timezone:', error); | ||
} finally { | ||
setIsLoading(false); | ||
} | ||
}, []); | ||
|
||
return { timezone, isLoading }; | ||
} |
Oops, something went wrong.