import { intervalToDuration } from "date-fns";

function getIntervalDuration(start: Date, end: Date) {
  const duration = intervalToDuration({
    start: start,
    end: end,
  });
  const hours = (duration.hours || 0).toString();
  const minutes = (duration.minutes || 0).toString().padStart(2, "0");
  const seconds = (duration.seconds || 0).toString().padStart(2, "0");
  return `${+hours ? `${hours}:` : ""}${minutes}:${seconds}`;
}

export default getIntervalDuration;
