diff options
Diffstat (limited to 'bug/operation.go')
-rw-r--r-- | bug/operation.go | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/bug/operation.go b/bug/operation.go index c9e7a555..15374f08 100644 --- a/bug/operation.go +++ b/bug/operation.go @@ -1,5 +1,7 @@ package bug +import "time" + type OperationType int const ( @@ -12,13 +14,28 @@ const ( type Operation interface { OpType() OperationType + Time() time.Time Apply(snapshot Snapshot) Snapshot } type OpBase struct { OperationType OperationType + Author Person + UnixTime int64 +} + +func NewOpBase(opType OperationType, author Person) OpBase { + return OpBase{ + OperationType: opType, + Author: author, + UnixTime: time.Now().Unix(), + } } func (op OpBase) OpType() OperationType { return op.OperationType } + +func (op OpBase) Time() time.Time { + return time.Unix(op.UnixTime, 0) +} |