-
Notifications
You must be signed in to change notification settings - Fork 77
Open
Description
JsonUnixTime helper for that matter:
type JsonUnixTime time.Time
func (t JsonUnixTime) MarshalJSON() ([]byte, error) {
return strconv.AppendInt(nil, time.Time(t).Unix(), 10), nil
}
func (t *JsonUnixTime) UnmarshalJSON(data []byte) (err error) {
// Fractional seconds are handled implicitly by Parse.
unixTime, err := strconv.ParseInt(string(data), 10, 64)
*t = JsonUnixTime(time.Unix(unixTime, 0))
return nil
}
Will work on a PR later
Metadata
Metadata
Assignees
Labels
No labels