protected function timefield_pagination_to(
        $field,
        $timeto,
        $lastseentime = null,
        $lastseenid = null
    ) {
        $where = [];
        $params = [];

        if ($lastseentime && $lastseentime > $timeto) {
            // The last seen event from this set is after the time sort range which
            // means all events in this range have been seen, so we can just return
            // early here.
            return false;
        } else if ($lastseentime && $lastseentime == $timeto) {
            $where[] = '((timesort = :timeto1 AND e.id > :timetoid) OR timesort < :timeto2)';
            if ($field === 'timestart') {
                $where[] = '((timestart = :timeto1 AND e.id > :timetoid) OR timestart < :timeto2)';
            }
            $params['timetoid'] = $lastseenid;
            $params['timeto1'] = $timeto;
            $params['timeto2'] = $timeto;
        } else {
            $where[] = ($field === 'timestart' ? 'timestart' : 'timesort') . ' <= :timeto';
            $params['timeto'] = $timeto;
        }

        return ['where' => $where, 'params' => $params];
    }