This repository has been archived on 2022-05-20. You can view files and clone it, but cannot push or open issues or pull requests.
Alley-HSBC-Frontend/src/components/meeting-details/Utils.tsx
2022-03-30 04:02:48 -07:00

40 lines
1.1 KiB
TypeScript

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 };