This is a bug in Safari that some of our Cosmo tests turned up.
I had to do bit of digging around to figure out what was going on, so I thought I'd post it here and maybe save other people some trouble if they run into the same thing.
Safari can't handle these out-of-range parameters properly, but doesn't even have the good sense to fail in those cases -- it just produces some seemingly random date. The
setMonth method of Date unsurprisingly has the same issue. This problem is documented in WebKit bug 4892.
Unfortunately this is one of those "doctor it hurts when I do this" kind of problems -- the only practical solution is just not to expect intelligent wraparound from Dates in Safari.
Happily, the problem is fixed in the WebKit nightlies, so when Apple revs Safari, this should be fixed. Fortunately Safari users are a relatively small group, and very likely to upgrade, so hopefully this won't be a thorn in our side that much longer.