From 466b7060d87b7710d5b69f60f147d50196c600cb Mon Sep 17 00:00:00 2001 From: Chteufleur Date: Tue, 29 Sep 2015 21:36:27 +0200 Subject: [PATCH] Fix bug on print horodate on index page --- controllers/default.go | 11 ++++++++++- controllers/viewTemp.go | 5 +---- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/controllers/default.go b/controllers/default.go index 62c5d67..8c57835 100644 --- a/controllers/default.go +++ b/controllers/default.go @@ -7,8 +7,14 @@ import ( "datahouse/models/temperature" "strconv" + "time" ) +var ( + _, timezoneOffset = time.Now().Zone() +) + + type SensorPrint struct { Name string Value string @@ -41,7 +47,10 @@ func getLastTemps() ([]SensorPrint) { sens.Value = strconv.FormatInt(t.Value, 10) sens.Unit = "°C" - sens.Horodate = t.HorodateGMT.Format("04h05") + horodatTmp := t.HorodateGMT + horodatTmp = horodatTmp.Add(time.Duration(timezoneOffset)*time.Second) + h, m, _ := horodatTmp.Clock() + sens.Horodate = strconv.Itoa(h)+"h"+strconv.Itoa(m) values = append(values, *sens) } diff --git a/controllers/viewTemp.go b/controllers/viewTemp.go index 4f833e4..c3b5da1 100644 --- a/controllers/viewTemp.go +++ b/controllers/viewTemp.go @@ -8,12 +8,9 @@ import ( "html/template" "strconv" - "time" ) -var ( - _, timezoneOffset = time.Now().Zone() -) + type ViewTempController struct { beego.Controller