Avoid extra calls to calendar.monthrange.
daysinmonth isn't used beyond setting cal, which is only used if calendar_end or business_end. Putting the if check in improved performance by a factor of 10. Once all of the flags are false, they can never become true (because of the &= operations), and short-circuiting the rest of the loop in that case saved an additional 20% runtime in the provided example code (see #1686).

Much simpler than rewriting in Cython for now. monthrange is relatively expensive and was being called 3x per index datetime when doing a .resample("T"...) operation.

Thanks for the help from Erik Welch!

thanks, just cherry-picked this commit
