export const formatDateToMMddYYYY = (date: Date, separator?: string) => {
  const sp = separator ?? "/";
  const localYear = date.getFullYear();
  const localMonth = date.getMonth() + 1; // Months are 0-indexed
  const localDay = date.getDate();

  const localDateFormatted = `${String(localMonth).padStart(2, "0")}${sp}${String(localDay).padStart(2, "0")}${sp}${localYear}`;

  return localDateFormatted;
};

export function differenceInDays(date1: Date, date2: Date): number {
  const msInDay = 1000 * 60 * 60 * 24;
  const diffInMs = date2.getTime() - date1.getTime();
  return Math.floor(diffInMs / msInDay);
}
