Improve time percentage

This commit is contained in:
Florian Hoss 2022-10-27 18:41:18 +02:00
parent 57f9ed454f
commit b3bf334bae
2 changed files with 7 additions and 7 deletions

View file

@ -18,9 +18,9 @@ type LiveInformation struct {
type Uptime struct {
Days uint64 `json:"days"`
Hours uint8 `json:"hours"`
Minutes uint8 `json:"minutes"`
Seconds uint8 `json:"seconds"`
Hours uint16 `json:"hours"`
Minutes uint16 `json:"minutes"`
Seconds uint16 `json:"seconds"`
Percentage float32 `json:"percentage"`
}

View file

@ -10,8 +10,8 @@ func (s *System) uptime() {
return
}
s.Live.Uptime.Days = i.Uptime / 84600
s.Live.Uptime.Hours = uint8((i.Uptime % 86400) / 3600)
s.Live.Uptime.Minutes = uint8(((i.Uptime % 86400) % 3600) / 60)
s.Live.Uptime.Seconds = uint8(((i.Uptime % 86400) % 3600) % 60)
s.Live.Uptime.Percentage = float32(s.Live.Uptime.Minutes) / 60 * 100
s.Live.Uptime.Hours = uint16((i.Uptime % 86400) / 3600)
s.Live.Uptime.Minutes = uint16(((i.Uptime % 86400) % 3600) / 60)
s.Live.Uptime.Seconds = uint16(((i.Uptime % 86400) % 3600) % 60)
s.Live.Uptime.Percentage = float32((s.Live.Uptime.Minutes*100)+s.Live.Uptime.Seconds) / 60
}