24 lines
348 B
Go
24 lines
348 B
Go
package config
|
|
|
|
import (
|
|
"encoding/json"
|
|
"time"
|
|
)
|
|
|
|
type Time time.Time
|
|
|
|
func (t Time) Get() time.Time {
|
|
return time.Time(t)
|
|
}
|
|
|
|
func (t Time) MarshalJSON() ([]byte, error) {
|
|
return json.Marshal(t.Get().Unix())
|
|
}
|
|
|
|
func (t *Time) UnmarshalJSON(b []byte) error {
|
|
var d int64
|
|
err := json.Unmarshal(b, &d)
|
|
*t = Time(time.Unix(d, 0))
|
|
return err
|
|
}
|