protected function extractAndCheckNumber($datetimeToParse, $isTwoDigits, $minValue, $maxValue)
    {
        if ($isTwoDigits || is_numeric($datetimeToParse[1])) {
            $number = substr($datetimeToParse, 0, 2);
        } else {
            $number = $datetimeToParse[0];
        }

        if (is_numeric($number)) {
            $number = (int)$number;

            if ($number <= $maxValue || $number >= $minValue) {
                return $number;
            }
        }

        throw new Exception\InvalidParseStringException('Expected one or two-digit number not found at the beginning of the string.', 1279963654);
    }