-
Notifications
You must be signed in to change notification settings - Fork 232
proposal 185
This is a fix for Issue 185.
The current duration(string)
function accepts a floating point value with a s
suffix indicating a duration in seconds which is at parity with what the protobuf
utilities support for parsing google.protobuf.Duration
values from strings;
however, this format is incredibly difficult to use in practice. A more human-
readable format like the one supported by golang time..ParseDuration
would
vastly improve the usability of duration(string)
.
The golang time.ParseDuration
method supports an easy to read duration string
as input:
Examples:
0
1h2m3..4s
+2.999999999us
-24h
Grammer:
duration: sign? (0 | (digit ('.' digit)? unit)+)
sign: ('+' | '-')
digit: 0..9+
unit: ('ns' | 'us' | 'ms' | 's' | 'm' | 'h')
This functionality is also available in the abseil.io C++ libraries as
time::ParseDuration
.
Go and C++ support inf
as an input, but as the input is not a valid
google.protobuf.Duration
value, infinite duration values should not be accepted
in CEL. Likewise, the valid duration range will be limited to the duration values
which can be supported by the google.protobuf.Duration