Skip to content

Commit

Permalink
Fixed timeStringWithAgo for sub-minute age
Browse files Browse the repository at this point in the history
  • Loading branch information
rykov committed Jun 27, 2024
1 parent 7206e12 commit c46e49f
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion cli/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ func timeStringWithAgo(t time.Time) string {
out := t.Local().Format("2006-01-02 15:04")

if ago := time.Now().Sub(t); ago < 24*time.Hour {
if str := roundDurationRE.FindString(ago.String()); str != "" {
agoStr := ago.Round(time.Second).String()
if str := roundDurationRE.FindString(agoStr); str != "" {
out = fmt.Sprintf("%s (~ %s ago)", out, str)
}
}
Expand Down

0 comments on commit c46e49f

Please sign in to comment.