More concise implementation of datesInYear.