lib: build intervals