initial commit
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
package api
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"time"
|
||||
)
|
||||
|
||||
type UnixTimestamp struct {
|
||||
time.Time
|
||||
}
|
||||
|
||||
func (ut *UnixTimestamp) UnmarshalJSON(b []byte) error {
|
||||
var timestamp int64
|
||||
// Unmarshal the raw JSON bytes into an int64
|
||||
if err := json.Unmarshal(b, ×tamp); err != nil {
|
||||
return err
|
||||
}
|
||||
// Convert the epoch seconds to a time.Time object
|
||||
ut.Time = time.Unix(timestamp, 0)
|
||||
return nil
|
||||
}
|
||||
Reference in New Issue
Block a user