orm detect mysql timezone #403

This commit is contained in:
slene 2013-12-21 21:00:29 +08:00
parent 2c868a9557
commit fc339fc3e0
1 changed files with 9 additions and 1 deletions

View File

@ -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()