예제 #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)
예제 #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)
예제 #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)
예제 #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)