From 7fb079cb43ed7260efd796ba65216790814617f4 Mon Sep 17 00:00:00 2001 From: Bart Schuurmans Date: Tue, 5 Mar 2024 15:25:35 +0100 Subject: [PATCH] PartialDate: fix __eq__ method --- bookwyrm/utils/partial_date.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/bookwyrm/utils/partial_date.py b/bookwyrm/utils/partial_date.py index 40b89c838..4c9391476 100644 --- a/bookwyrm/utils/partial_date.py +++ b/bookwyrm/utils/partial_date.py @@ -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"""