One caveat here: You *can* experience bugs with this after midnight.
Program starts at 23:59:59. Add three seconds -- 24:00:02... (In seconds, and not hours and minutes like this, though hours and minutes are easier to visualize.)
Clock hits midnight: 0:00:00
At no point will you ever have TIMER become greater than t#.
If you're going to have a program which might run into this issue, I'd suggest just plugging in my ExtendedTimer and use it instead:
l1
= INSTR(l
+ 1, d$
, "-") SELECT CASE i
'Add the number of days for each previous month passed CASE 1: d
= d
'January doestn't have any carry over days. CASE 2, 4, 6, 8, 9, 11: d
= d
+ 31 CASE 5, 7, 10, 12: d
= d
+ 30 d = d + 365
IF m
> 2 THEN d
= d
+ 1 'add an extra day for leap year every 4 years, starting in 1970 d = d - 1 'for year 2000
s~&& = d * 24 * 60 * 60 'Seconds are days * 24 hours * 60 minutes * 60 seconds
ExtendedTimer##
= (s~&&
+ TIMER)
Most of us write time code to test little snippets for which method might be faster for us while we're coding. The clock resetting on us isn't normally such a big deal. When it is, however, all you have to do is swap to the ExtendedTimer function above -- it returns a value for you based off DAY + TIME, rather than just time alone! No midnight clock issues with something like that in our programs. ;)
' DO SOMETHING FOR 3 SECONDS
t# = ExtendedTimer + 3
Do
'(SOMETHING)
Loop Until Timer > t#