Repository navigation
fix(core): name the box's time zone instead of "Local" - #1585
Conversation
Go names the host zone "Local" when TZ is unset. Core sent that name in the app hello, /api/energy/daily, /api/savings/daily and the load research export, and clients cannot load it. Move the resolver forecastTimezone() already used into internal/localzone so cmd/ftw and api share it, and read it once per process to match time.Local. A child-process test runs a real hello with no TZ and checks hello_ok.box.tz loads. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 3f1217ae2d
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if target, err := filepath.EvalSymlinks(localtime); err == nil { | ||
| if _, zone, ok := strings.Cut(target, "/zoneinfo/"); ok { | ||
| candidates = append(candidates, zone) | ||
| } |
There was a problem hiding this comment.
Preserve zones stored in a regular /etc/localtime file
When a host configures its zone by copying a tzfile to /etc/localtime rather than symlinking it, and has no /etc/timezone or TZ setting, Go still uses the copied rules through time.Local, but this resolver cannot extract a name and falls back to UTC. The daily endpoints then calculate buckets in the actual local zone while labeling them UTC, and the app renders plan times in UTC. Compare the regular file against the installed zoneinfo tree (or otherwise avoid returning a confidently incorrect fallback) before reporting UTC.
Useful? React with 👍 / 👎.
Problem
Core reports the box's time zone with
time.Now().Location().String(),loc.String()ortime.Local.String(). WhenTZis unset, Go names the host zoneLocal, not an IANA name. Clients that passLocaltotime.LoadLocationorIntlget nothing useful.This hits the
tzfield in the app protocol hello. The iOS app and the web client use it to show plan times in the box's zone, so on a box withoutTZthey cannot. It also hitstzin/api/energy/dailyand/api/savings/daily, andtimezonein the load research export.Change
go/internal/localzone.localzone.Name()returns the IANA name of the box's zone, orUTC. It is the resolverforecastTimezone()already used (TZ, the/etc/localtimelink,/etc/timezone), moved socmd/ftwandapishare it. No second resolver.time.Localis fixed at start, so a zone changed on the host later must not rename the one the box still runs on.localzone.Name(). The forecast and planner callers offorecastTimezone()call it too, with the same result as before, so forecast learning revisions do not change.Independent of #1582. That PR keeps the EV ready time on the household clock; this one lets clients learn which clock that is.
Evidence
TestTheHelloNamesTheBoxZoneWhenTZIsUnsetruns a real hello throughappprotoin a child process with noTZin its environment. It first checks thattime.Localis Go's unnamedLocal, then thathello_ok.box.tzis a nametime.LoadLocationaccepts. With the old line innewAppBoxInfoit fails withhello tz = "Local".localzonetests cover aTZvalue, an unknownTZ, the/etc/localtimelink,/etc/timezoneand a host that names no zone (UTC), using fake host files.make verifypasses locally (macOS).Not in this PR
Clients may still hold a cached
Localfrom an older box. TreatingLocalas "zone unknown" is a client change, if wanted.🤖 Generated with Claude Code