add marshal yaml for ts

master
Bel LaPointe 2021-12-31 16:07:54 -05:00
parent 28baac7dc6
commit 2bcda28d5d
1 changed files with 9 additions and 1 deletions

View File

@ -8,10 +8,18 @@ import (
type TS int64
func (ts TS) MarshalJSON() ([]byte, error) {
v, err := ts.MarshalYAML()
if err != nil {
return nil, err
}
return json.Marshal(v)
}
func (ts TS) MarshalYAML() (interface{}, error) {
if ts == 0 {
ts = TS(time.Now().Unix())
}
return json.Marshal(int64(ts))
return int64(ts), nil
}
func (ts *TS) UnmarshalJSON(b []byte) error {