Create a yyyy-mm(-dd) string from a tuple containing (yyyy, m) (or one with the day too)

def tuple_to_string(date_tuple):
    """
    Create a yyyy-mm(-dd) string from a tuple containing (yyyy, m) (or one with the day too)
    """
    if len(date_tuple) == 2:
        # It's yyyy-mm
        return str(date_tuple[0]).zfill(4) + '-' + str(date_tuple[1]).zfill(2)
    # It's yyyy-mm-dd
    return str(date_tuple[0]).zfill(4) + '-' + str(date_tuple[1]).zfill(2) + '-' + str(date_tuple[2]).zfill(2)