Get the week day for 1st of any month:

int firstday = (1 + 2*m + (3*(m+1)/5) + y + (y/4) – (y/100) + (y/400) + 2) % 7 – 1

Simple, right? Don’t remember where is it from.