diff --git a/database/gdb/gdb.go b/database/gdb/gdb.go index 67a1489af..79c897000 100644 --- a/database/gdb/gdb.go +++ b/database/gdb/gdb.go @@ -158,7 +158,7 @@ type DB interface { // =========================================================================== mappingAndFilterData(schema, table string, data map[string]interface{}, filter bool) (map[string]interface{}, error) - convertValue(fieldValue interface{}, fieldType string) interface{} + convertDatabaseValueToLocalValue(fieldValue interface{}, fieldType string) interface{} rowsToResult(rows *sql.Rows) (Result, error) } diff --git a/database/gdb/gdb_core.go b/database/gdb/gdb_core.go index 58058204d..71979a0f6 100644 --- a/database/gdb/gdb_core.go +++ b/database/gdb/gdb_core.go @@ -785,7 +785,7 @@ func (c *Core) rowsToResult(rows *sql.Rows) (Result, error) { if value == nil { row[columnNames[i]] = gvar.New(nil) } else { - row[columnNames[i]] = gvar.New(c.DB.convertValue(value, columnTypes[i])) + row[columnNames[i]] = gvar.New(c.DB.convertDatabaseValueToLocalValue(value, columnTypes[i])) } } records = append(records, row) diff --git a/database/gdb/gdb_core_structure.go b/database/gdb/gdb_core_structure.go index 900a7ea8c..0a0d91808 100644 --- a/database/gdb/gdb_core_structure.go +++ b/database/gdb/gdb_core_structure.go @@ -22,9 +22,9 @@ import ( "github.com/gogf/gf/util/gconv" ) -// convertValue automatically checks and converts field value from database type +// convertDatabaseValueToLocalValue automatically checks and converts field value from database type // to golang variable type. -func (c *Core) convertValue(fieldValue interface{}, fieldType string) interface{} { +func (c *Core) convertDatabaseValueToLocalValue(fieldValue interface{}, fieldType string) interface{} { // If there's no type retrieved, it returns the directly // to use its original data type, as is type of interface{}. if fieldType == "" { diff --git a/os/gtime/gtime.go b/os/gtime/gtime.go index 6745c4a61..500b39761 100644 --- a/os/gtime/gtime.go +++ b/os/gtime/gtime.go @@ -333,7 +333,6 @@ func StrToTime(str string, format ...string) (*Time, error) { if year <= 0 { return nil, errors.New("invalid time string:" + str) } - // It finally converts all time to UTC time zone. return NewFromTime(time.Date(year, time.Month(month), day, hour, min, sec, nsec, local)), nil } diff --git a/os/gtime/gtime_time.go b/os/gtime/gtime_time.go index 174ef973f..66d9d0797 100644 --- a/os/gtime/gtime_time.go +++ b/os/gtime/gtime_time.go @@ -31,6 +31,10 @@ func New(param ...interface{}) *Time { return NewFromTime(r) case *time.Time: return NewFromTime(*r) + case Time: + return &r + case *Time: + return r case string: return NewFromStr(r) case []byte: