Hello,
I'm currently stuggling with an algorithm for determing the delay between timer calls. Allow me to describe the problem first:
A user is able to setup a batch command that will either run at a specified interval or only once at the specific point in time. Due the required flexibility, the user should only be required to set the interval. If for example the user sets an interval of 10 minutes (600sec), the command should be executed at 12.00, 12.10, 12.20 and so on.
The problem currently is that if the user created the command at 12.27, how I can calculate the next offset of the command and calculate the delay in second between Now and the next "interval".
Calculating the offset between the two times is not the problem, I'm just looking for an algorithm that will give me the next interval based upon the current datetime.
Extra issue: The interval can be increased up to 24hours...
I'm currently stuggling with an algorithm for determing the delay between timer calls. Allow me to describe the problem first:
A user is able to setup a batch command that will either run at a specified interval or only once at the specific point in time. Due the required flexibility, the user should only be required to set the interval. If for example the user sets an interval of 10 minutes (600sec), the command should be executed at 12.00, 12.10, 12.20 and so on.
The problem currently is that if the user created the command at 12.27, how I can calculate the next offset of the command and calculate the delay in second between Now and the next "interval".
Calculating the offset between the two times is not the problem, I'm just looking for an algorithm that will give me the next interval based upon the current datetime.
Extra issue: The interval can be increased up to 24hours...
Comment