Subtract two dates, or a date and a timedelta.
(self, other)
| 1236 | __radd__ = __add__ |
| 1237 | |
| 1238 | def __sub__(self, other): |
| 1239 | """Subtract two dates, or a date and a timedelta.""" |
| 1240 | if isinstance(other, timedelta): |
| 1241 | return self + timedelta(-other.days) |
| 1242 | if isinstance(other, date): |
| 1243 | days1 = self.toordinal() |
| 1244 | days2 = other.toordinal() |
| 1245 | return timedelta(days1 - days2) |
| 1246 | return NotImplemented |
| 1247 | |
| 1248 | def weekday(self): |
| 1249 | "Return day of the week, where Monday == 0 ... Sunday == 6." |