[fpc-pascal] Getting Last User Input reliably
wkitty42 at windstream.net
wkitty42 at windstream.net
Mon Dec 6 10:45:15 CET 2021
On 12/5/21 11:10 AM, James Richters via fpc-pascal wrote:
> So the only thing I need to consider is times of longer than 49.7 days
> without user input... because if it was exactly 50 days, it would look like
> 0.3 days as the first rollover would be forgotten. To take care of this I can
> just check it in my main program loop and keep updating my own datetime
> variable of last user input.
i don't understand why you are keeping up with user input times by counting
ticks... you said that one second accuracy is just fine so Keep It Simple, man,
and don't over engineer it...
grab the unix timestamp NOW each time they input something and store that...
when you want to know how long it has been since their last input, just subtract
lastUserInputTime from currentNow and you have your elapsed time...
if you use a 32bit signed variable, you still have 17 years before you have to
even think about a rollover... in this day in age, i'd use a 64bit signed
variable along with the 64bit unix time routines and not worry about it for the
next 292 billion years ;)
--
NOTE: No off-list assistance is given without prior approval.
*Please keep mailing list traffic on the list where it belongs!*
More information about the fpc-pascal
mailing list