Preferences: Add API validation and update documentation (#116045)

This commit is contained in:
Stephanie Hingtgen
2026-01-09 03:57:15 -07:00
committed by GitHub
parent 368762c026
commit 5f8668b3aa
14 changed files with 142 additions and 44 deletions
+21
View File
@@ -0,0 +1,21 @@
package pref
import (
"time"
)
// IsValidTimezone checks if the timezone string is valid.
// It accepts:
// - "" - uses default
// - "utc"
// - "browser"
// - Any valid IANA timezone (e.g., "America/New_York", "Europe/London")
func IsValidTimezone(timezone string) bool {
if timezone == "" || timezone == "utc" || timezone == "browser" {
return true
}
// try to load as IANA timezone
_, err := time.LoadLocation(timezone)
return err == nil
}