Merge pull request #73 from CPSC319-Winter-term-2/home

Home
This commit is contained in:
Jincheng Lu 2022-03-30 22:49:52 -07:00 committed by GitHub
commit 3c9d8e4822
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 14 additions and 14 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

@ -6,7 +6,7 @@
rel="stylesheet"
href="https://fonts.googleapis.com/css?family=Roboto:300,400,500,700&display=swap"
/>
<title>Typescript React App</title>
<title>Digital Walk-Around</title>
</head>
<body>
<noscript>You need to enable JavaScript to run this app.</noscript>

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