ResolveHeadTime resolves variables and special bounds (like 'now') in a HeadTime interval using the given substitution. Returns the resolved interval or nil if HeadTime is nil.
(headTime *ast.Interval, subst unionfind.UnionFind, evalTime time.Time)
| 495 | // ResolveHeadTime resolves variables and special bounds (like 'now') in a HeadTime interval |
| 496 | // using the given substitution. Returns the resolved interval or nil if HeadTime is nil. |
| 497 | func ResolveHeadTime(headTime *ast.Interval, subst unionfind.UnionFind, evalTime time.Time) (*ast.Interval, error) { |
| 498 | if headTime == nil { |
| 499 | return nil, nil |
| 500 | } |
| 501 | |
| 502 | // Resolve start bound |
| 503 | start, err := resolveBoundWithSubst(headTime.Start, subst, evalTime) |
| 504 | if err != nil { |
| 505 | return nil, fmt.Errorf("failed to resolve start bound: %w", err) |
| 506 | } |
| 507 | |
| 508 | // Resolve end bound |
| 509 | end, err := resolveBoundWithSubst(headTime.End, subst, evalTime) |
| 510 | if err != nil { |
| 511 | return nil, fmt.Errorf("failed to resolve end bound: %w", err) |
| 512 | } |
| 513 | |
| 514 | resolved := ast.NewInterval(start, end) |
| 515 | return &resolved, nil |
| 516 | } |
| 517 | |
| 518 | // resolveBoundWithSubst resolves a temporal bound, substituting variables and handling 'now'. |
| 519 | func resolveBoundWithSubst(bound ast.TemporalBound, subst unionfind.UnionFind, evalTime time.Time) (ast.TemporalBound, error) { |