def get_last_n_months(months):
    ranges = []
    today = datetime.utcnow()
    for month in range(months):
        month_start = datetime(today.year, today.month, 1) - relativedelta(months=month)
        last_day_of_month = get_last_day_of_month(month_start, today)
        month_end = datetime(month_start.year, month_start.month, last_day_of_month)
        ranges.insert(0, (month_start, month_end))
    return ranges
dataset/ETHPy150Open dimagi/commcare-hq/custom/m4change/fixtures/report_fixtures.py/get_last_n_months/original