git-bug/bug/comment.go

30 lines
684 B
Go
Raw Normal View History

package bug
2018-07-19 19:10:45 +03:00
import (
"github.com/MichaelMure/git-bug/util/git"
2018-07-19 19:10:45 +03:00
"github.com/dustin/go-humanize"
"time"
)
2018-07-17 21:51:09 +03:00
2018-08-13 16:28:16 +03:00
// Comment represent a comment in a Bug
type Comment struct {
2018-08-01 03:15:40 +03:00
Author Person
Message string
Files []git.Hash
2018-07-14 23:18:40 +03:00
// Creation time of the comment.
// Should be used only for human display, never for ordering as we can't rely on it in a distributed system.
UnixTime int64
}
2018-07-17 21:51:09 +03:00
// FormatTimeRel format the UnixTime of the comment for human consumption
func (c Comment) FormatTimeRel() string {
2018-07-19 19:10:45 +03:00
t := time.Unix(c.UnixTime, 0)
return humanize.Time(t)
2018-07-17 21:51:09 +03:00
}
func (c Comment) FormatTime() string {
t := time.Unix(c.UnixTime, 0)
return t.Format("Mon Jan 2 15:04:05 2006 +0200")
}