fixed time display error in detailed meeting

This commit is contained in:
CodeServer 2022-03-31 06:46:17 +01:00
parent 272a7bf33e
commit 9f48d3788b
2 changed files with 13 additions and 13 deletions

View File

@ -48,6 +48,7 @@ const Body: React.FC<Props> = ({ meeting }) => {
);
const parseIsoString = (s: string) => {
const date: Date = new Date(s);
const month = [
"January",
"February",
@ -61,10 +62,13 @@ const Body: React.FC<Props> = ({ meeting }) => {
"October",
"November",
"December",
][parseInt(s.slice(5, 7)) - 1];
const day = s.slice(8, 10);
const isoTime: string = s.slice(11, 16);
const hour: number = parseInt(isoTime.slice(0, 2));
][date.getMonth()];
// ][parseInt(s.slice(5, 7)) - 1];
// const day = s.slice(8, 10);
// const isoTime: string = s.slice(11, 16);
// const hour: number = parseInt(isoTime.slice(0, 2));
const day = date.getDate();
const hour: number = date.getHours();
const hourMod: string = hour % 12 == 0 ? "12" : (hour % 12).toString();
return (
month +
@ -73,7 +77,8 @@ const Body: React.FC<Props> = ({ meeting }) => {
", " +
hourMod +
":" +
isoTime.slice(3, 5) +
// isoTime.slice(3, 5) +
date.getMinutes() +
(hour > 11 ? "PM" : "AM")
);
};

View File

@ -21,14 +21,9 @@ const getStatusColor = (ms: MeetingStatus): string => {
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";
}
const minutes = date.getMinutes() < 10 ? "0" + date.getMinutes() : "" + date.getMinutes();
ampm = hour < 12 ? "AM" : "PM";
hour = hour % 12 == 0 ? 12 : (hour % 12);
return hour + ":" + minutes + ampm;
};