Skip to content

Commit

Permalink
use proper time in landscape mode
Browse files Browse the repository at this point in the history
  • Loading branch information
CubicrootXYZ committed May 30, 2024
1 parent bd4a850 commit 162cc99
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion internal/shiftnotifier/webview.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"net/http"
"strings"
"text/template"
"time"

_ "embed"
)
Expand Down Expand Up @@ -85,6 +86,16 @@ func (service *service) serveHumanLandscape(w http.ResponseWriter, r *http.Reque
return
}

defaultTZ, err := time.LoadLocation("Europe/Berlin")
if err != nil {
defaultTZ = time.Local
}

timeStr := service.latestDiffs.ReferenceTime.
Add(service.config.NotifyBeforeShiftStart).
In(defaultTZ).
Format("Mon, 15:04")

tmpl, err := template.New("landscape").Parse(landscapeTemplate)
if err != nil {
w.WriteHeader(http.StatusInternalServerError)
Expand All @@ -94,7 +105,7 @@ func (service *service) serveHumanLandscape(w http.ResponseWriter, r *http.Reque
err = tmpl.Execute(w, map[string]any{
"data": service.latestDiffs,
"refresh_seconds": r.URL.Query().Get("refresh_seconds"),
"shift_time": service.latestDiffs.ReferenceTime.Format("Mon, 15:04"),
"shift_time": timeStr,
})
if err != nil {
w.WriteHeader(http.StatusInternalServerError)
Expand Down

0 comments on commit 162cc99

Please sign in to comment.