Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

bucket

quantize a time or duration value into buckets of equal time spans

Synopsis

bucket(val: time, span: duration) -> time
bucket(val: duration, span: duration) -> duration

Description

The bucket function quantizes a time or duration val into buckets that are equally spaced as specified by span where the bucket boundary aligns with 0.

Examples


Bucket a couple times to hour intervals

# spq
values bucket(this::time, 1h)
# input
2020-05-26T15:27:47Z
"5/26/2020 3:27pm"
# expected output
2020-05-26T15:00:00Z
2020-05-26T15:00:00Z