From 2bcda28d5d0e94bfb8c2b8264a4a0a563e619779 Mon Sep 17 00:00:00 2001 From: Bel LaPointe Date: Fri, 31 Dec 2021 16:07:54 -0500 Subject: [PATCH] add marshal yaml for ts --- pttodo/ts.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) 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 {