From b4e38376ea06581ddcc1de5c4aebb20e27198c15 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?O=CC=81scar=20M=2E=20Lage?= Date: Sat, 30 Nov 2024 13:14:29 +0100 Subject: [PATCH] Fix: Format timestamps in CET --- internal/web/templates/view.html | 2 +- internal/web/utils.go | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/internal/web/templates/view.html b/internal/web/templates/view.html index 78dfaf5..5b2ed1b 100644 --- a/internal/web/templates/view.html +++ b/internal/web/templates/view.html @@ -97,7 +97,7 @@ {{range .events}} {{.ID}} - {{.Timestamp}} + {{.Timestamp | formatTimestamp }} {{.EventType}} Editar diff --git a/internal/web/utils.go b/internal/web/utils.go index 1a68151..48f7cc0 100644 --- a/internal/web/utils.go +++ b/internal/web/utils.go @@ -57,6 +57,11 @@ func LoadTemplate(c echo.Context, templateName string, data interface{}) error { funcs := template.FuncMap{ "date": FormatDate, // Asignamos la función FormatDate con el nombre "date" "json": ToJson, // Agregamos la función ToJson con el nombre "json" + "formatTimestamp": func(t time.Time) string { + location, _ := time.LoadLocation("Europe/Madrid") + localTime := t.In(location) + return localTime.Format("2006-01-02 15:04 (MST)") + }, } // Cargar las plantillas desde los directorios