Add MarshalJSON function to LemmyTime

This commit is contained in:
Elara 2023-09-02 15:51:05 -07:00
parent 11c92ef2b1
commit 9f4bae88f2

View File

@ -32,6 +32,10 @@ type LemmyTime struct {
time.Time 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 { func (lt *LemmyTime) UnmarshalJSON(b []byte) error {
var timeStr string var timeStr string
err := json.Unmarshal(b, &timeStr) err := json.Unmarshal(b, &timeStr)