tstor/daemons/kemono/client/models.go

22 lines
345 B
Go
Raw Normal View History

2024-11-24 17:32:26 +00:00
package client
import (
"encoding/json"
"time"
)
type Timestamp struct {
Time time.Time
}
func (t *Timestamp) UnmarshalJSON(b []byte) error {
var timestamp float64
err := json.Unmarshal(b, &timestamp)
if err != nil {
return err
}
t.Time = time.Unix(int64(timestamp), int64((timestamp-float64(int64(timestamp)))*1e9))
return nil
}