-
Notifications
You must be signed in to change notification settings - Fork 5.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
util/types: refact Time introduce a TimeInternal interface #2098
Conversation
Go time representation is not compatible with mysql, this commit is a prepare before the code refact. timeInternal is a interface for time representation, and it would make the refact more smooth.
Conflicts: sessionctx/variable/session.go
PTAL @coocood @hanfei1991 @zimulala |
if err != nil { | ||
return errors.Trace(err) | ||
} | ||
loc := local | ||
if t.Type == mysql.TypeTimestamp { | ||
loc = time.UTC | ||
} | ||
t.Time = time.Date(year, time.Month(month), day, hour, minute, second, nanosec, loc).In(local) | ||
t.Time = FromGoTime(time.Date(year, time.Month(month), day, hour, minute, second, microsec*1000, loc).In(local)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not use "FromDate" ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because we need convert UTC date to local date.
The whole argument is, notice the In()
time.Date(year, time.Month(month), day, hour, minute, second, microsec*1000, loc).In(local)
LGTM |
1 similar comment
LGTM |
5073d7f
to
e1492c4
Compare
Go time representation is not compatible with mysql, this
commit is a prepare before the code refact.
TimeInternal is a interface for time representation, and it
would make the refact more smooth.