export const formatDate = (date: string | null) => {
  if (!date) return null;
  return new Date(date).toLocaleDateString("en-US", {
    month: "long",
    day: "numeric",
    year: "numeric",
  });
};

export const formatTime = (date: string | null) => {
  if (!date) return null;
  return new Date(date).toLocaleTimeString("en-US", {
    hour: "2-digit",
    minute: "2-digit",
  });
};

export const formatSecondsToHHMMSS = (
  seconds: number,
  availableValues?: Partial<
    Record<"isHours" | "isMinutes" | "isSeconds", boolean>
  >
) => {
  const {
    isHours = true,
    isMinutes = true,
    isSeconds = true,
  } = availableValues || {};
  const hours = Math.floor(seconds / 3600);
  const minutes = Math.floor((seconds % 3600) / 60);
  const secs = seconds % 60;

  return [
    isHours && String(hours).padStart(2, "0"),
    isMinutes && String(minutes).padStart(2, "0"),
    isSeconds && String(secs).padStart(2, "0"),
  ]
    .filter(Boolean)
    .join(":");
};
