format time
This commit is contained in:
parent
be7651f415
commit
f982b9f277
13
ui/ui.go
13
ui/ui.go
@ -213,7 +213,7 @@ func printBlock(n int, blocks []*client.Block) []byte {
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
white(" %d secs ago ", ago),
|
||||
white(" %s ago ", fmtSeconds(ago)),
|
||||
" ",
|
||||
}
|
||||
|
||||
@ -226,3 +226,14 @@ func printBlock(n int, blocks []*client.Block) []byte {
|
||||
fmt.Fprintf(buf, strings.Join(lines, "\n"))
|
||||
return buf.Bytes()
|
||||
}
|
||||
|
||||
func fmtSeconds(s int64) string {
|
||||
if s < 60 {
|
||||
return "< 1 minute"
|
||||
} else if s < 120 {
|
||||
return fmt.Sprintf("1 minute")
|
||||
} else if s < 3600 {
|
||||
return fmt.Sprintf("%d minutes", s/60)
|
||||
}
|
||||
return fmt.Sprintf("%d hours", s/3600)
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user