Repository: dimitarOnGithub/temporals

Issue:
DatetimePeriod implementation
Create the `is_before` and `is_after` logic for the `DatetimePeriod` class

Discussion:

Patch:
diff --git a/temporals/periods.py b/temporals/periods.py
index 5a10dda..c726532 100644
--- a/temporals/periods.py
+++ b/temporals/periods.py
@@ -818,6 +818,38 @@ class DatetimePeriod(Period):
             return self.start.time() <= item <= self.end.time()
         return False
 
+    def is_before(self,
+                  other: Union['DatePeriod', 'DatetimePeriod', date, datetime]
+                  ) -> bool:
+        """ Test if this period ends before the provided `other` value. In the cases when a date or a DatePeriod is
+        provided, the check will be done based on at least a 24 hour difference (ie, this period ends on the 2024-01-01
+        and the provided date/DatePeriod begins on the 2024-01-02). In all other cases (datetime and DatetimePeriod),
+        objects are allowed to share the same end-start datetime.
+        """
+        if isinstance(other, DatePeriod):
+            return self.end.date() < other.start
+        elif isinstance(other, datetime):
+            return self.end <= other
+        elif isinstance(other, date):
+            return self.end.date() < other
+        return self.end <= other.start
+
+    def is_after(self,
+                 other: Union['DatePeriod', 'DatetimePeriod', date, datetime]
+                 ) -> bool:
+        """ Test if this period begins after the provided `other` value. In the cases when a date or a DatePeriod is
+        provided, the check will be done based on at least a 24 hour difference (ie, this period begins on the
+        2024-01-02 and the provided date/DatePeriod ends on the 2024-01-01). In all other cases (datetime and
+        DatetimePeriod), objects are allowed to share the same end-start datetime.
+        """
+        if isinstance(other, DatePeriod):
+            return other.end < self.start.date()
+        elif isinstance(other, datetime):
+            return other <= self.start
+        elif isinstance(other, date):
+            return other < self.start.date()
+        return other.end <= self.start
+
     def overlaps_with(self,
                       other: Union['TimePeriod', 'DatePeriod', 'DatetimePeriod']
                       ) -> bool:


Test patch:
diff --git a/tests/test_datetimeperiod.py b/tests/test_datetimeperiod.py
index 5267ace..facc69d 100644
--- a/tests/test_datetimeperiod.py
+++ b/tests/test_datetimeperiod.py
@@ -202,6 +202,57 @@ class TestDatetimePeriod:
         )
         assert self.time_period not in self.period
 
+    def test_is_before(self):
+        self.start = datetime(2024, 1, 1, 8, 0)
+        self.end = datetime(2024, 1, 1, 12, 0)
+        self.period = DatetimePeriod(start=self.start, end=self.end)
+        assert self.period.is_before(date(2024, 1, 2)) is True
+        assert self.period.is_before(date(2024, 1, 1)) is False
+        assert self.period.is_before(datetime(2024, 1, 1, 12, 0)) is True
+        assert self.period.is_before(datetime(2024, 1, 1, 11, 59)) is False
+
+        self.other_start = date(2024, 1, 2)
+        self.other_end = date(2024, 1, 3)
+        self.other_period = DatePeriod(start=self.other_start, end=self.other_end)
+        assert self.period.is_before(self.other_period) is True
+
+        self.start = datetime(2024, 1, 1, 8, 0)
+        self.end = datetime(2024, 1, 5, 12, 0)
+        self.period = DatetimePeriod(start=self.start, end=self.end)
+        self.other_start = date(2024, 1, 5)
+        self.other_end = date(2024, 1, 10)
+        self.other_period = DatePeriod(start=self.other_start, end=self.other_end)
+        assert self.period.is_before(self.other_period) is False
+
+        self.other_start = datetime(2024, 1, 5, 12, 0)
+        self.other_end = datetime(2024, 3, 1, 12, 0)
+        self.other_period = DatetimePeriod(start=self.other_start, end=self.other_end)
+        assert self.period.is_before(self.other_period) is True
+
+    def test_is_after(self):
+        self.start = datetime(2024, 1, 1, 8, 0)
+        self.end = datetime(2024, 1, 1, 12, 0)
+        self.period = DatetimePeriod(start=self.start, end=self.end)
+        assert self.period.is_after(date(2023, 12, 31)) is True
+        assert self.period.is_after(date(2024, 1, 1)) is False
+        assert self.period.is_after(datetime(2024, 1, 1, 8, 0)) is True
+        assert self.period.is_after(datetime(2024, 1, 1, 8, 1)) is False
+
+        self.other_start = date(2023, 12, 1)
+        self.other_end = date(2023, 12, 31)
+        self.other_period = DatePeriod(start=self.other_start, end=self.other_end)
+        assert self.period.is_after(self.other_period) is True
+
+        self.other_start = date(2023, 12, 1)
+        self.other_end = date(2024, 1, 1)
+        self.other_period = DatePeriod(start=self.other_start, end=self.other_end)
+        assert self.period.is_after(self.other_period) is False
+
+        self.other_start = datetime(2024, 1, 1, 7, 0)
+        self.other_end = datetime(2024, 1, 1, 8, 0)
+        self.other_period = DatetimePeriod(start=self.other_start, end=self.other_end)
+        assert self.period.is_after(self.other_period) is True
+
     def test_overlaps_time(self):
         """
             Same day: