From fc339fc3e09b6d7baed643f4e1ebafd57c4e3edf Mon Sep 17 00:00:00 2001 From: slene Date: Sat, 21 Dec 2013 21:00:29 +0800 Subject: [PATCH] orm detect mysql timezone #403 --- orm/db_alias.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/orm/db_alias.go b/orm/db_alias.go index 568a3b24..ca90bf3a 100644 --- a/orm/db_alias.go +++ b/orm/db_alias.go @@ -126,7 +126,15 @@ func RegisterDataBase(aliasName, driverName, dataSource string, params ...int) { row := al.DB.QueryRow("SELECT @@session.time_zone") var tz string row.Scan(&tz) - if tz != "SYSTEM" { + if tz == "SYSTEM" { + tz = "" + row = al.DB.QueryRow("SELECT @@system_time_zone") + row.Scan(&tz) + t, err := time.Parse("MST", tz) + if err == nil { + al.TZ = t.Location() + } + } else { t, err := time.Parse("-07:00", tz) if err == nil { al.TZ = t.Location()