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
}
