# TimeDiff.fun # This function can be used to calculate the delta # time in milliseconds between two times. The times # (Time1, Time2) are obtained using the 'GetTime()' # built-in Phantom function. # This function works for time differences up to an hour # but can be modified for times greater than an hour function int TimeDiff(string Time1, string Time2) { SetDelay(0); # Separate out the members of the time strings string sSec1 = SubString(Time1, 6, 11); # Get Seconds of Time1 string sSec2 = SubString(Time2, 6, 11); # Get Seconds of Time2 string sMin1 = SubString(Time1, 3, 4); # Get Minutes of Time1 string sMin2 = SubString(Time2, 3, 4); # Get Minutes of Time2 # Convert the seconds from a string to real numbers real rSec1 = StrToReal(sSec1); real rSec2 = StrToReal(sSec2); # Convert the minutes from strings to integers int iMin1 = StrToInt(sMin1); int iMin2 = StrToInt(sMin2); int tMin = 0; real tSec = 0; int Ret = 0; # Compensate for difference in hours if(iMin1 > iMin2) # if 1st minutes are greater than 2nd, hour must have changed { tMin = 60 - iMin1; tMin = tMin + iMin2; } else { tMin = iMin2 - iMin1; } if(rSec1 > rSec2) # if 1st seconds are greater than 2nd, extra minute needed { tSec = 60 - rSec1; tSec = tSec + rSec2; tMin--; } else { tSec = rSec2 - rSec1; } # Calculate Seconds Ret = tMin * 60; tSec = tSec + Ret; # Calculate Milliseconds Ret = tSec * 1000; return Ret; }