MCPcopy Create free account
hub / github.com/RT-Thread/env-windows / __sub__

Method __sub__

tools/python-3.11.9-amd64/Lib/datetime.py:1150–1158  ·  view source on GitHub ↗

Subtract two dates, or a date and a timedelta.

(self, other)

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 2

toordinalMethod · 0.95
timedeltaClass · 0.85

Tested by

no test coverage detected