From 9f4bae88f2fe2d3817062d45e2c568f052bca05c Mon Sep 17 00:00:00 2001 From: Elara Musayelyan Date: Sat, 2 Sep 2023 15:51:05 -0700 Subject: [PATCH] Add MarshalJSON function to LemmyTime --- types/types.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/types/types.go b/types/types.go index 8694ec3..ca20bb8 100644 --- a/types/types.go +++ b/types/types.go @@ -32,6 +32,10 @@ type LemmyTime struct { time.Time } +func (lt LemmyTime) MarshalJSON() ([]byte, error) { + return json.Marshal(lt.Time.Format("2006-01-02T15:04:05")) +} + func (lt *LemmyTime) UnmarshalJSON(b []byte) error { var timeStr string err := json.Unmarshal(b, &timeStr)