Fix uptime being inaccurate.
All checks were successful
Build and push container image / build (push) Successful in 39s
All checks were successful
Build and push container image / build (push) Successful in 39s
This commit is contained in:
parent
e41be91a4c
commit
bfe787b632
@ -1,9 +1,6 @@
|
|||||||
package toolbox
|
package toolbox
|
||||||
|
|
||||||
import (
|
import "time"
|
||||||
"fmt"
|
|
||||||
"time"
|
|
||||||
)
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
System/OS-related utilities such as uptime.
|
System/OS-related utilities such as uptime.
|
||||||
@ -18,10 +15,5 @@ var timerStart = time.Now()
|
|||||||
func GetUptime() string {
|
func GetUptime() string {
|
||||||
uptime := time.Since(timerStart)
|
uptime := time.Since(timerStart)
|
||||||
roundedUp := uptime.Round(time.Second)
|
roundedUp := uptime.Round(time.Second)
|
||||||
days := roundedUp / (24 * time.Hour)
|
|
||||||
hours := roundedUp % (24 * time.Hour) / time.Hour
|
|
||||||
if days > 0 {
|
|
||||||
return fmt.Sprintf("%dd,%dh", days, hours)
|
|
||||||
}
|
|
||||||
return roundedUp.String()
|
return roundedUp.String()
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user