PartialDate: fix __eq__ method

This commit is contained in:
Bart Schuurmans 2024-03-05 15:25:35 +01:00
parent 7066e2815b
commit 7fb079cb43

View file

@ -67,6 +67,14 @@ class PartialDate(datetime):
# current_timezone and default_timezone.
return cls.from_datetime(datetime(year, month, day, tzinfo=_westmost_tz))
def __eq__(self, other: object) -> bool:
if not isinstance(other, PartialDate):
return NotImplemented
return self.partial_isoformat() == other.partial_isoformat()
def __repr__(self) -> str:
return f"<{self.__class__.__name__} object: {self.partial_isoformat()}>"
class MonthParts(PartialDate):
"""a date bound into month precision"""