diff options
author | Mehmet Gurevin <mehmet.gurevin@kartaca.com> | 2014-10-23 20:12:32 +0300 |
---|---|---|
committer | Mehmet Gurevin <mehmet.gurevin@kartaca.com> | 2014-10-23 20:12:32 +0300 |
commit | 6710e996b5a7a19f6d085ce7a95ba6787565d3ab (patch) | |
tree | 9b78818f09252f4af39cdb0762a50f427c7bdd60 /sqlite3.go | |
parent | Merge commit '3d78a08b9f3307ac3874f5c120f7d4166c62efb9' (diff) | |
download | golite-6710e996b5a7a19f6d085ce7a95ba6787565d3ab.tar.gz golite-6710e996b5a7a19f6d085ce7a95ba6787565d3ab.tar.xz |
fixed timezone problem for datetime types
Diffstat (limited to 'sqlite3.go')
-rw-r--r-- | sqlite3.go | 6 |
1 files changed, 4 insertions, 2 deletions
@@ -486,7 +486,7 @@ func (rc *SQLiteRows) Next(dest []driver.Value) error { val := int64(C.sqlite3_column_int64(rc.s.s, C.int(i))) switch rc.decltype[i] { case "timestamp", "datetime", "date": - dest[i] = time.Unix(val, 0) + dest[i] = time.Unix(val, 0).Local() case "boolean": dest[i] = val > 0 default: @@ -513,12 +513,14 @@ func (rc *SQLiteRows) Next(dest []driver.Value) error { dest[i] = nil case C.SQLITE_TEXT: var err error + var timeVal time.Time s := C.GoString((*C.char)(unsafe.Pointer(C.sqlite3_column_text(rc.s.s, C.int(i))))) switch rc.decltype[i] { case "timestamp", "datetime", "date": for _, format := range SQLiteTimestampFormats { - if dest[i], err = time.Parse(format, s); err == nil { + if timeVal, err = time.ParseInLocation(format, s, time.UTC); err == nil { + dest[i] = timeVal.Local() break } } |