def window

bend-kit-webhooks@0.11.0.1 · webhooks.bend:94

import bend-kit-webhooks@0.11.0.1/webhooks.bend as Webhooks
import Base
import bend-kit-time@0.3.0.0/time.bend as Time
import bend-kit-int@0.2.0.0/int.bend as Int

94# t within tol seconds of now, either way.
95def window(+tol: U32, now: Time.Instant, t: Int.I64) -> Result<&1, &1, Err, Unit>:
96  match now:
97    case Time.Instant{n, ns}:
98      +d = Int.I64.sub(n, t)
99      +w = Int.I64.from_u32(tol)
100      window.pick(Int.I64.is_gt(d, w), Int.I64.is_lt(d, Int.I64.neg(w)))

Uses (12)

Used by (2)