mirror of
https://github.com/astaxie/beego.git
synced 2024-11-25 23:01:28 +00:00
orm detect mysql timezone #403
This commit is contained in:
parent
2c868a9557
commit
fc339fc3e0
@ -126,7 +126,15 @@ func RegisterDataBase(aliasName, driverName, dataSource string, params ...int) {
|
|||||||
row := al.DB.QueryRow("SELECT @@session.time_zone")
|
row := al.DB.QueryRow("SELECT @@session.time_zone")
|
||||||
var tz string
|
var tz string
|
||||||
row.Scan(&tz)
|
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)
|
t, err := time.Parse("-07:00", tz)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
al.TZ = t.Location()
|
al.TZ = t.Location()
|
||||||
|
Loading…
Reference in New Issue
Block a user