-
Notifications
You must be signed in to change notification settings - Fork 228
proposal 175
This is a fix for Issue 175.
The current Duration.get*()
functions are inconsistent with each other and with the Timestamp.get*()
functions. The Timestamp.get*()
functions extract the named part of the date-time, e.g. timestamp('2009-02-13T23:31:30Z').getMinutes()
returns 31
. The Duration.get*()
functions mostly convert the duration into the named units, e.g. duration('3730s').getMinutes()
returns 62
. The exception is the Duration.getMilliseconds()
function which:
- is documented as returning the milliseconds component in a range 0-999;
- has a conformance test that requires conversion to milliseconds of total duration;
- follows the conformance tests for the cel-go implementation, but the spec for the other implementations.
The use of the same name for functions with different semantics is undesirable.
We believe that there are more stored expressions in the wild that might rely on the conversion behavior than the extraction behavior.
There doesn't seem to be a need for extracting unit components from a duration, nor for getting units-since-epoch for a timestamp.
The proposal is:
- Create a new set of int-valued methods
Duration.to*()
, with the more explicit name better describing the conversion semantics. - Mark the
Duration.get*()
functions as deprecated. - Update the conformance tests for
Duration.getMilliseconds()
to test that it extracts the millisecond component, as documented. - Update cel-go to match the spec, possibly with a flag for the old behavior if requested.