Comments (5)
I'm sorry we didn't get back to you on this sooner. The duration format we support within Go, unofficially, is what time.ParseDuration
supports: https://golang.org/src/time/format.go?s=40605:40651#L1364
This PR is about making sure the spec and other implementations support the same logic as Go since it seems to be the maximum about of usability with the least amount of confusion.
As for type conversions, we don't make any assumptions about units and offer timestamp
+ duration
overloads, but no overload for duration
+ int
as it's not clear what the intent is of the unit-less number. I don't think it's a super common use case to add two duration values constructed from string inputs, but I could be wrong. The preferred technique would be: duration("2h30m45s") + duration("2s") == duration("8456s")
from cel-spec.
Are these normalized in any way when a duration is the output from the expression? Would a trivial expression like duration("2h30m45s")
output duration("8454s")
? Would we need timestamp-like extractor methods for days and weeks? double(duration("8454s").days()) == 0.097847
?
Also. What about type conversions? Would these have an assumed unit? duration("2h30m45s") + 2 == duration("8456s")
Or would there be no overload for this?
from cel-spec.
This would be very nice to have, and the option of `duration("2h30m45s") over adding each unit separately seems nicer. Both cel-go and cel-cpp supports this, so one might just as well formalize it.
Also, I believe fractional seconds are allowed in both cel-go and cel-cpp (cel-cpp seems to use absl::ParseDuration which afaict is essentially the same logic as time.ParseDuration
), but it is not clear that this is the case in the spec.
from cel-spec.
The go syntax seems like a reasonable standard to follow. There doesn't seem to be a standard duration notation in Google SQL or Javascript - the prototype languages we try to follow. There's an ISO-8601 notation for durations, but it's clunky and and not compatible with the current "120s" notation.
from cel-spec.
A common subset of the duration parsing syntax supported by Go (native), Java (threeten-extra), and C++ (abseil.io) has been introduced in all of the runtimes, and the spec now clarifies the supported notation and character set. Days is not supported, but more granular units are. See #185
from cel-spec.
Related Issues (20)
- Conformance tests for heterogeneous numeric in/equality HOT 1
- Allow optional trailing commas in function calls
- Is the cel-spec compatible with Kotlin, if so, how do I add this in my project? HOT 1
- pseudo numeric values in map keys HOT 1
- CeL pure functions HOT 1
- Merging maps HOT 2
- Optional Values Support HOT 4
- Map to Map/List conversion
- CIDR block validation HOT 1
- has() macro for complicated map key HOT 1
- Does cel support regex syntax? HOT 1
- Will cel be moving to a new organization? HOT 1
- [Question] how to specify now()? HOT 3
- Support jq x[] operation
- Support bitwise operators HOT 3
- C spex
- Link to the implementation dashboard is broken. HOT 1
- Function Definitions and Variables HOT 2
- Protobuf extensions HOT 2
- Checking for undeclared reference HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cel-spec.