How to know – will 2 repeatable intervals overlap in the future

Issue

This Content is from Stack Overflow. Question asked by Satoshi

In brief, I have:

startTime (When my interval chain will start)

repeatEveryMinuteInterval (Repeat every minutes this action)

duration (Duration of the action)

It builds the chain of the intervals. Example 1:

StartTime - 15:00
repeatEveryMinuteInterval - 15
duration - 5 minutes

15:00 - 15:05
15:15 - 15:20
15:30 - 15:35
15:45 - 15:50
16:00 - 16:05
// as it is endless it will iterate an infinite number of times

Example 2:

StartTime - 03:07
repeatEveryMinuteInterval - 30
duration - 5 minutes

03:07- 03:12
03:37- 03:12
04:07- 04:12
// as it is endless it will iterate an infinite number of times

My question is: as these 2 interval chains do not have an end, how can I know that they wouldn’t overlap in the future?

I assume, that 2 intervals overlap if they share the same time even partially.

15:30 - 15:45
15:25 - 15:31 

They are overlapping as they both have 15:30 - 15:31 in the intervals.



Solution

This question is not yet answered, be the first one who answer using the comment. Later the confirmed answer will be published as the solution.

This Question and Answer are collected from stackoverflow and tested by JTuto community, is licensed under the terms of CC BY-SA 2.5. - CC BY-SA 3.0. - CC BY-SA 4.0.

people found this article helpful. What about you?