I came across this question whilst playing with a C/C++/C# hobby project. So, although this answer may not be pertinent to the OP, the remainder of the answers/comments seem to concern JavaScript "golf"; which is a bit of a black art due to the vagaries of JS JIT, but fun nonetheless.
Standing on the shoulders of GitaarLAB, TrueBlueAussie, et al, I propose:
return m===2?y&3||!(y%25)&&y&15?28:29:30|(m+(m>>3));