(self, other)
return NotImplemented
Subtract two dates, or a date and a timedelta.
Subtract two dates, or a date and a timedelta.
Subtract two dates or a date and a timedelta .
def __sub__(self, other):
        """Subtract two dates, or a date and a timedelta."""
        if isinstance(other, timedelta):
            return self + timedelta(-other.days)
        if isinstance(other, date):
            days1 = self.toordinal()
            days2 = other.toordinal()
            return timedelta(days1 - days2)
        return NotImplemented
def __sub__ ( self , other ) : if isinstance ( other , timedelta ) : return self + timedelta ( - other . days ) if isinstance ( other , date ) : days1 = self . toordinal ( ) days2 = other . toordinal ( ) return timedelta ( days1 - days2 ) return NotImplemented