How to know – will 2 eternal repeatable intervals overlap in the future (reopened)


This Content is from Stack Overflow. Question asked by Satoshi

In brief, I have:

startTime (When my interval chain will start)

repeatEveryMinuteInterval (Repeat every minute of this action)

duration (Duration of the action)

It builds the chain of the intervals. Example 1:

StartTime - 15:00 UTC 9/19/2022
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 UTC 10/19/2022
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.

From the implementation point of view, I have figured out 3 ways, and all of them are dummy )

1.) Assume post that they will overlap as it is an endless set and impossible to calculate and have a consistent result.

2.) To calculate maybe the next 1000 of the iterations and compare. The thing is that I don’t know how many times should i iterate to have a valid result and for this operation not to take a lot of time to calculate.

UPD: If anyone has a solution with or without time zones, I will be glad to communicate. Thanks

I am reopening my question as a received update from the CryptoFool that this problem can be solved.

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


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?