(some_date: date)
return f"{year}Q{quarter}"
Returns the previous quarter in DHIS2 web API `period format`_.
    e.g. "2004Q1"

    .. _period format: https://docs.dhis2.org/master/en/developer/html/webapi_date_perid_format.html
Returns the previous quarter in DHIS2 web API `period format`_.
    e.g. "2004Q1"
Returns the previous quarter in DHIS2 web API period format _ . e . g . 2004Q1
def previous_quarter(some_date: date) -> str:
    """
    Returns the previous quarter in DHIS2 web API `period format`_.
    e.g. "2004Q1"

    .. _period format: https://docs.dhis2.org/master/en/developer/html/webapi_date_perid_format.html
    """
    year = some_date.year
    quarter = (some_date.month - 1) // 3
    if quarter == 0:
        year -= 1
        quarter = 4
    return f"{year}Q{quarter}"
def previous_quarter ( some_date : date ) -> str : year = some_date . year quarter = ( some_date . month - 1 ) // 3 if quarter == 0 : year -= 1 quarter = 4 return f"{year}Q{quarter}"