spatie / period

Complex period comparisons
https://spatie.be/open-source
MIT License
1.55k stars 72 forks source link

Created a PeriodCollection, tried ->overlapAll() but it returns the same collection of periods, not overlaps #113

Closed startupskateboard closed 1 year ago

startupskateboard commented 1 year ago

I've created the following PeriodCollection:

$dayPeriods = new PeriodCollection();

//period one

$period = Period::make('2022-11-16 21:00:00.0 UTC (+00:00)', '2022-11-16 23:00:00.0 UTC (+00:00)', Precision::MINUTE()); (the start and ends are actually carbon times, but ive made them strings for simplification)
 $dayPeriods = $dayPeriods->add($period);

//period two

$period = Period::make('2022-11-16 22:00:00.0 UTC (+00:00)', '2022-11-16 23:00:00.0 UTC (+00:00)', Precision::MINUTE());
 $dayPeriods = $dayPeriods->add($period);

//period three

$period = Period::make('2022-11-16 22:00:00.0 UTC (+00:00)', '2022-11-16 23:00:00.0 UTC (+00:00)', Precision::MINUTE());
 $dayPeriods = $dayPeriods->add($period);

when I run $overlap = $dayPeriods->overlapAll();

The $overlap is simply the same period collection with exactly the same 3 periods I've defined, it doesn't return the overlaps between the 3 periods inside the period collection.

Any idea why this is happening?