The calendar works like this.
def month_year_iter( start_month, start_year, end_month, end_year ):
ym_start= 12*start_year + start_month - 1
ym_end= 12*end_year + end_month - 1
for ym in range( ym_start, ym_end ):
y, m = divmod( ym, 12 )
yield y, m+1
All multiple-unit things work like this. Feet and Inches, Hours, Minutes and Seconds, etc., etc. The only thing that’s not this simple is months-days or months-weeks because months are irregular. Everything else is regular, and you need to work in the finest-grained units.