Subtract two dates, or a date and a timedelta.
(self, other)
| 1148 | __radd__ = __add__ |
| 1149 | |
| 1150 | def __sub__(self, other): |
| 1151 | """Subtract two dates, or a date and a timedelta.""" |
| 1152 | if isinstance(other, timedelta): |
| 1153 | return self + timedelta(-other.days) |
| 1154 | if isinstance(other, date): |
| 1155 | days1 = self.toordinal() |
| 1156 | days2 = other.toordinal() |
| 1157 | return timedelta(days1 - days2) |
| 1158 | return NotImplemented |
| 1159 | |
| 1160 | def weekday(self): |
| 1161 | "Return day of the week, where Monday == 0 ... Sunday == 6." |