Fix bug on print horodate on index page
This commit is contained in:
parent
6c03e63e62
commit
466b7060d8
|
|
@ -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)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,12 +8,9 @@ import (
|
|||
|
||||
"html/template"
|
||||
"strconv"
|
||||
"time"
|
||||
)
|
||||
|
||||
var (
|
||||
_, timezoneOffset = time.Now().Zone()
|
||||
)
|
||||
|
||||
|
||||
type ViewTempController struct {
|
||||
beego.Controller
|
||||
|
|
|
|||
Loading…
Reference in New Issue