Hi,
you can base this on day-of-year, which can be calculated as a simple table look-up:
int dayOfYear = dayOfMonth + monthOffset[monthNumber];
where monthOffset is an array holding 12 constants, starting with 0 and 31. You may have two of them, one for leap years, one regular.
However, you have a potential problem around New Year. When a time span exceeds half a year, you should mirror it to the next year.
:)