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

Method _cmp

tools/python-3.11.9-amd64/Lib/datetime.py:1439–1465  ·  view source on GitHub ↗
(self, other, allow_mixed=False)

Source from the content-addressed store, hash-verified

1437 return NotImplemented
1438
1439 def _cmp(self, other, allow_mixed=False):
1440 assert isinstance(other, time)
1441 mytz = self._tzinfo
1442 ottz = other._tzinfo
1443 myoff = otoff = None
1444
1445 if mytz is ottz:
1446 base_compare = True
1447 else:
1448 myoff = self.utcoffset()
1449 otoff = other.utcoffset()
1450 base_compare = myoff == otoff
1451
1452 if base_compare:
1453 return _cmp((self._hour, self._minute, self._second,
1454 self._microsecond),
1455 (other._hour, other._minute, other._second,
1456 other._microsecond))
1457 if myoff is None or otoff is None:
1458 if allow_mixed:
1459 return 2 # arbitrary non-zero value
1460 else:
1461 raise TypeError("cannot compare naive and aware times")
1462 myhhmm = self._hour * 60 + self._minute - myoff//timedelta(minutes=1)
1463 othhmm = other._hour * 60 + other._minute - otoff//timedelta(minutes=1)
1464 return _cmp((myhhmm, self._second, self._microsecond),
1465 (othhmm, other._second, other._microsecond))
1466
1467 def __hash__(self):
1468 """Hash."""

Callers 5

__eq__Method · 0.95
__le__Method · 0.95
__lt__Method · 0.95
__ge__Method · 0.95
__gt__Method · 0.95

Calls 3

utcoffsetMethod · 0.95
timedeltaClass · 0.85
_cmpFunction · 0.70

Tested by

no test coverage detected