代码拉取完成,页面将自动刷新
package timeout
import (
"database/sql/driver"
"fmt"
"strings"
"time"
)
type DTime time.Time
const DTimeFormat = "15:04:05"
func (d *DTime) UnmarshalJSON(src []byte) error {
return d.UnmarshalText(strings.Replace(string(src), "\"", "", -1))
}
func (d DTime) MarshalJSON() ([]byte, error) {
return []byte(`"` + d.String() + `"`), nil
}
func (d *DTime) UnmarshalText(value string) error {
dd, err := time.Parse(DTimeFormat, value)
if err != nil {
return err
}
*d = DTime(dd)
return nil
}
func (d DTime) String() string {
return (time.Time)(d).Format(DTimeFormat)
}
func (d *DTime) Scan(value interface{}) error {
switch v := value.(type) {
case []byte:
return d.UnmarshalText(string(v))
case string:
return d.UnmarshalText(v)
case time.Time:
*d = DTime(v)
case nil:
*d = DTime{}
default:
return fmt.Errorf("cannot sql.Scan() DBDate from: %#v", v)
}
return nil
}
func (d DTime) Value() (driver.Value, error) {
return driver.Value(time.Time(d).Format(DTimeFormat)), nil
}
func (DTime) GormDataType() string {
return "TIME"
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。