Hmm, really.. I'd be concerned with the "why" instead of hacking your code in one place to cover up bugs in another. Like I said I've had projects running continuously for months and never seen what you're talking about.
I'm using the code I referenced:
http://docs.macetech.com/doku.php/chronodot_v2.0I call that code to get the hours, minutes, and seconds from the RTC. That's the only interaction with the RTC.
Usually I get the correct time. But sometimes I will get a single wrong result.
Today I got 2:28:2 instead of the correct time after about 13 hours of no problems with the RTC. 2:28:2 looks a lot like today's date. I will of course be watching if any future errors match the current date.
I don't consider it a bug. I consider it an error. The battery could be running down (the RTC is usually running off its battery) and there is a strong motor nearby.
I think that is the reason. Unless the code I referenced is wrong. The signal may be getting occasionally mixed up going to or from the RTC.
So I am looking for help for correcting the occasional RTC error.
I can constrain the numbers, but I don't want to average these numbers to pull a single bad result. What is the best way to pull a single bad result out of clock like data?
What has been your experience with RTC data when the batteries begin to fail? Does wrong data occur? Or does the RTC give perfect time until the battery is dead?
Again, thank you for your attention to my problem.