diff --git a/pttodo/ts.go b/pttodo/ts.go index 737a4c3..f33691d 100644 --- a/pttodo/ts.go +++ b/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 {