I have two time_t variables: timeA and timeB.
What I want to do is check if timeA is the same as timeB. However, I know that in some cases they won't be exactly the same and there may be a 1 or 2 seconds difference between the two of them, so what I really want to check is:
if (timeB - 2sec) <= timeA <= (timeB + 2sec)
Is it possible to do so?
I suppose one option is not to use time_t but instead keep timeB as a tm struct, and just before the comparison, subtract two seconds and create a time_t timeBminus and then add four seconds and create time_t timeBplus. The problem is that I will be comparing several millions of timeA - timeB pairs and want to keep it as simple and fast as possible.
How can I do it?
Something like -
(Not able to check the exact type etc from here but I think the idea is correct)