From 0a7814f33a44a57924ac4c6dfeca20cf741dc1f3 Mon Sep 17 00:00:00 2001 From: Michael Muré Date: Thu, 19 Jul 2018 18:10:45 +0200 Subject: humanize time --- bug/comment.go | 8 ++++++-- bug/snapshot.go | 5 +++-- 2 files changed, 9 insertions(+), 4 deletions(-) (limited to 'bug') diff --git a/bug/comment.go b/bug/comment.go index 63147776..c0c07076 100644 --- a/bug/comment.go +++ b/bug/comment.go @@ -1,6 +1,9 @@ package bug -import "time" +import ( + "github.com/dustin/go-humanize" + "time" +) type Comment struct { Author Person @@ -12,5 +15,6 @@ type Comment struct { } func (c Comment) FormatTime() string { - return time.Unix(c.UnixTime, 0).Format(time.RFC822) + t := time.Unix(c.UnixTime, 0) + return humanize.Time(t) } diff --git a/bug/snapshot.go b/bug/snapshot.go index 75d3a028..14ffd629 100644 --- a/bug/snapshot.go +++ b/bug/snapshot.go @@ -2,6 +2,7 @@ package bug import ( "fmt" + "github.com/dustin/go-humanize" "time" ) @@ -28,10 +29,10 @@ func (snap Snapshot) HumanId() string { } func (snap Snapshot) Summary() string { - return fmt.Sprintf("C:%d L:%d %s", + return fmt.Sprintf("C:%d L:%d %s", len(snap.Comments)-1, len(snap.Labels), - snap.LastEdit().Format(time.RFC822), + humanize.Time(snap.LastEdit()), ) } -- cgit