//
export const formatDateForApi = (date: Date): string => {
  const mm = String(date.getMonth() + 1).padStart(2, "0");
  const dd = String(date.getDate()).padStart(2, "0");
  const yyyy = date.getFullYear();
  return `${mm}/${dd}/${yyyy}`;
};

export const getDefaultStartDate = (daysAgo: number = 30): Date => {
  const today = new Date();
  today.setDate(today.getDate() - daysAgo);
  return today;
};

export const getDateRange = (range: "week" | "month" | "quarter"): Date => {
  const today = new Date();
  switch (range) {
    case "week":
      today.setDate(today.getDate() - 7);
      break;
    case "month":
      today.setDate(today.getDate() - 30);
      break;
    case "quarter":
      today.setDate(today.getDate() - 90);
      break;
  }
  return today;
};
