I have an function to get difference between time period.
But it has a little problem. If start_hour is the current hour and stop_hour is 24am, it does not accurately calculate the difference Between Time.
function:
Is there a problem with the function?
Solved:
This is resolved if I put?24 in?start_hour.
But it has a little problem. If start_hour is the current hour and stop_hour is 24am, it does not accurately calculate the difference Between Time.
Code:
new start_hour, start_minute, start_second, hours, minutes, seconds;
gettime(start_hour, start_minute, start_second);
DifferenceBetweenTimePeriod(start_hour, 24, start_minute, 0, start_second, 0, hours, minutes, seconds);
function:
Code:
DifferenceBetweenTimePeriod(start_hour, stop_hour, start_minute, stop_minute, start_second, stop_second, &hours, &minutes, &seconds) {
? ? while (stop_second > start_second) {
? ? ? ? --start_minute;
? ? ? ? start_second = 60;
? ? }
? ? seconds = start_second - stop_second;
? ? while (stop_minute > start_minute) {
? ? ? ? --start_hour;
? ? ? ? start_minute = 60;
? ? }
? ? minutes = start_minute - stop_minute;
? ? hours = start_hour - stop_hour;
}
Is there a problem with the function?
Solved:
This is resolved if I put?24 in?start_hour.
Code:
DifferenceBetweenTimePeriod(24,?start_hour, start_minute, 0, start_second, 0, hours, minutes, seconds);