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