The thing that <i>kills</i> me about this bug is that it's such an easy bug to find in a code-review. Some person totally unfamiliar with the code asks "What happens when that inner <i>if</i> condition is false?" and MSFT is saved from yet another embarassing gadget glitch.
The correct way to do this is to define a quadyear=365*4+1, and then just use mods & divides (quadyear -> year-within-quad -> day) with no loop, right?