// String returns a human-readable description of the state func (s *State) String() string { s.RLock() defer s.RUnlock() if s.Running { return fmt.Sprintf("Up %s", units.HumanDuration(time.Now().UTC().Sub(s.StartedAt))) } if s.FinishedAt.IsZero() { return "" } return fmt.Sprintf("Exited (%d) %s ago", s.ExitCode, units.HumanDuration(time.Now().UTC().Sub(s.FinishedAt))) }
func stringTimeToHuman(ts string) (ds string) { tt, err := time.Parse("2006-01-02T15:04:05Z07:00", ts) if err != nil { return ts } d := time.Since(tt) return units.HumanDuration(d) }