To be fair, I have difficulty imagining how you could practically test for this kind of bug ahead of time. You can't test every feature in every app in the app store with the clock set to every possible date and time.
The current fashion of "write some code, write some tests, modify either until the tests pass" is not a way towards fewer bugs. All it leads to is the analogy of "throwing things on a wall and seeing what sticks". Tests should be for reducing the remaining uncertainty about the functioning of some code, and not a substitute for actually trying to get it right through careful reasoning.