Skip to content
Toggle navigation
Toggle navigation
This project
Loading...
Sign in
张磊
/
FileStorageBeego
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
8d79f838
authored
2014-01-10 16:50:03 +0800
by
slene
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
#441 fix detect timezone in mysql
1 parent
844412c3
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
10 deletions
orm/db_alias.go
orm/db_alias.go
View file @
8d79f83
...
...
@@ -123,21 +123,18 @@ func RegisterDataBase(aliasName, driverName, dataSource string, params ...int) {
switch
al
.
Driver
{
case
DR_MySQL
:
row
:=
al
.
DB
.
QueryRow
(
"SELECT
@@session.time_zone
"
)
row
:=
al
.
DB
.
QueryRow
(
"SELECT
TIMEDIFF(NOW(), UTC_TIMESTAMP)
"
)
var
tz
string
row
.
Scan
(
&
tz
)
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
()
if
len
(
tz
)
>=
8
{
if
tz
[
0
]
!=
'-'
{
tz
=
"+"
+
tz
}
}
else
{
t
,
err
:=
time
.
Parse
(
"-07:00"
,
tz
)
t
,
err
:=
time
.
Parse
(
"-07:00:00"
,
tz
)
if
err
==
nil
{
al
.
TZ
=
t
.
Location
()
}
else
{
DebugLog
.
Printf
(
"Detect DB timezone: %s %s
\n
"
,
tz
,
err
.
Error
())
}
}
...
...
@@ -163,6 +160,8 @@ func RegisterDataBase(aliasName, driverName, dataSource string, params ...int) {
loc
,
err
:=
time
.
LoadLocation
(
tz
)
if
err
==
nil
{
al
.
TZ
=
loc
}
else
{
DebugLog
.
Printf
(
"Detect DB timezone: %s %s
\n
"
,
tz
,
err
.
Error
())
}
}
...
...
Write
Preview
Styling with
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment