You are talking about something like the international fixed calendar
(http://en.wikipedia.org/wiki/International_fixed_calendar )?
One simple approach might be to create two mapping tables for leap years and non leap years.
(That's the good thing about the IFC, two lookup tables are enough for all time)