You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

25 lines
396 B

package util
import (
"fmt"
"time"
)
const (
// TimeFormat .
TimeFormat = "2006-01-02 15:04:05"
)
// JSONTime .
type JSONTime time.Time
// MarshalJSON .
func (jt JSONTime) MarshalJSON() ([]byte, error) {
stamp := fmt.Sprintf("%q", time.Time(jt).Format(TimeFormat))
return []byte(stamp), nil
}
// Before .
func (jt JSONTime) Before(t time.Time) bool {
return time.Time(jt).Before(t)
}