MCPcopy Index your code
hub / github.com/google/mangle / intervalToConstant

Function intervalToConstant

engine/temporal.go:463–481  ·  view source on GitHub ↗

intervalToConstant converts an interval to a Mangle constant (pair of numbers).

(interval ast.Interval)

Source from the content-addressed store, hash-verified

461
462// intervalToConstant converts an interval to a Mangle constant (pair of numbers).
463func intervalToConstant(interval ast.Interval) ast.Constant {
464 var startNano, endNano int64
465
466 if interval.Start.Type == ast.TimestampBound {
467 startNano = interval.Start.Timestamp
468 } else if interval.Start.Type == ast.NegativeInfinityBound {
469 startNano = math.MinInt64 // -inf
470 }
471
472 if interval.End.Type == ast.TimestampBound {
473 endNano = interval.End.Timestamp
474 } else if interval.End.Type == ast.PositiveInfinityBound {
475 endNano = math.MaxInt64 // +inf
476 }
477
478 startConst := ast.Number(startNano)
479 endConst := ast.Number(endNano)
480 return ast.Pair(&startConst, &endConst)
481}
482
483// premiseTemporalLiteral evaluates a temporal literal premise.
484// This is called from oneStepEvalPremise when encountering a TemporalLiteral.

Callers 1

Calls 2

NumberFunction · 0.92
PairFunction · 0.92

Tested by 1