def max_consecutive_days(self) -> Optional[Tuple[int, Interval]]:
        """
        The length of the longest sequence of days in which all days include
        an interval.

        Returns:
             tuple:
                ``(longest_length, longest_interval)`` where
                ``longest_interval`` is a :class:`Interval` containing the
                start and end date of the longest span -- or ``None`` if we
                contain no intervals.
        """
        if len(self.intervals) == 0:
            return None
        startdate = self.start_date()
        enddate = self.end_date()
        seq = ''
        ndays = (enddate - startdate).days + 1
        for i in range(ndays):
            date = startdate + datetime.timedelta(days=i)
            wholeday = Interval.wholeday(date)
            if any([x.overlaps(wholeday) for x in self.intervals]):
                seq += '+'
            else:
                seq += ' '
        # noinspection PyTypeChecker
        longest = max(seq.split(), key=len)
        longest_len = len(longest)
        longest_idx = seq.index(longest)
        longest_interval = Interval.dayspan(
            startdate + datetime.timedelta(days=longest_idx),
            startdate + datetime.timedelta(days=longest_idx + longest_len)
        )
        return longest_len, longest_interval
def max_consecutive_days ( self ) -> Optional [ Tuple [ int , Interval ] ] : if len ( self . intervals ) == 0 : return None startdate = self . start_date ( ) enddate = self . end_date ( ) seq = '' ndays = ( enddate - startdate ) . days + 1 for i in range ( ndays ) : date = startdate + datetime . timedelta ( days = i ) wholeday = Interval . wholeday ( date ) if any ( [ x . overlaps ( wholeday ) for x in self . intervals ] ) : seq += '+' else : seq += ' ' longest = max ( seq . split ( ) , key = len ) longest_len = len ( longest ) longest_idx = seq . index ( longest ) longest_interval = Interval . dayspan ( startdate + datetime . timedelta ( days = longest_idx ) , startdate + datetime . timedelta ( days = longest_idx + longest_len ) ) return longest_len , longest_interval
The length of the longest sequence of days in which all days include
        an interval.

        Returns:
             tuple:
                ``(longest_length, longest_interval)`` where
                ``longest_interval`` is a :class:`Interval` containing the
                start and end date of the longest span -- or ``None`` if we
                contain no intervals.