aboutsummaryrefslogtreecommitdiff
path: root/sqlite3.go
diff options
context:
space:
mode:
authormattn <mattn.jp@gmail.com>2014-10-24 18:22:46 +0900
committermattn <mattn.jp@gmail.com>2014-10-24 18:22:46 +0900
commitc1aa7ac7060c032c5b65aaa5269680fc348ebf1c (patch)
tree1b57ab208cce3cad362face37e24a68312a518f0 /sqlite3.go
parentSpecify by -D (diff)
parentfixed timezone problem for datetime types (diff)
downloadgolite-c1aa7ac7060c032c5b65aaa5269680fc348ebf1c.tar.gz
golite-c1aa7ac7060c032c5b65aaa5269680fc348ebf1c.tar.xz
Merge pull request #155 from kartaca/master
fixed timezone problem for datetime types
Diffstat (limited to 'sqlite3.go')
-rw-r--r--sqlite3.go6
1 files changed, 4 insertions, 2 deletions
diff --git a/sqlite3.go b/sqlite3.go
index 69a2a9b..db6bdf7 100644
--- a/sqlite3.go
+++ b/sqlite3.go
@@ -498,7 +498,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:
@@ -525,12 +525,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
}
}