| 1537 | return NotImplemented |
| 1538 | |
| 1539 | def _cmp(self, other, allow_mixed=False): |
| 1540 | assert isinstance(other, time) |
| 1541 | mytz = self._tzinfo |
| 1542 | ottz = other._tzinfo |
| 1543 | myoff = otoff = None |
| 1544 | |
| 1545 | if mytz is ottz: |
| 1546 | base_compare = True |
| 1547 | else: |
| 1548 | myoff = self.utcoffset() |
| 1549 | otoff = other.utcoffset() |
| 1550 | base_compare = myoff == otoff |
| 1551 | |
| 1552 | if base_compare: |
| 1553 | return _cmp((self._hour, self._minute, self._second, |
| 1554 | self._microsecond), |
| 1555 | (other._hour, other._minute, other._second, |
| 1556 | other._microsecond)) |
| 1557 | if myoff is None or otoff is None: |
| 1558 | if allow_mixed: |
| 1559 | return 2 # arbitrary non-zero value |
| 1560 | else: |
| 1561 | raise TypeError("cannot compare naive and aware times") |
| 1562 | myhhmm = self._hour * 60 + self._minute - myoff//timedelta(minutes=1) |
| 1563 | othhmm = other._hour * 60 + other._minute - otoff//timedelta(minutes=1) |
| 1564 | return _cmp((myhhmm, self._second, self._microsecond), |
| 1565 | (othhmm, other._second, other._microsecond)) |
| 1566 | |
| 1567 | def __hash__(self): |
| 1568 | """Hash.""" |