local-time: the panel in the container's zone, named on Settings

Agreed by the owner on 2026-10-13 (the local day, no "UTC" beside a
time); the zone is the container's TZ in .env and Settings only shows it,
his "Да" of 2026-10-17. Mockups c205106.

Every time the panel shows is formatted in time.Local and says no zone:
the logs' Time and the DMARC Received columns, a message's timeline,
Overview's "Updated", Health's certificate and renewal, the filter lists,
DMARC reports and windows, the auto limit's last recalculation. Stored
instants stay UTC. The days counted are the zone's: delivery_log_days and
sender_check_days key their rows by the local date, the sender check cuts
downtime at local midnights (byDay), the log filters' days run from local
midnight to local midnight. Notification mail and the test message write
the zone's abbreviation after a time - they are read away from the panel.
DMARC's one-day window label stays the reporter's (UTC) day.

Settings box 05, Time zone, read-only: the name (UTC without TZ), its
offset, and a TZ the image cannot load said to leave the times in UTC
(time/zoneinfo_unix.go, initLocal) rather than named. TZ is passed by the
compose file ("${TZ:-}"), in .env.example and the guide's table; tzdata is
named in the image (supervisor's python3.13 brings it today). Postfix
takes TZ through import_environment, so mail.log's stamps are the same
zone, which closes the trap the roadmap wrote down: the tailer has always
read them in time.Local.

Tests: a TestMain runs view, handlers, store and cmd/panel in UTC whatever
the machine's zone (as logtail's); TestSettingsShowsTheTimeZone,
TestTimesAreTheContainersZone, TestByDayInTheContainersZone, a Moscow day
in TestQueryInboundSpamFilters; envdoc's pattern takes two-letter names.
e2e time_zone_is_the_containers recreates the stand with
TZ=Europe/Moscow: date says MSK, Settings names the zone and UTC+03:00, a
test message's page gives its time and its mail.log lines in Moscow's.
go vet + go test (26 packages) and make e2e on the test server for this
tree.

Docs: guide (§ Settings, the TZ row, the days of Health and the logs),
architecture, schema-migrations, help (word for word with the mockup),
CHANGELOG [Unreleased] § Added, roadmap row done with the decision.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
mix
2026-10-17 01:34:28 +03:00
co-authored by Claude Opus 5.5
parent c205106418
commit bdeb01681d
58 changed files with 484 additions and 117 deletions
+35 -1
View File
@@ -6,7 +6,12 @@ package view
// user's own — who they are to the panel and their password — and every role
// has it. Settings is the instance's.
import "strconv"
import (
"fmt"
"strconv"
"strings"
"time"
)
// Account is the data of the Account page. Two forms, each its own POST: the
// profile (Username, Email) and the password. The fields hold what was stored,
@@ -78,6 +83,11 @@ type Settings struct {
// are signed and authorised with, drawn like a domain's.
Mail Box
MailRecords []Record
// TimeZone names the container's zone, which every time and day the
// panel shows is in; it is set in .env, so the box only shows it.
TimeZone Box
ZoneFacts []Fact
}
// NewSettings builds the page. retention is what the field shows (the stored
@@ -106,6 +116,7 @@ func NewSettings(m Meta, retention, level1 string) *Settings {
Notifications: Box{No: "02", Title: "Notifications", ID: "notifications", Help: topicLink(HelpNotifications, "What is sent and when")},
Mail: Box{No: "03", Title: "Notification mail", ID: "notification-mail", End: Plain("DNS records of the server's own name"),
Help: topicLink(HelpNotifications, "What the panel sends and what makes it arrive")},
TimeZone: Box{No: "05", Title: "Time zone", ID: "time-zone", End: Plain("Read-only"), Help: topicLink(HelpSettings, "Times and days of the panel")},
}
}
@@ -133,6 +144,29 @@ func (s *Settings) WithMail(records []Record, checked string) *Settings {
return s
}
// WithTimeZone names the zone: tz is TZ as the container has it ("" is UTC,
// Go's and the C library's default), loc the zone the process took from it
// (time.Local), at now for its offset. A TZ Go cannot load leaves time.Local
// UTC (time/zoneinfo_unix.go, initLocal), and the box says so rather than name
// a zone the times are not in.
func (s *Settings) WithTimeZone(tz string, loc *time.Location, now time.Time) *Settings {
name := strings.TrimPrefix(tz, ":")
if name == "" {
name = "UTC"
}
_, offset := now.In(loc).Zone()
sign := "+"
if offset < 0 {
sign, offset = "-", -offset
}
note := Rich(fmt.Sprintf("UTC%s%02d:%02d. Set in ", sign, offset/3600, offset%3600/60), Code(".env"), " (", Code("TZ"), "); restart to change.")
if name != "UTC" && loc.String() != name {
note = Rich("Not a zone this image knows, so the times are UTC. Set in ", Code(".env"), " (", Code("TZ"), "); restart to change.")
}
s.ZoneFacts = []Fact{{Label: "Zone", Value: Plain(name), Mono: true, Note: note}}
return s
}
// WithInbound adds the retention of the Inbound log to the Log retention box.
// days is what the field shows, like retention in NewSettings. The field exists
// only while the inbound relay is on: with it off there is no journal to keep.