From 545f223a97ca82309a43bec446c84de25cf90d0e Mon Sep 17 00:00:00 2001 From: Jan Bader Date: Sun, 20 Feb 2022 21:06:17 +0000 Subject: [PATCH] Comments --- server/json-date.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/server/json-date.go b/server/json-date.go index 17ba6a2..869069d 100644 --- a/server/json-date.go +++ b/server/json-date.go @@ -9,7 +9,7 @@ import ( type JSONDate time.Time -// Implement Marshaler and Unmarshaler interface +// UnmarshalJSON parses the JSONDate from a JSON input. func (j *JSONDate) UnmarshalJSON(b []byte) error { s := strings.Trim(string(b), "\"") t, err := time.Parse("2006-01-02", s) @@ -20,6 +20,7 @@ func (j *JSONDate) UnmarshalJSON(b []byte) error { return nil } +// MarshalJSON converts the JSONDate to a JSON in ISO format. func (j JSONDate) MarshalJSON() ([]byte, error) { result, err := json.Marshal(time.Time(j)) if err != nil { @@ -29,7 +30,7 @@ func (j JSONDate) MarshalJSON() ([]byte, error) { return result, nil } -// Maybe a Format function for printing your date +// Format formats the time using the regular time.Time mechanics.. func (j JSONDate) Format(s string) string { t := time.Time(j) return t.Format(s)