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"
|
"datahouse/models/temperature"
|
||||||
|
|
||||||
"strconv"
|
"strconv"
|
||||||
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
_, timezoneOffset = time.Now().Zone()
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
type SensorPrint struct {
|
type SensorPrint struct {
|
||||||
Name string
|
Name string
|
||||||
Value string
|
Value string
|
||||||
|
|
@ -41,7 +47,10 @@ func getLastTemps() ([]SensorPrint) {
|
||||||
sens.Value = strconv.FormatInt(t.Value, 10)
|
sens.Value = strconv.FormatInt(t.Value, 10)
|
||||||
sens.Unit = "°C"
|
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)
|
values = append(values, *sens)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -8,12 +8,9 @@ import (
|
||||||
|
|
||||||
"html/template"
|
"html/template"
|
||||||
"strconv"
|
"strconv"
|
||||||
"time"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
|
||||||
_, timezoneOffset = time.Now().Zone()
|
|
||||||
)
|
|
||||||
|
|
||||||
type ViewTempController struct {
|
type ViewTempController struct {
|
||||||
beego.Controller
|
beego.Controller
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue