comment.go

 1package bug
 2
 3import (
 4	"github.com/MichaelMure/git-bug/identity"
 5	"github.com/MichaelMure/git-bug/util/git"
 6	"github.com/MichaelMure/git-bug/util/timestamp"
 7	"github.com/dustin/go-humanize"
 8)
 9
10// Comment represent a comment in a Bug
11type Comment struct {
12	Author  identity.Interface
13	Message string
14	Files   []git.Hash
15
16	// Creation time of the comment.
17	// Should be used only for human display, never for ordering as we can't rely on it in a distributed system.
18	UnixTime timestamp.Timestamp
19}
20
21// FormatTimeRel format the UnixTime of the comment for human consumption
22func (c Comment) FormatTimeRel() string {
23	return humanize.Time(c.UnixTime.Time())
24}
25
26func (c Comment) FormatTime() string {
27	return c.UnixTime.Time().Format("Mon Jan 2 15:04:05 2006 +0200")
28}
29
30// Sign post method for gqlgen
31func (c Comment) IsAuthored() {}