Doug101:
If it's getting close to the 20 day spillage then don't I have to do the same test to see if the turn off time will fall in the exception time?
Alright so according to this article, the spill would wrap around. If this is the case, then yes, there'd be a problem.
For simplicity, let's say the spillage happens upon 60 seconds, and the current second is 58. If you stored now()+5, you'd get 63, which would loop around to 3.
The next check would be:
if (58 > 3)
which would return true, even though there's still 5 more seconds until the real trigger.
The solution to this problem would be to make sure your maximum time addition (in this case, 5 seconds) is subtracted from the real overspill number.
So if the time is larger than 55 seconds (and the light isn't currently on), reset it to 0 again. That way if the button is pressed on 54, it will continue to 59 without fear of a spill. Next iteration, the time will be reset to 0 again, and the problem is avoided.
Also it would have to be 54 seconds not 55, because it would go from 59 straight to 0.
But you don't need to worry about that, I made a mistake! See my amended post!
Doug101:
If I install a real time clock module or sync with a NTP server would that chage things?
It wouldn't change the spill issue (that you don't need to worry about), in fact it would make it worse.
When you power up your arduino, the date starts at 1970, so you've got until 2038 before the wrap. If you sync it to a time holder, it will fast forward the date to the current year, meaning you've got far less time before that date.
AWOL:
I think you may be confusing the UNIX "time_t" which represents a number of seconds, and the value returned by Arduino's "millis() function which will wrap after 49 days after the particular Arduino's reset, and represents an arbitrary number of milliseconds.
Yes I believe I was. I'm no longer confused now, and I've corrected my initial post so any other readers coming through here won't be confused either ^^