Skip to content

Commit

Permalink
Refactor timezone detection and formatting functions
Browse files Browse the repository at this point in the history
  • Loading branch information
teetangh committed Dec 12, 2024
1 parent e48fcd1 commit bac34ff
Show file tree
Hide file tree
Showing 3 changed files with 354 additions and 161 deletions.
21 changes: 21 additions & 0 deletions app/explore/experts/[consultantId]/hooks/useTimezone.ts
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 };
}
Loading

0 comments on commit bac34ff

Please sign in to comment.