Get the closest date from the instance.
(self, dt1: date, dt2: date)
| 108 | # COMPARISONS |
| 109 | |
| 110 | def closest(self, dt1: date, dt2: date) -> Self: |
| 111 | """ |
| 112 | Get the closest date from the instance. |
| 113 | """ |
| 114 | dt1 = self.__class__(dt1.year, dt1.month, dt1.day) |
| 115 | dt2 = self.__class__(dt2.year, dt2.month, dt2.day) |
| 116 | |
| 117 | if self.diff(dt1).in_seconds() < self.diff(dt2).in_seconds(): |
| 118 | return dt1 |
| 119 | |
| 120 | return dt2 |
| 121 | |
| 122 | def farthest(self, dt1: date, dt2: date) -> Self: |
| 123 | """ |