github.com/kyleu/dbaudit@v0.0.2-0.20240321155047-ff2f2c940496/app/lib/types/timestamp.go (about) 1 // Package types - Content managed by Project Forge, see [projectforge.md] for details. 2 package types 3 4 import "github.com/kyleu/dbaudit/app/util" 5 6 const KeyTimestamp = "timestamp" 7 8 type Timestamp struct{} 9 10 var _ Type = (*Timestamp)(nil) 11 12 func (x *Timestamp) Key() string { 13 return KeyTimestamp 14 } 15 16 func (x *Timestamp) Sortable() bool { 17 return true 18 } 19 20 func (x *Timestamp) Scalar() bool { 21 return false 22 } 23 24 func (x *Timestamp) String() string { 25 return x.Key() 26 } 27 28 func (x *Timestamp) From(v any) any { 29 return invalidInput(x.Key(), v) 30 } 31 32 func (x *Timestamp) Default(string) any { 33 return util.TimeCurrent() 34 } 35 36 func NewTimestamp() *Wrapped { 37 return Wrap(&Timestamp{}) 38 }