diff options
Diffstat (limited to 'internal')
| -rw-r--r-- | internal/server/server.go | 26 | ||||
| -rw-r--r-- | internal/server/templates/index.html | 13 |
2 files changed, 35 insertions, 4 deletions
diff --git a/internal/server/server.go b/internal/server/server.go index 6b7fbfb..35eb6fb 100644 --- a/internal/server/server.go +++ b/internal/server/server.go @@ -1495,24 +1495,42 @@ func formatUptimeTooltip(uptimePercent float64, totalChecks int64, lastFailure * // formatVersionTooltip creates JSON data for version tooltip func (s *Server) formatVersionTooltip() string { + timezone := s.config.Display.Timezone + useBrowserTz := timezone == "Browser" + rows := []map[string]string{ {"label": "Version", "value": s.version.Version, "class": ""}, {"label": "Commit", "value": s.version.Commit, "class": ""}, } + data := map[string]interface{}{ + "header": "Kaze", + } + // Parse and format build date if available if s.version.Date != "" && s.version.Date != "unknown" { if t, err := time.Parse(time.RFC3339, s.version.Date); err == nil { + // Include raw timestamp for browser timezone conversion + if useBrowserTz { + data["timestamp"] = t.Format(time.RFC3339) + data["timestampLabel"] = "Built" + } + + // Convert to configured timezone for server-side rendering + loc := time.Local + if timezone != "" && timezone != "Local" && timezone != "Browser" { + if l, err := time.LoadLocation(timezone); err == nil { + loc = l + } + } + t = t.In(loc) rows = append(rows, map[string]string{"label": "Built", "value": t.Format("Jan 2, 2006 15:04"), "class": ""}) } else { rows = append(rows, map[string]string{"label": "Built", "value": s.version.Date, "class": ""}) } } - data := map[string]interface{}{ - "header": "Kaze", - "rows": rows, - } + data["rows"] = rows b, _ := json.Marshal(data) return string(b) diff --git a/internal/server/templates/index.html b/internal/server/templates/index.html index 35f08c1..684819d 100644 --- a/internal/server/templates/index.html +++ b/internal/server/templates/index.html @@ -295,6 +295,19 @@ }); } } + // Convert version tooltip build date to browser timezone + if (data.timestamp && data.timestampLabel) { + const date = new Date(data.timestamp); + const formatted = date.toLocaleDateString('en-US', { year: 'numeric', month: 'short', day: 'numeric' }) + ' ' + + date.toLocaleTimeString('en-US', { hour: '2-digit', minute: '2-digit', hour12: false }); + if (data.rows) { + data.rows.forEach(function(row) { + if (row.label === data.timestampLabel) { + row.value = formatted; + } + }); + } + } {{end}} let html = '<span class="tooltip-header">' + data.header + '</span>'; |