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

           
        
                                                 
                                                 
                                                       
                                       
 
 
                                       
                     
                                  
                      
                          


                                                                                                                    
                                    
 
 

                                                                         
                                               
 

                                      
                                                                        
 


                                
package bug

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

// Comment represent a comment in a Bug
type Comment struct {
	Author  identity.Interface
	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 timestamp.Timestamp
}

// FormatTimeRel format the UnixTime of the comment for human consumption
func (c Comment) FormatTimeRel() string {
	return humanize.Time(c.UnixTime.Time())
}

func (c Comment) FormatTime() string {
	return c.UnixTime.Time().Format("Mon Jan 2 15:04:05 2006 +0200")
}

// Sign post method for gqlgen
func (c Comment) IsAuthored() {}