toast
7e486cb8ce
All checks were successful
Build and push container image / build (push) Successful in 41s
28 lines
519 B
Go
28 lines
519 B
Go
package toolbox
|
|
|
|
import (
|
|
"fmt"
|
|
"time"
|
|
)
|
|
|
|
/*
|
|
System/OS-related utilities such as uptime.
|
|
*/
|
|
|
|
var timerStart = time.Now()
|
|
|
|
/*
|
|
Nor the Go or the Disgo library has a built-in
|
|
Client/Process uptime function, so I had to get creative.
|
|
*/
|
|
func GetUptime() string {
|
|
uptime := time.Since(timerStart)
|
|
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()
|
|
}
|