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

Function ResolveHeadTime

engine/temporal.go:497–516  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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.
497func 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'.
519func resolveBoundWithSubst(bound ast.TemporalBound, subst unionfind.UnionFind, evalTime time.Time) (ast.TemporalBound, error) {

Calls 2

NewIntervalFunction · 0.92
resolveBoundWithSubstFunction · 0.85