From 43bf0063f2994463cdb98ec6420b786ca41dde28 Mon Sep 17 00:00:00 2001 From: Michael Muré Date: Tue, 17 Jul 2018 20:51:09 +0200 Subject: crude implementation of show --- bug/comment.go | 6 ++++++ bug/snapshot.go | 3 +++ 2 files changed, 9 insertions(+) (limited to 'bug') diff --git a/bug/comment.go b/bug/comment.go index 09cd49bd..8ea4154f 100644 --- a/bug/comment.go +++ b/bug/comment.go @@ -1,5 +1,7 @@ package bug +import "time" + type Comment struct { Author Person Message string @@ -8,3 +10,7 @@ type Comment struct { // Should be used only for human display, never for ordering as we can't rely on it in a distributed system. Time int64 } + +func (c Comment) FormatTime() string { + return time.Unix(c.Time, 0).Format(time.RFC822) +} diff --git a/bug/snapshot.go b/bug/snapshot.go index 41d96aa2..9229e7a1 100644 --- a/bug/snapshot.go +++ b/bug/snapshot.go @@ -33,6 +33,9 @@ func (snap Snapshot) Summary() string { } func (snap Snapshot) LastEdit() time.Time { + if len(snap.Comments) == 0 { + return time.Unix(0, 0) + } lastEditTimestamp := snap.Comments[len(snap.Comments)-1].Time return time.Unix(lastEditTimestamp, 0) } -- cgit