MCPcopy
hub / github.com/google/mangle / resolveOperatorInterval

Method resolveOperatorInterval

engine/temporal.go:247–262  ·  view source on GitHub ↗

resolveOperatorInterval converts an operator interval (with durations) to absolute timestamps. For past operators, durations are interpreted as offsets from the evaluation time.

(interval ast.Interval)

Source from the content-addressed store, hash-verified

245// resolveOperatorInterval converts an operator interval (with durations) to absolute timestamps.
246// For past operators, durations are interpreted as offsets from the evaluation time.
247func (te *TemporalEvaluator) resolveOperatorInterval(interval ast.Interval) (ast.Interval, error) {
248 start, err := te.resolveBound(interval.Start, true) // true = past operator
249 if err != nil {
250 return ast.Interval{}, err
251 }
252
253 end, err := te.resolveBound(interval.End, true)
254 if err != nil {
255 return ast.Interval{}, err
256 }
257
258 // For past operators with duration bounds, the semantics are:
259 // <-[0d, 7d] means "from 7 days ago to now"
260 // So start should be the larger duration (further in past) and end the smaller
261 return ast.NewInterval(end, start), nil // Note: swapped because past operators
262}
263
264// resolveBound converts a temporal bound to an absolute timestamp.
265func (te *TemporalEvaluator) resolveBound(bound ast.TemporalBound, isPast bool) (ast.TemporalBound, error) {

Callers 2

evalDiamondMinusMethod · 0.95
evalBoxMinusMethod · 0.95

Calls 2

resolveBoundMethod · 0.95
NewIntervalFunction · 0.92

Tested by

no test coverage detected