feat: autofill client timezone based on user timezone

This commit is contained in:
Hussain Nagaria
2025-03-03 22:42:43 +05:30
parent f19e974b9d
commit fa1621c3d1
2 changed files with 22 additions and 2 deletions

View File

@@ -441,6 +441,22 @@ export function getTimezones() {
]
}
export function getUserTimezone() {
try {
const timezone = Intl.DateTimeFormat().resolvedOptions().timeZone
const supportedTimezones = getTimezones()
if (supportedTimezones.includes(timezone)) {
return timezone // e.g., 'Asia/Calcutta', 'America/New_York', etc.
} else {
throw Error('unsupported timezone')
}
} catch (error) {
console.error('Error getting timezone:', error)
return null
}
}
export function getSidebarLinks() {
return [
{