paranoiq / dogma

Things and stuffs.
Other
25 stars 9 forks source link

DateTimeIntervalSet::normalize() not always normalize fully #28

Open VladaHejda opened 2 months ago

VladaHejda commented 2 months ago

DateTimeIntervalSet::normalize() not always normalize fully:

        use Dogma\Time\DateTime;
        use Dogma\Time\Interval\DateTimeInterval;
        use Dogma\Time\Interval\DateTimeIntervalSet;

        $i1 = new DateTimeInterval(new DateTime('2024-09-01'), new DateTime('2024-09-10'));
        $i2 = new DateTimeInterval(new DateTime('2024-08-01'), new DateTime('2024-08-10'));
        $i3 = new DateTimeInterval(new DateTime('2024-07-20'), new DateTime('2024-09-02'));

        $s = new DateTimeIntervalSet([$i1, $i2, $i3]);
        var_dump(count($s->getIntervals())); // 3

        $s = $s->normalize();
        var_dump(count($s->getIntervals())); // 2

        $s = $s->normalize();
        var_dump(count($s->getIntervals())); // 1
VladaHejda commented 1 month ago

144b62b454ac54f0df28b8c2d44e69d119669336 solves