-
-
Notifications
You must be signed in to change notification settings - Fork 475
Adds support for common operators for time.Time #256
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
Conversation
|
Awesome. Thanks. Will try to review on weekend. |
…e and time.Duration to be passed to the operator fns.
…cker return types as they were incorrect.
|
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) |
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.
Can we add test for this part?
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.
Added to checker_test.go in 5ea8ef9.
|
bump. Are there any other areas that need attention? Is there anything blocking accepting this PR? |
|
Awesome work) really nice. Also will be cool to see some docs. |
|
Added some docs with #257. |
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 comparetime.Timeinstances, returning bool.The
+operator adds atime.Durationtotime.Time, returningtime.TimeThe
-operator returns a duration representing the diff between twotime.Timeinstances.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.
:)