mirror of
https://gitee.com/johng/gf
synced 2026-06-07 02:12:11 +08:00
30 lines
536 B
Go
30 lines
536 B
Go
package gtime
|
|
|
|
import (
|
|
"database/sql/driver"
|
|
)
|
|
|
|
//Scanner is an interface used by Scan.
|
|
//Scan value from database
|
|
//database/sql
|
|
func (t *Time) Scan(value interface{}) error {
|
|
if t == nil {
|
|
return nil
|
|
}
|
|
newTime := New(value)
|
|
t.Time = newTime.Time
|
|
return nil
|
|
}
|
|
|
|
// Valuer is the interface providing the Value method. database/sql/driver
|
|
// Value insert into mysql need this function.
|
|
func (t *Time) Value() (driver.Value, error) {
|
|
if t == nil {
|
|
return nil, nil
|
|
}
|
|
if t.IsZero() {
|
|
return nil, nil
|
|
}
|
|
return t.Time, nil
|
|
}
|