aboutsummaryrefslogtreecommitdiffhomepage
path: root/vendor/github.com/fsouza/go-dockerclient/external/github.com/docker/go-units/duration.go
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/github.com/fsouza/go-dockerclient/external/github.com/docker/go-units/duration.go')
-rw-r--r--vendor/github.com/fsouza/go-dockerclient/external/github.com/docker/go-units/duration.go33
1 files changed, 0 insertions, 33 deletions
diff --git a/vendor/github.com/fsouza/go-dockerclient/external/github.com/docker/go-units/duration.go b/vendor/github.com/fsouza/go-dockerclient/external/github.com/docker/go-units/duration.go
deleted file mode 100644
index c219a8a..0000000
--- a/vendor/github.com/fsouza/go-dockerclient/external/github.com/docker/go-units/duration.go
+++ /dev/null
@@ -1,33 +0,0 @@
1// Package units provides helper function to parse and print size and time units
2// in human-readable format.
3package units
4
5import (
6 "fmt"
7 "time"
8)
9
10// HumanDuration returns a human-readable approximation of a duration
11// (eg. "About a minute", "4 hours ago", etc.).
12func HumanDuration(d time.Duration) string {
13 if seconds := int(d.Seconds()); seconds < 1 {
14 return "Less than a second"
15 } else if seconds < 60 {
16 return fmt.Sprintf("%d seconds", seconds)
17 } else if minutes := int(d.Minutes()); minutes == 1 {
18 return "About a minute"
19 } else if minutes < 60 {
20 return fmt.Sprintf("%d minutes", minutes)
21 } else if hours := int(d.Hours()); hours == 1 {
22 return "About an hour"
23 } else if hours < 48 {
24 return fmt.Sprintf("%d hours", hours)
25 } else if hours < 24*7*2 {
26 return fmt.Sprintf("%d days", hours/24)
27 } else if hours < 24*30*3 {
28 return fmt.Sprintf("%d weeks", hours/24/7)
29 } else if hours < 24*365*2 {
30 return fmt.Sprintf("%d months", hours/24/30)
31 }
32 return fmt.Sprintf("%d years", int(d.Hours())/24/365)
33}