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