GAAS GFrame项目web后台
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.

27 lines
511 B

package grmi
import (
"encoding/json"
"fmt"
"time"
)
type DateTime time.Time
func (self DateTime) MarshalJSON() ([]byte, error) {
return []byte(fmt.Sprintf("\"%s\"", time.Time(self).Format(URLDateTimeFormat))), nil
}
func (self *DateTime) UnmarshalJSON(data []byte) error {
var jsonString string
err := json.Unmarshal(data, &jsonString)
if err != nil {
return err
}
result, err := time.Parse(URLDateTimeFormat, jsonString)
if err != nil {
return err
}
*self = DateTime(result)
return nil
}