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

Comparing timestamps? #357

Closed
mholt opened this issue May 21, 2020 · 10 comments · Fixed by #358
Closed

Comparing timestamps? #357

mholt opened this issue May 21, 2020 · 10 comments · Fixed by #358

Comments

@mholt
Copy link

mholt commented May 21, 2020

Hi, sorry for the lame question -- how can I compare timestamps using CEL + this library?

I tried timestamp(0) == timestamp(0) but I get false every time.

Is there a reference I could read about how to do this?

@TristonianJones
Copy link
Collaborator

That should work. Let me add a quick conformance test and get back to you.

@mholt
Copy link
Author

mholt commented May 21, 2020

It's very possible there is a bug on my end too -- I will dig down more, now that I know that should work.

@TristonianJones
Copy link
Collaborator

Ah, there's no overload for timestamp from epoch:
type conversion error from 'int' to 'google.protobuf.Timestamp', wanted true

We could add one if you like. I see no reason not to support this.

@TristonianJones
Copy link
Collaborator

TristonianJones commented May 21, 2020

@mholt This is a bug on our side. Sorry about this. It's clearly in the checker, but not in the interpreter.

@mholt
Copy link
Author

mholt commented May 21, 2020

No worries, thanks for checking!

My objective is to compare timestamps. I would prefer to use == < > operators since they are so convenient. If it's not too much trouble, I think it could be really useful.

@TristonianJones
Copy link
Collaborator

TristonianJones commented May 21, 2020

Oh, yes, the comparisons are certainly supported. The problem is that the function declaration was added to the Go type-checker, but not the interpreter. We missed it in our conformance audit since the spec indicates that only timestamp(string) is supported. I'll add an issue to update the spec, but will fix the Go implementation shortly.

@TristonianJones
Copy link
Collaborator

@mholt I'll put together a point release once this is checked in.

@mholt
Copy link
Author

mholt commented May 21, 2020

Thanks! That's fast!

@TristonianJones
Copy link
Collaborator

@mholt You should be all set to bump up to v0.5.1 :) Thanks for the reaching out!

@mholt
Copy link
Author

mholt commented May 22, 2020

Works like a charm. Thank you very much!

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 a pull request may close this issue.

3 participants
@TristonianJones @mholt and others