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.
go-library/vendor/github.com/golang-module/carbon/database.go

26 lines
573 B

package carbon
import (
"database/sql/driver"
"fmt"
"time"
)
// Scan an interface used by Scan in package database/sql for Scanning value from database to local golang variable.
func (c *Carbon) Scan(v interface{}) error {
value, ok := v.(time.Time)
if ok {
*c = Carbon{Time: value, loc: time.Local}
return nil
}
return fmt.Errorf("can not convert %v to carbon", v)
}
// Value the interface providing the Value method for package database/sql/driver.
func (c Carbon) Value() (driver.Value, error) {
if c.IsZero() {
return nil, nil
}
return c.Time, nil
}