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 26, 2024
1 parent 8195a01 commit 18327c3
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 18327c3

Please sign in to comment.