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

View File

@ -21,14 +21,9 @@ const getStatusColor = (ms: MeetingStatus): string => {
const formatTimeFromDate = (date: Date): string => { const formatTimeFromDate = (date: Date): string => {
let hour = date.getHours(); let hour = date.getHours();
let ampm = ""; let ampm = "";
const minutes = const minutes = date.getMinutes() < 10 ? "0" + date.getMinutes() : "" + date.getMinutes();
date.getMinutes() < 10 ? "0" + date.getMinutes() : "" + date.getMinutes(); ampm = hour < 12 ? "AM" : "PM";
if (hour < 12) { hour = hour % 12 == 0 ? 12 : (hour % 12);
ampm = "am";
} else {
hour = hour === 12 ? 12 : hour - 12;
ampm = "pm";
}
return hour + ":" + minutes + ampm; return hour + ":" + minutes + ampm;
}; };