Remove unrelated files
This commit is contained in:
parent
ac3ca38638
commit
ae0d5506c1
|
@ -1,30 +0,0 @@
|
||||||
// Copyright 2021 The Xorm Authors. All rights reserved.
|
|
||||||
// Use of this source code is governed by a BSD-style
|
|
||||||
// license that can be found in the LICENSE file.
|
|
||||||
|
|
||||||
package convert
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
"time"
|
|
||||||
)
|
|
||||||
|
|
||||||
// String2Time converts a string to time with original location
|
|
||||||
func String2Time(s string, originalLocation *time.Location, convertedLocation *time.Location) (*time.Time, error) {
|
|
||||||
if len(s) == 19 {
|
|
||||||
dt, err := time.ParseInLocation("2006-01-02 15:04:05", s, originalLocation)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
dt = dt.In(convertedLocation)
|
|
||||||
return &dt, nil
|
|
||||||
} else if len(s) == 20 && s[10] == 'T' && s[19] == 'Z' {
|
|
||||||
dt, err := time.ParseInLocation("2006-01-02T15:04:05Z", s, originalLocation)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
dt = dt.In(convertedLocation)
|
|
||||||
return &dt, nil
|
|
||||||
}
|
|
||||||
return nil, fmt.Errorf("unsupported convertion from %s to time", s)
|
|
||||||
}
|
|
48
scan.go
48
scan.go
|
@ -6,58 +6,10 @@ package xorm
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"database/sql"
|
"database/sql"
|
||||||
"time"
|
|
||||||
|
|
||||||
"xorm.io/xorm/convert"
|
|
||||||
"xorm.io/xorm/core"
|
"xorm.io/xorm/core"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (engine *Engine) scan(rows *core.Rows, types []*sql.ColumnType, v ...interface{}) error {
|
|
||||||
var v2 = make([]interface{}, 0, len(v))
|
|
||||||
var turnBackIdxes = make([]int, 0, 5)
|
|
||||||
for i, vv := range v {
|
|
||||||
switch vv.(type) {
|
|
||||||
case *time.Time:
|
|
||||||
v2 = append(v2, &sql.NullString{})
|
|
||||||
turnBackIdxes = append(turnBackIdxes, i)
|
|
||||||
case *sql.NullTime:
|
|
||||||
v2 = append(v2, &sql.NullString{})
|
|
||||||
turnBackIdxes = append(turnBackIdxes, i)
|
|
||||||
default:
|
|
||||||
v2 = append(v2, v[i])
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if err := rows.Scan(v2...); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
for _, i := range turnBackIdxes {
|
|
||||||
switch t := v[i].(type) {
|
|
||||||
case *time.Time:
|
|
||||||
var s = *(v2[i].(*sql.NullString))
|
|
||||||
if !s.Valid {
|
|
||||||
break
|
|
||||||
}
|
|
||||||
dt, err := convert.String2Time(s.String, engine.DatabaseTZ, engine.TZLocation)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
*t = *dt
|
|
||||||
case *sql.NullTime:
|
|
||||||
var s = *(v2[i].(*sql.NullString))
|
|
||||||
if !s.Valid {
|
|
||||||
break
|
|
||||||
}
|
|
||||||
dt, err := convert.String2Time(s.String, engine.DatabaseTZ, engine.TZLocation)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
t.Time = *dt
|
|
||||||
t.Valid = true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (engine *Engine) row2mapStr(rows *core.Rows, types []*sql.ColumnType, fields []string) (map[string]string, error) {
|
func (engine *Engine) row2mapStr(rows *core.Rows, types []*sql.ColumnType, fields []string) (map[string]string, error) {
|
||||||
var scanResults = make([]interface{}, len(fields))
|
var scanResults = make([]interface{}, len(fields))
|
||||||
for i := 0; i < len(fields); i++ {
|
for i := 0; i < len(fields); i++ {
|
||||||
|
|
Loading…
Reference in New Issue