forked from mirror/go-sqlite3
cleanup code
This commit is contained in:
parent
4c5c4e5261
commit
18aa166fa9
15
sqlite3.go
15
sqlite3.go
|
@ -572,21 +572,16 @@ func (rc *SQLiteRows) Next(dest []driver.Value) error {
|
||||||
|
|
||||||
switch rc.decltype[i] {
|
switch rc.decltype[i] {
|
||||||
case "timestamp", "datetime", "date":
|
case "timestamp", "datetime", "date":
|
||||||
if rc.s.c.loc != nil {
|
zone := rc.s.c.loc
|
||||||
|
if zone == nil {
|
||||||
|
zone = time.UTC
|
||||||
|
}
|
||||||
for _, format := range SQLiteTimestampFormats {
|
for _, format := range SQLiteTimestampFormats {
|
||||||
if timeVal, err = time.ParseInLocation(format, s, rc.s.c.loc); err == nil {
|
if timeVal, err = time.ParseInLocation(format, s, zone); err == nil {
|
||||||
dest[i] = timeVal
|
dest[i] = timeVal
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
for _, format := range SQLiteTimestampFormats {
|
|
||||||
if timeVal, err = time.ParseInLocation(format, s, time.UTC); err == nil {
|
|
||||||
dest[i] = timeVal
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
// The column is a time value, so return the zero time on parse failure.
|
// The column is a time value, so return the zero time on parse failure.
|
||||||
dest[i] = time.Time{}
|
dest[i] = time.Time{}
|
||||||
|
|
Loading…
Reference in New Issue