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/utils.tsx
2022-03-30 04:02:48 -07:00

36 lines
829 B
TypeScript

const enum MeetingStatus {
NOT_IN_MEETING = "Not in meeting",
IN_MEETING = "In meeting",
NOT_AVAILABLE = "Not available",
}
const getStatusColor = (ms: MeetingStatus): string => {
switch (ms) {
case MeetingStatus.NOT_IN_MEETING: {
return "#70ff70";
}
case MeetingStatus.IN_MEETING: {
return "#ff7070";
}
case MeetingStatus.NOT_AVAILABLE: {
return "#808080";
}
}
};
const formatTimeFromDate = (date: Date): string => {
let hour = date.getHours();
let ampm = "";
const minutes =
date.getMinutes() < 10 ? "0" + date.getMinutes() : "" + date.getMinutes();
if (hour < 12) {
ampm = "am";
} else {
hour = hour === 12 ? 12 : hour - 12;
ampm = "pm";
}
return hour + ":" + minutes + ampm;
};
export { MeetingStatus, getStatusColor, formatTimeFromDate };