Calculate elapsed time (or countdown to future time)

SetInt32TablesEqual(itCurrentDateTime,itTestStartTime);
DateTimeToNtpTimestamp(itTestStartTime,iiTestStartTime);
iiTestStartTime = iiTestStartTime >> 32;

repeat

iiTestEndTime = iiTestStartTime + ((iCycles_Ideal - iCycles) * fSecondsInDay);
iiTestEndTime = iiTestEndtime << 32;
NtpTimestampToDateTime(itTestEndTime,iiTestEndTime);

iCycles = iCycles + 1;

The above sets my start time once from the current time/date string, then permanently shifts the start integer over 32 bits

Each time I start a cycle (24 hours), I am calculating how many seconds away the end is, then shifting the result back over 32 bits before sending it into the function

Looks reasonable - you may want to use the GetHighBitsOfInt64 command instead of the >> operator to preserve the sign.

1 Like

Thank you! Each reply gives me something new, hadn’t know of the “get high bits” function at all until now :slight_smile: