There are just two tricky details in you task, namely
- Wrap around.
- Leap years.
For simplicity, let's suppose that neither wrap around nor leap year case is happening then, with just an array (days per month) and simple operations you may easily find the result.