Skip to content
Advertisement

Separate date to several intervals

I’ve got an array like the following :

JavaScript

And another array :

JavaScript

I would like to create a new $array3 that removes the intervals from $array2 in $array1 to give the following result :

JavaScript

As you can see, in $array3 2 new entries were added to remove the interval used in $array2. I don’t know how can I tackle an algorithm to do this. Any help, advice or resources is appreciated.

Note that, in $array1 there will never be 2 same intervals, intervals are unique.

Advertisement

Answer

Here it is

JavaScript
User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement