22 lines
345 B
Go
22 lines
345 B
Go
|
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, ×tamp)
|
||
|
if err != nil {
|
||
|
return err
|
||
|
}
|
||
|
|
||
|
t.Time = time.Unix(int64(timestamp), int64((timestamp-float64(int64(timestamp)))*1e9))
|
||
|
return nil
|
||
|
}
|