glanceapp/glance · error
hour-format must be either 12h or 24h
Error message
hour-format must be either 12h or 24h
What it means
Returned by weatherWidget.initialize() during config parsing when the twitch weather widget's hour-format value is neither empty, '12h', nor '24h'. The field selects which hour labels the hourly forecast uses; anything else is rejected at startup so the config author notices immediately. The error is wrapped by formatWidgetInitError into 'weather widget: hour-format must be either 12h or 24h'.
Source
Thrown at internal/glance/widget-weather.go:47
TimeLabels [12]string `yaml:"-"`
}
var timeLabels12h = [12]string{"2am", "4am", "6am", "8am", "10am", "12pm", "2pm", "4pm", "6pm", "8pm", "10pm", "12am"}
var timeLabels24h = [12]string{"02:00", "04:00", "06:00", "08:00", "10:00", "12:00", "14:00", "16:00", "18:00", "20:00", "22:00", "00:00"}
func (widget *weatherWidget) initialize() error {
widget.withTitle("Weather").withCacheOnTheHour()
if widget.Location == "" {
return fmt.Errorf("location is required")
}
if widget.HourFormat == "" || widget.HourFormat == "12h" {
widget.TimeLabels = timeLabels12h
} else if widget.HourFormat == "24h" {
widget.TimeLabels = timeLabels24h
} else {
return errors.New("hour-format must be either 12h or 24h")
}
if widget.Units == "" {
widget.Units = "metric"
} else if widget.Units != "metric" && widget.Units != "imperial" {
return errors.New("units must be either metric or imperial")
}
return nil
}
func (widget *weatherWidget) update(ctx context.Context) {
if widget.Place == nil {
place, err := fetchOpenMeteoPlaceFromName(widget.Location)
if err != nil {
widget.withError(err).scheduleEarlyUpdate()
return
}View on GitHub (pinned to 91324e8de7)
Solutions
- Set hour-format: 12h or hour-format: 24h exactly (lowercase, with the h suffix), or remove the key entirely to default to 12h.
- Validate the whole file before serving with `glance config:validate --config glance.yml` (or `glance config:print`) to catch typos.
- Check for stray quoting/casing in YAML (e.g. '24H') and correct it.
Example fix
// glance.yml (before) - type: weather location: Berlin, Germany hour-format: 24H // after - type: weather location: Berlin, Germany hour-format: 24h
Defensive patterns
Strategy: validation
Validate before calling
# in CI or a pre-deploy hook: grep -n 'hour-format:' glance.yml | grep -vE 'hour-format:\s*(12h|24h)\s*$' && echo 'BAD hour-format' && exit 1 || echo ok
Prevention
- Only use '12h' or '24h' (or omit) — copy from the official docs.
- Run `glance config:validate` in CI for every config change.
When it happens
Trigger: YAML config contains a widget of type weather with hour-format set to e.g. '12H', '24', '12-hour', 'h12', or any typo — any string other than '', '12h', '24h' hits the else branch and errors.
Common situations: Copy-pasting config from docs that use a different casing; writing '24H' uppercase; assuming 'h:24' or numeric 24 is accepted; hand-editing glance.yml and forgetting the exact allowed literals.
Related errors
- location is required
- URL is required
- nested groups are not supported
- split columns inside of groups are not supported
- source is required
AI-assisted analysis of glanceapp/glance@91324e8de7 (2026-08-15).
Data as JSON: /api/errors/0f07f78293dc7628.
Report an issue: GitHub.