Fixed a tiny issue for ShortHumanDuration printer.

Fixed a tiny issue for ShortHumanDuration printer
to avoid "0y" message.
pull/6/head
Xing Zhou 2017-04-18 16:07:46 +08:00
parent c20e63bfb9
commit 35c900aa70
1 changed files with 1 additions and 1 deletions

View File

@ -34,7 +34,7 @@ func ShortHumanDuration(d time.Duration) string {
return fmt.Sprintf("%dm", minutes) return fmt.Sprintf("%dm", minutes)
} else if hours := int(d.Hours()); hours < 24 { } else if hours := int(d.Hours()); hours < 24 {
return fmt.Sprintf("%dh", hours) return fmt.Sprintf("%dh", hours)
} else if hours < 24*364 { } else if hours < 24*365 {
return fmt.Sprintf("%dd", hours/24) return fmt.Sprintf("%dd", hours/24)
} }
return fmt.Sprintf("%dy", int(d.Hours()/24/365)) return fmt.Sprintf("%dy", int(d.Hours()/24/365))