spatie / period

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

Overlap all (n^2) #27

Closed zstima closed 5 years ago

zstima commented 5 years ago
/*
 * A       [========]
 * B             [==]
 * C                                         [=====]
 * D                                         [===============]
 *
 * OVERLAP       [==]                        [=====]
 */

how would one combine the given overlap,diff,and gap functions to get such collection as described in the graph above?

brendt commented 5 years ago

Seems like an overlapAny function would be useful? I'd accepted a tested PR for that.

brendt commented 5 years ago

To answer your question on the top of my head: I'd first loop over all periods and group them together whether they overlap or not, and than calculate the overlaps for each group.

zstima commented 5 years ago

nice, your experience pays out.

its so simple !

will make a pr when i make time

zstima commented 5 years ago

could u make software that produces php code for any input graph ?

brendt commented 5 years ago

I'm not sure what you mean. I'll be closing this issue and await for a PR to be submitted.