Skip to content

Conversation

@hudlow
Copy link
Contributor

@hudlow hudlow commented Dec 22, 2025

I'm not particularly happy for duration strings to disagree with the CEL grammar about numbers allowing trailing decimal points, and for units to be allowed with any order and any repetition.

I'm pretty unhappy about silently truncating fractional nanoseconds.

But I'm assuming the pragmatic view here is that what cel-go already implements is the correct behavior so that is what I have (hopefully) specified and tested here.

@hudlow hudlow changed the title Add conformance tests for parsing duration strings Clarify duration string parsing Dec 22, 2025
@jnthntatum
Copy link
Collaborator

/gcbrun

as days or weeks, are not supported as this would necessitate an understanding
of the locale of the execution context to account for leap seconds and leap
years.
Duration strings support decimal values with the following unit suffixes:
Copy link
Collaborator

Choose a reason for hiding this comment

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

The cel-go implementation is just using go's stdlib time.ParseDuration. For cel-cpp and cel-java, we use libraries that cite go as the format spec and reference implementation. so might make sense to to cite the godoc here?

fwiw abseil doesn't handle mu for microseconds so there are at least some inconsistencies for cel-cpp.

@TristonianJones thoughts?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

so might make sense to to cite the godoc here

I don't think it has anything to offer. In my experience, Pike is nakedly hostile to tightly-specified behavior, and time.ParseDuration seems like no exception — if we want a spec, I think we have to own it here.

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