Get the closest time from the instance.
(self, dt1: Time | time, dt2: Time | time)
| 63 | # Comparisons |
| 64 | |
| 65 | def closest(self, dt1: Time | time, dt2: Time | time) -> Self: |
| 66 | """ |
| 67 | Get the closest time from the instance. |
| 68 | """ |
| 69 | dt1 = self.__class__(dt1.hour, dt1.minute, dt1.second, dt1.microsecond) |
| 70 | dt2 = self.__class__(dt2.hour, dt2.minute, dt2.second, dt2.microsecond) |
| 71 | |
| 72 | if self.diff(dt1).in_seconds() < self.diff(dt2).in_seconds(): |
| 73 | return dt1 |
| 74 | |
| 75 | return dt2 |
| 76 | |
| 77 | def farthest(self, dt1: Time | time, dt2: Time | time) -> Self: |
| 78 | """ |