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

Parse time literals using the time zone in the select statement #8642

Merged
merged 1 commit into from
Jul 28, 2017

Conversation

jsternberg
Copy link
Contributor

@jsternberg jsternberg commented Jul 27, 2017

Fixes #8639.

@jsternberg jsternberg force-pushed the js-8639-parse-time-literals-with-location branch from 1195f9d to 950753d Compare July 27, 2017 18:06
@rbetts rbetts added this to the 1.4.0 milestone Jul 28, 2017
Copy link
Contributor

@desa desa left a comment

Choose a reason for hiding this comment

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

LGTM. Mostly just a couple general questions/comments.

@@ -4868,7 +4877,7 @@ func reduceBinaryExprBooleanLHS(op Token, lhs *BooleanLiteral, rhs Expr) Expr {
return &BinaryExpr{Op: op, LHS: lhs, RHS: rhs}
}

func reduceBinaryExprDurationLHS(op Token, lhs *DurationLiteral, rhs Expr) Expr {
func reduceBinaryExprDurationLHS(op Token, lhs *DurationLiteral, rhs Expr, loc *time.Location) Expr {
Copy link
Contributor

Choose a reason for hiding this comment

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

Kind of sucks that this bleeds into the some of the binary expression reducing. Guess it has to though.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yea, I didn't like this. Might be improved in the future with some better parsing of the expression.

@@ -5300,9 +5309,16 @@ type Valuer interface {
Value(key string) (interface{}, bool)
}

// ZoneValuer is the interface that specifies the current time zone.
type ZoneValuer interface {
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we really need this interface? Seems like the only place this gets used is

+	loc := time.UTC
 +	if v, ok := valuer.(ZoneValuer); ok {
 +		loc = v.Zone()
 +	}

Is there any anticipation that there will be anything else that implements ZoneValuer?

I guess I've never quite understood why people use create an interface (it seems pretty common) for something where a concrete type would suffice.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's because this is an extension of the Valuer interface and not all Valuers can have a Zone method.

Copy link
Contributor

Choose a reason for hiding this comment

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

But you could just as easily casted to a NowValuer

@jsternberg jsternberg merged commit fcc5184 into master Jul 28, 2017
@jsternberg jsternberg deleted the js-8639-parse-time-literals-with-location branch July 28, 2017 17:35
jsternberg added a commit that referenced this pull request Jul 28, 2017
jsternberg added a commit that referenced this pull request Aug 8, 2017
jsternberg added a commit that referenced this pull request Aug 10, 2017
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