glanceapp/glance · error
invalid timezone '%s': %v
Error message
invalid timezone '%s': %v
What it means
Returned by the clock widget's Initialize when time.LoadLocation rejects one of the configured timezone strings. LoadLocation resolves names against the IANA Time Zone database and fails on misspelled names, non-IANA names, or when no tz database is available in the binary/container.
Source
Thrown at internal/glance/widget-clock.go:37
} `yaml:"timezones"`
}
func (widget *clockWidget) initialize() error {
widget.withTitle("Clock").withError(nil)
if widget.HourFormat == "" {
widget.HourFormat = "24h"
} else if widget.HourFormat != "12h" && widget.HourFormat != "24h" {
return errors.New("hour-format must be either 12h or 24h")
}
for t := range widget.Timezones {
if widget.Timezones[t].Timezone == "" {
return errors.New("missing timezone value")
}
if _, err := time.LoadLocation(widget.Timezones[t].Timezone); err != nil {
return fmt.Errorf("invalid timezone '%s': %v", widget.Timezones[t].Timezone, err)
}
}
widget.cachedHTML = widget.renderTemplate(widget, clockWidgetTemplate)
return nil
}
func (widget *clockWidget) Render() template.HTML {
return widget.cachedHTML
}
View on GitHub (pinned to 91324e8de7)
Solutions
- Use full IANA names: America/New_York, Europe/Berlin, Asia/Kolkata, UTC.
- If running in a minimal container, install tzdata (apk add tzdata / apt-get install tzdata) or blank-import time/tzdata.
- Validate each entry with `go run` one-liner time.LoadLocation or a site like zoneinfo before adding to config.
- Remember hour-format must also be 12h or 24h — a bad value raises a separate error in the same function.
Example fix
# before timezones: - timezone: PST # after timezones: - timezone: America/Los_Angeles # main.go (container without zoneinfo) import _ "time/tzdata"
Defensive patterns
Strategy: validation
Validate before calling
func validTimezones(ts []clockTimezone) error {
for _, t := range ts {
if t.Timezone == "" {
return errors.New("missing timezone value")
}
if _, err := time.LoadLocation(t.Timezone); err != nil {
return fmt.Errorf("invalid timezone %q: use IANA names like Europe/Berlin", t.Timezone)
}
}
return nil
} Try / catch
if _, err := time.LoadLocation(tz); err != nil {
slog.Warn("falling back to UTC", "timezone", tz, "error", err)
tz = "UTC"
} Prevention
- Use IANA zone names only (America/New_York, not EST/NY).
- In minimal containers, install tzdata or blank-import _ "time/tzdata".
- Lint config at deploy time by running LoadLocation over every timezone value.
When it happens
Trigger: timezones: [{timezone: "EST"}] (deprecated abbreviation, not a valid IANA name), "New_York" without the region prefix, "GMT+2" style, or a valid name like "Europe/Berlin" inside a scratch/distroless Docker image lacking /usr/share/zoneinfo.
Common situations: Users copy abbreviations (PST, CEST) instead of IANA names; glance deployed in a minimal container without tzdata; typo in YAML; Alpine-based image without the tzdata package.
Related errors
- loading location: %v
- invalid first day of week
- invalid body type, must be either 'json' or 'string'
- URL is required
- nested groups are not supported
AI-assisted analysis of glanceapp/glance@91324e8de7 (2026-08-15).
Data as JSON: /api/errors/ac7addd3cbef9e52.
Report an issue: GitHub.