add marshal yaml for ts
parent
28baac7dc6
commit
2bcda28d5d
10
pttodo/ts.go
10
pttodo/ts.go
|
|
@ -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 {
|
||||
|
|
|
|||
Loading…
Reference in New Issue