From 4c7bab9812b95fed8e6f8255b51b843b3e762782 Mon Sep 17 00:00:00 2001 From: umohnani8 Date: Tue, 23 Jan 2018 13:34:22 -0500 Subject: Fixed Created At and Running For value Changed the Created At value to match the format of docker ps and fixed the value for Running For to reflect the time elapsed since the container has been started. Initially it was showing the time elapsed since the container was created. Signed-off-by: umohnani8 Closes: #257 Approved by: rhatdan --- cmd/podman/ps.go | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'cmd/podman') diff --git a/cmd/podman/ps.go b/cmd/podman/ps.go index be6c5aef5..0b75b9a96 100644 --- a/cmd/podman/ps.go +++ b/cmd/podman/ps.go @@ -427,9 +427,17 @@ func getTemplateOutput(containers []*libpod.Container, opts psOptions) ([]psTemp if batchErr != nil { return nil, err } - - runningFor := units.HumanDuration(time.Since(conConfig.CreatedTime)) - createdAt := runningFor + " ago" + runningFor := "" + startedTime, err := ctr.StartedTime() + if err != nil { + logrus.Errorf("error getting started time for %q: %v", ctr.ID(), err) + } + // If the container has not be started, the "zero" value of time is 0001-01-01 00:00:00 +0000 UTC + // which would make the time elapsed about a few hundred of years. So checking for the "zero" value of time.Time + if startedTime != (time.Time{}) { + runningFor = units.HumanDuration(time.Since(startedTime)) + } + createdAt := conConfig.CreatedTime.Format("2006-01-02 15:04:05 -0700 MST") imageName := conConfig.RootfsImageName rootFsSize, err := ctr.RootFsSize() if err != nil { -- cgit v1.2.3-54-g00ecf