github.com/kotovmak/go-admin@v1.1.1/template/types/display/date.go (about)

     1  package display
     2  
     3  import (
     4  	"strconv"
     5  	"time"
     6  
     7  	"github.com/kotovmak/go-admin/template/types"
     8  )
     9  
    10  type Date struct {
    11  	types.BaseDisplayFnGenerator
    12  }
    13  
    14  func init() {
    15  	types.RegisterDisplayFnGenerator("date", new(Date))
    16  }
    17  
    18  func (d *Date) Get(args ...interface{}) types.FieldFilterFn {
    19  	return func(value types.FieldModel) interface{} {
    20  		format := args[0].(string)
    21  		ts, _ := strconv.ParseInt(value.Value, 10, 64)
    22  		tm := time.Unix(ts, 0)
    23  		return tm.Format(format)
    24  	}
    25  }