def format_date( date_obj ):  # date_obj is a datetime.date object
    """Returns a formatted date string given a date object. If the day is
    the first of the month, then the day is dropped, eg:
        format_date ( datetime.date(2013, 04, 12)) returns 2013-04-12
        format_date ( datetime.date(2013,  4,  1)) returns 2013-04
    """
    if date_obj.day == 1:
        full_date = date_obj.isoformat()
        return full_date[0:7]
    else:
        return date_obj.isoformat()