import DetailedMeeting from "../../api-bodies/DetailedMeeting";

const getUpcomingMeetingTime = (meeting: DetailedMeeting) => {
  const startDate = new Date(meeting.startTime);
  const endDate = new Date(startDate.getTime() + meeting.duration * 60000);
  const startTime = startDate
    .toTimeString()
    .split(" ")[0]
    .split(":")
    .slice(0, 2)
    .join(":");
  const endTime = endDate
    .toTimeString()
    .split(" ")[0]
    .split(":")
    .slice(0, 2)
    .join(":");
  return `${startTime} - ${endTime}`;
};

const getMeetingDuration = (meeting: DetailedMeeting) => {
  const startDate = new Date(meeting.startTime);
  const endDate = new Date(startDate.getTime() + meeting.duration * 60000);
  const startDateString = startDate.toDateString();
  const startTimeString = startDate
    .toTimeString()
    .split(" ")[0]
    .split(":")
    .splice(0, 2)
    .join(":");
  const endTimeString = endDate
    .toTimeString()
    .split(" ")[0]
    .split(":")
    .slice(0, 2)
    .join(":");
  return `${startDateString} ${startTimeString} - ${endTimeString}`;
};
export { getUpcomingMeetingTime, getMeetingDuration };
