summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTomSweeneyRedHat <tsweeney@redhat.com>2018-02-24 19:54:41 -0500
committerAtomic Bot <atomic-devel@projectatomic.io>2018-02-28 18:06:50 +0000
commit85ece8a01fbfcfb376c4f79926d205044532b738 (patch)
treefbe591123e3eef9faec8d4a4790753954d47400c
parent7ffc89d71a65da32c74cf6ec3aeb99b0d547ebd1 (diff)
downloadpodman-85ece8a01fbfcfb376c4f79926d205044532b738.tar.gz
podman-85ece8a01fbfcfb376c4f79926d205044532b738.tar.bz2
podman-85ece8a01fbfcfb376c4f79926d205044532b738.zip
Tweak info time format
Signed-off-by: TomSweeneyRedHat <tsweeney@redhat.com> Closes: #397 Approved by: rhatdan
-rw-r--r--libpod/info.go27
1 files changed, 26 insertions, 1 deletions
diff --git a/libpod/info.go b/libpod/info.go
index ab2865e85..03919eb1a 100644
--- a/libpod/info.go
+++ b/libpod/info.go
@@ -6,6 +6,7 @@ import (
"io/ioutil"
"os"
"runtime"
+ "strconv"
"time"
"github.com/docker/docker/pkg/system"
@@ -51,7 +52,31 @@ func (r *Runtime) hostInfo() (map[string]interface{}, error) {
if err != nil {
return nil, errors.Wrapf(err, "error parsing system uptime")
}
- info["uptime"] = upDuration.String()
+
+ hoursFound := false
+ var timeBuffer bytes.Buffer
+ var hoursBuffer bytes.Buffer
+ for _, elem := range upDuration.String() {
+ timeBuffer.WriteRune(elem)
+ if elem == 'h' || elem == 'm' {
+ timeBuffer.WriteRune(' ')
+ if elem == 'h' {
+ hoursFound = true
+ }
+ }
+ if !hoursFound {
+ hoursBuffer.WriteRune(elem)
+ }
+ }
+
+ info["uptime"] = timeBuffer.String()
+ if hoursFound {
+ hours, err := strconv.ParseFloat(hoursBuffer.String(), 64)
+ if err == nil {
+ days := hours / 24
+ info["uptime"] = fmt.Sprintf("%s (Approximately %.2f days)", info["uptime"], days)
+ }
+ }
host, err := os.Hostname()
if err != nil {