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)
| 245 | // resolveOperatorInterval converts an operator interval (with durations) to absolute timestamps. |
| 246 | // For past operators, durations are interpreted as offsets from the evaluation time. |
| 247 | func (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. |
| 265 | func (te *TemporalEvaluator) resolveBound(bound ast.TemporalBound, isPast bool) (ast.TemporalBound, error) { |
no test coverage detected