def dayspan(startdate: datetime.date,
                enddate: datetime.date,
                include_end: bool = True) -> Optional["Interval"]:
        """
        Returns an :class:`Interval` representing the date range given, from
        midnight at the start of the first day to midnight at the end of the
        last (i.e. at the start of the next day after the last), or if
        include_end is False, 24h before that.

        If the parameters are invalid, returns ``None``.
        """
        if enddate < startdate:
            return None
        if enddate == startdate and include_end:
            return None
        start_dt = datetime.datetime.combine(startdate, datetime.time())
        end_dt = datetime.datetime.combine(enddate, datetime.time())
        if include_end:
            end_dt += datetime.timedelta(days=1)
        return Interval(start_dt, end_dt)