Return to Snippet

Revision: 17176
at August 26, 2009 07:33 by pats


Initial Code
def quarters_range(date_to, date_from=None):
    result = []
    if date_from is None:
        date_from = datetime.now()
    quarter_from = (date_from.month/4)+1
    quarter_to = (date_to.month/4)+1
    for year in range(date_from.year, date_to.year+1):
        for quarter in range(1, 5):
            if date_to.year == year and quarter >= quarter_to:
                break
            if date_from.year == year and quarter <= quarter_from:
                continue
            result.append([quarter, year])
    return result

Initial URL

                                

Initial Description

                                

Initial Title
calculate quarters range between specific dates - correct version

Initial Tags

                                

Initial Language
Python