aboutsummaryrefslogtreecommitdiff
path: root/sqlite3.go
diff options
context:
space:
mode:
authordeepilla <hello@deepilla.com>2017-06-30 13:17:04 -0500
committerdeepilla <hello@deepilla.com>2017-06-30 13:17:04 -0500
commit05123859bed77249c3d9ca8efe6adc3cce1e1bed (patch)
treeecca0bc608fe592ac2007e6cb180c71a1375b558 /sqlite3.go
parentMerge pull request #429 from emakeev/cgo_panic_fix (diff)
downloadgolite-05123859bed77249c3d9ca8efe6adc3cce1e1bed.tar.gz
golite-05123859bed77249c3d9ca8efe6adc3cce1e1bed.tar.xz
Don't convert Unix times to nanoseconds when querying datetime fields. Fixes #430.
Diffstat (limited to 'sqlite3.go')
-rw-r--r--sqlite3.go5
1 files changed, 3 insertions, 2 deletions
diff --git a/sqlite3.go b/sqlite3.go
index b34c3a5..d3a6407 100644
--- a/sqlite3.go
+++ b/sqlite3.go
@@ -961,10 +961,11 @@ func (rc *SQLiteRows) Next(dest []driver.Value) error {
// large to be a reasonable timestamp in seconds.
if val > 1e12 || val < -1e12 {
val *= int64(time.Millisecond) // convert ms to nsec
+ t = time.Unix(0, val)
} else {
- val *= int64(time.Second) // convert sec to nsec
+ t = time.Unix(val, 0)
}
- t = time.Unix(0, val).UTC()
+ t = t.UTC()
if rc.s.c.loc != nil {
t = t.In(rc.s.c.loc)
}