def convert_calendar(ds, calendar, time_dim="time"):
    """
    Convert calendar, dropping invalid/surplus dates or inserting missing dates

    Parameters
    ----------
    ds : xarray Dataset
        A dataset with a time dimension
    time_dim : str, optional
        The name of the time dimension
    """
    return ds.convert_calendar(calendar=calendar, dim=time_dim, use_cftime=True)