tempTimer rounding the time provided to it at creation
I've encountered an issue when creating a tempTimer that seems to be unexpectedly rounding the provided initialization time. Best way to show it is probably with an example function and the output, vs. what I would expect. The following function creates a tempTimer, timer_1, with the provided time. It then displays the time remaining on timer_1 immediately after creation. It also creates a second tempTimer, timer_2, that fires 0.3 seconds later to again show the time remaining on timer_1.
function fire_away(time)
cecho("Before timer_1 = "..time.."s is made\n")
local timer_1 = tempTimer(time, function() cecho("Done!\n") end)
cecho("After timer_1 is made with remaining time = "..remainingTime(timer_1).."s\n")
cecho("Before timer_2 = 0.3s is made\n")
local timer_2 = tempTimer(0.3, function() cecho("timer_2 firing. Remaining time on timer_1 = "..remainingTime(timer_1).."s\n") end)
cecho("After timer_2 is made\n")
end
The output from a sample run of this function looks like the following:
As expected, the timer creations and initial message echoes all occur simultaneously. However, after being created, timer_1 shows the time remaining as GREATER than the time I provided at initialization.
0.3 seconds later, as expected, timer_2 fires and its code executes, showing the remaining time left on timer_1. Again, the remaining time is GREATER than what I tried creating timer_1 with.
For the example shown, timer_1 was created at 18 hours 33 minutes 43.615 seconds. If it truly was made with the time I told it to use (30.6 seconds in the example shown), I would expect it to fire at 18 hours 34 minutes 14.215 seconds (+/- a handful of milliseconds). Instead, it fires at 18 hours 34 minutes 14.602 seconds.
This 0.4 second difference (+/- a few milliseconds, which I'm not worried about as that's kind of to be expected) is perhaps not large, but I have found the error from rounding to be an issue in some work I'm doing.
To make things even more curious, this issue does not occur for all values provided to the tempTimer. Someone else on Discord pointed it out, but the issue only seems to be a problem for tempTimers created with an initial time of 20 seconds or greater.

Hopefully that was all clear, glad to provide more info or answer questions if needed. Thanks!