Skip to content

Conversation

@panthershark
Copy link
Contributor

@panthershark panthershark commented Sep 23, 2022

This should resolve the following issues.

#73
#203
#227

Before starting this PR, I attempted to add support for time operators, but ended up with an impossible state b/c I cannot support interface{} -OP- interface{} without losing the built-in functionality of the operators. The only option I could see was to copy/paste/extend /vm/helpers.go.

I decided to search the issues and found that others have run into this too.


With this PR, the operators ==, >=, <=, <, > are included by default allowing users to compare time.Time instances, returning bool.

The + operator adds a time.Duration to time.Time, returning time.Time
The - operator returns a duration representing the diff between two time.Time instances.


Please lmk if there are any concerns with the implementation. Please lmk if you see any gaps in the tests. I'll be happy to fix it up.

:)

@antonmedv
Copy link
Member

Awesome. Thanks. Will try to review on weekend.

…e and time.Duration to be passed to the operator fns.
@panthershark
Copy link
Contributor Author

Sweet thanks!

I added tests to expr_test.go this morning and found I needed to update the checker for this to be fully functional. I think it is pretty close. I'm happy to fix up anything that I missed.

Thanks for making this library. :)

}
}
return false
return isInterface(t)
Copy link
Member

Choose a reason for hiding this comment

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

Can we add test for this part?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added to checker_test.go in 5ea8ef9.

@panthershark
Copy link
Contributor Author

bump. Are there any other areas that need attention? Is there anything blocking accepting this PR?

@antonmedv antonmedv merged commit cd021ef into expr-lang:master Oct 3, 2022
@antonmedv
Copy link
Member

Awesome work) really nice. Also will be cool to see some docs.

@panthershark
Copy link
Contributor Author

Added some docs with #257.

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.

2 participants