protected function get_timestamp_max_limit(\DateTimeInterface $starttime, $max) {
        // We're doing a similar calculation here as we are for the minimum
        // day timestamp. See the explanation above.
        $values = [];
        $timestamp = $max[0];
        $errorstring = $max[1];
        $maxdate = (new \DateTimeImmutable())->setTimestamp($timestamp);
        $maxstart = $maxdate->setTime(
            $starttime->format('H'),
            $starttime->format('i'),
            $starttime->format('s')
        );
        $midnight = usergetmidnight($timestamp);

        if ($maxdate >= $maxstart) {
            $values['maxdaytimestamp'] = $midnight;
        } else {
            $yesterday = (new \DateTime())->setTimestamp($midnight)->modify('-1 day');
            $values['maxdaytimestamp'] = $yesterday->getTimestamp();
        }

        // Get the human readable error message to display if the max day
        // timestamp is violated.
        $values['maxdayerror'] = $errorstring;
        return $values;
    }