aboutsummaryrefslogblamecommitdiffstats
path: root/bug/comment.go
blob: c716827582e18b9b4f522a2c67e2de9fa0b8d741 (plain) (tree)
1
2
3
4
5
6
7
8
9

           
        
                                                 


                                       
 
                                       
                     

                      
                          


                                                                                                                    
                      
 
 

                                                                         

                                     
 




                                                        
package bug

import (
	"github.com/MichaelMure/git-bug/util/git"
	"github.com/dustin/go-humanize"
	"time"
)

// Comment represent a comment in a Bug
type Comment struct {
	Author  Person
	Message string
	Files   []git.Hash

	// 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
}

// FormatTimeRel format the UnixTime of the comment for human consumption
func (c Comment) FormatTimeRel() string {
	t := time.Unix(c.UnixTime, 0)
	return humanize.Time(t)
}

func (c Comment) FormatTime() string {
	t := time.Unix(c.UnixTime, 0)
	return t.Format("Mon Jan 2 15:04:05 2006 +0200")
}