MCPcopy Index your code
hub / github.com/python/cpython / __sub__

Method __sub__

Lib/_pydatetime.py:1238–1246  ·  view source on GitHub ↗

Subtract two dates, or a date and a timedelta.

(self, other)

Source from the content-addressed store, hash-verified

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."

Callers

nothing calls this directly

Calls 2

toordinalMethod · 0.95
timedeltaClass · 0.85

Tested by

no test coverage detected