Exemple #1
0
    def test_intersect_excluded(self):
        start = Pendulum(2016, 8, 7)
        end = start.add(weeks=1)
        p1 = Period(start, end)
        intersection = p1.intersect(
            Period(start.add(days=-2), start.add(days=-1)))

        self.assertIsNone(intersection)
Exemple #2
0
    def test_intersect_same(self):
        start = Pendulum(2016, 8, 7)
        end = start.add(weeks=1)
        p1 = Period(start, end)
        intersection = p1.intersect(Period(start.copy(), end.copy()))

        self.assertPendulum(intersection.start, 2016, 8, 7)
        self.assertPendulum(intersection.end, 2016, 8, 14)
Exemple #3
0
    def test_intersect_included(self):
        start = Pendulum(2016, 8, 7)
        end = start.add(weeks=1)
        p1 = Period(start, end)
        intersection = p1.intersect(
            Period(start.add(days=2), start.add(days=4)))

        self.assertPendulum(intersection.start, 2016, 8, 9)
        self.assertPendulum(intersection.end, 2016, 8, 11)
Exemple #4
0
    def test_intersect_multiple(self):
        start = Pendulum(2016, 8, 7)
        end = start.add(weeks=1)
        p1 = Period(start, end)
        intersection = p1.intersect(
            Period(start.add(days=-2), start.add(days=2)),
            Period(start.add(days=1), start.add(days=2)))

        self.assertPendulum(intersection.start, 2016, 8, 8)
        self.assertPendulum(intersection.end, 2016, 8, 9)