Update for 0.19.0-rc.1
This commit is contained in:
@@ -1,38 +0,0 @@
|
||||
package types
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"time"
|
||||
)
|
||||
|
||||
// LemmyTime represents a time value returned by the Lemmy server
|
||||
type LemmyTime struct {
|
||||
time.Time
|
||||
}
|
||||
|
||||
// MarshalJSON encodes the Lemmy time to its JSON value
|
||||
func (lt LemmyTime) MarshalJSON() ([]byte, error) {
|
||||
return json.Marshal(lt.Time.Format("2006-01-02T15:04:05"))
|
||||
}
|
||||
|
||||
// UnmarshalJSON decodes JSON into the Lemmy time struct
|
||||
func (lt *LemmyTime) UnmarshalJSON(b []byte) error {
|
||||
var timeStr string
|
||||
err := json.Unmarshal(b, &timeStr)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if timeStr == "" {
|
||||
lt.Time = time.Unix(0, 0)
|
||||
return nil
|
||||
}
|
||||
|
||||
t, err := time.Parse("2006-01-02T15:04:05", timeStr)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
lt.Time = t
|
||||
|
||||
return nil
|
||||
}
|
||||
2626
types/types.gen.go
2626
types/types.gen.go
File diff suppressed because it is too large
Load Diff
@@ -6,12 +6,6 @@ type EmptyResponse struct {
|
||||
LemmyResponse
|
||||
}
|
||||
|
||||
// EmptyData is a request without any fields. It contains
|
||||
// an Auth field so that the auth token is sent to the server.
|
||||
type EmptyData struct {
|
||||
Auth string `json:"auth" url:"auth,omitempty"`
|
||||
}
|
||||
|
||||
// LemmyResponse is embedded in all response structs
|
||||
// to capture any errors sent by the Lemmy server.
|
||||
type LemmyResponse struct {
|
||||
|
||||
Reference in New Issue
Block a user