Skip to content
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

Merged
merged 8 commits into from
Nov 29, 2016

Conversation

tiancaiamao
Copy link
Contributor

@tiancaiamao tiancaiamao commented Nov 25, 2016

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.

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
@tiancaiamao tiancaiamao changed the title [WIP] util/types: refact Time introduce a timeInternal interface util/types: refact Time introduce a timeInternal interface Nov 28, 2016
@tiancaiamao tiancaiamao changed the title util/types: refact Time introduce a timeInternal interface util/types: refact Time introduce a TimeInternal interface Nov 28, 2016
@tiancaiamao
Copy link
Contributor Author

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))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not use "FromDate" ?

Copy link
Contributor Author

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)

@zimulala
Copy link
Contributor

LGTM

1 similar comment
@coocood
Copy link
Member

coocood commented Nov 29, 2016

LGTM

@tiancaiamao tiancaiamao force-pushed the tiancaiamao/time-internal branch from 5073d7f to e1492c4 Compare November 29, 2016 12:54
@tiancaiamao tiancaiamao merged commit 296f4a6 into master Nov 29, 2016
@tiancaiamao tiancaiamao deleted the tiancaiamao/time-internal branch December 26, 2016 06:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants