/** Keeps every backup of the last 14 days, and the newest of each month for ever. Returns the folders that may go. */
export function expired(folders: string[], newest: string): string[] {
  const mine = folders.filter((f) => /^\d{4}-\d{2}-\d{2}_\d{2}-\d{2}-\d{2}$/.test(f)).sort(), limit = new Date(Date.parse(`${newest.slice(0, 10)}T00:00:00Z`) - 14 * 86_400_000).toISOString().slice(0, 10);
  const month = new Map(mine.map((f) => [f.slice(0, 7), f]));
  return mine.filter((f) => f.slice(0, 10) < limit && month.get(f.slice(0, 7)) !== f && f !== newest);
}
