z80 Machine Code, 13 bytes
47 1F 1F 1F A8 E6 01 05 10 01 3D C6 30
Takes input (starting at 1) in the A register and stores output in the same register. This was manually assembled from the ez80 manual and is not yet tested, therefore it might contain some mistakes.
Explanation:
47 ld b, a ; Copy the value to the B register
1F 1F 1F rra (3 times) ; Rightrotate\ theSet A registerto 3((A times,>> moving3) bit^ 3B) to& bit1, 0which is
A8 xor a, b ; Xor A and B into A, which sets bit 0 of| Aequal to 1 on all months with 31 days
E6 01 and a, 1 ; Set all other bits to/ zero
05 dec b ; \ Decrement the B register twice and skip the next instruction if
10 01 djnz $+3 ; Decrement B again and skip/ the nextresulting instructionvalue ifis not equal to zero (if the month is not february)
3D dec a ; Decrement A (if february)
C6 30 add a, 30 ; Add 30 to A