orm detect mysql timezone #403
Showing
1 changed file
with
9 additions
and
1 deletions
| ... | @@ -126,7 +126,15 @@ func RegisterDataBase(aliasName, driverName, dataSource string, params ...int) { | ... | @@ -126,7 +126,15 @@ func RegisterDataBase(aliasName, driverName, dataSource string, params ...int) { |
| 126 | row := al.DB.QueryRow("SELECT @@session.time_zone") | 126 | row := al.DB.QueryRow("SELECT @@session.time_zone") |
| 127 | var tz string | 127 | var tz string |
| 128 | row.Scan(&tz) | 128 | row.Scan(&tz) |
| 129 | if tz != "SYSTEM" { | 129 | if tz == "SYSTEM" { |
| 130 | tz = "" | ||
| 131 | row = al.DB.QueryRow("SELECT @@system_time_zone") | ||
| 132 | row.Scan(&tz) | ||
| 133 | t, err := time.Parse("MST", tz) | ||
| 134 | if err == nil { | ||
| 135 | al.TZ = t.Location() | ||
| 136 | } | ||
| 137 | } else { | ||
| 130 | t, err := time.Parse("-07:00", tz) | 138 | t, err := time.Parse("-07:00", tz) |
| 131 | if err == nil { | 139 | if err == nil { |
| 132 | al.TZ = t.Location() | 140 | al.TZ = t.Location() | ... | ... |
-
Please register or sign in to post a comment