Пример #1
0
// 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)))
}
Пример #2
0
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)
}