diff options
author | Matthew Heon <matthew.heon@gmail.com> | 2018-02-19 11:22:23 -0500 |
---|---|---|
committer | Atomic Bot <atomic-devel@projectatomic.io> | 2018-02-19 19:19:07 +0000 |
commit | 635deb63586fdfb41a7595ef667ce1546bf5f9e2 (patch) | |
tree | 56411e0283f640f41237eab801a835eddb34cc84 | |
parent | 32efbbdf8a2a3caf628adeef7c0ad49ad8de2c88 (diff) | |
download | podman-635deb63586fdfb41a7595ef667ce1546bf5f9e2.tar.gz podman-635deb63586fdfb41a7595ef667ce1546bf5f9e2.tar.bz2 podman-635deb63586fdfb41a7595ef667ce1546bf5f9e2.zip |
Change uptime format in `podman info` to human-readable
Signed-off-by: Matthew Heon <matthew.heon@gmail.com>
Closes: #355
Approved by: rhatdan
-rw-r--r-- | libpod/info.go | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/libpod/info.go b/libpod/info.go index 8a77c2ab7..ab2865e85 100644 --- a/libpod/info.go +++ b/libpod/info.go @@ -6,6 +6,7 @@ import ( "io/ioutil" "os" "runtime" + "time" "github.com/docker/docker/pkg/system" "github.com/pkg/errors" @@ -44,7 +45,13 @@ func (r *Runtime) hostInfo() (map[string]interface{}, error) { if err != nil { return nil, errors.Wrapf(err, "error reading up time") } - info["uptime"] = up + // Convert uptime in seconds to a human-readable format + upSeconds := up + "s" + upDuration, err := time.ParseDuration(upSeconds) + if err != nil { + return nil, errors.Wrapf(err, "error parsing system uptime") + } + info["uptime"] = upDuration.String() host, err := os.Hostname() if err != nil { |