Skip to content

Commit

Permalink
Format time
Browse files Browse the repository at this point in the history
  • Loading branch information
DCRepublic committed Nov 7, 2024
1 parent 26a4bdc commit 0925ea8
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 11 deletions.
22 changes: 14 additions & 8 deletions components/CourseCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import { generateColorFromName } from "../components/primitives";

import { InstructorCard } from "./InstructorCard";
import AddIcon from "@mui/icons-material/Add";
import moment from "moment";
import axios from "axios";
export const card = tv({
slots: {
Expand Down Expand Up @@ -142,14 +143,19 @@ export default function CourseCard(props: any) {
<div className="mt-2">
<p className={role()}>Time</p>
<div className="text-xs ">
{" "}
{props.course.facultyMeet.meetingTimes.beginTime.slice(0, 2) +
":" +
props.course.facultyMeet.meetingTimes.beginTime.slice(2)}{" "}
-{" "}
{props.course.facultyMeet.meetingTimes.endTime.slice(0, 2) +
":" +
props.course.facultyMeet.meetingTimes.endTime.slice(2)}
{moment(
props.course.facultyMeet.meetingTimes.beginTime.slice(0, 2) +
":" +
props.course.facultyMeet.meetingTimes.beginTime.slice(2),
"HH:mm"
).format("hh:mm a")}
-
{moment(
props.course.facultyMeet.meetingTimes.endTime.slice(0, 2) +
":" +
props.course.facultyMeet.meetingTimes.endTime.slice(2),
"HH:mm"
).format("hh:mm a")}
</div>
</div>
) : null}
Expand Down
8 changes: 6 additions & 2 deletions components/Search.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { useSearchParams, usePathname, useRouter } from "next/navigation";
import { useDebouncedCallback } from "use-debounce";
import { Select, SelectItem } from "@nextui-org/react";
import { useEffect, useState } from "react";

import moment from "moment";
export default function Search(props: any) {
let router = useRouter();
const searchParams = useSearchParams();
Expand Down Expand Up @@ -159,9 +159,13 @@ export default function Search(props: any) {
onSelectionChange={handleSTimeChange}
>
{props.times.startTimes.map((startTime: any) => {
var time = startTime.slice(0, 2) + ":" + startTime.slice(2);
var daTime = moment(time, "HH:mm").format("hh:mm A");

console.log(daTime);
return (
<SelectItem key={startTime} value={startTime}>
{startTime.slice(0, 2) + ":" + startTime.slice(2)}
{daTime}
</SelectItem>
);
})}
Expand Down
2 changes: 1 addition & 1 deletion docker-compose.debug.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ services:
- 9229:9229
networks:
- internal
command: sh -c "npm install --silent && npx prisma migrate dev && npm run dev "
command: sh -c "npm install --silent && npx prisma generate && npm run dev "

postgres:
image: postgres:16.4-bullseye
Expand Down
10 changes: 10 additions & 0 deletions prisma/migrations/20241107165826_courseplanner1_1/migration.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/*
Warnings:
- Made the column `beginTime` on table `MeetingTime` required. This step will fail if there are existing NULL values in that column.
- Made the column `endTime` on table `MeetingTime` required. This step will fail if there are existing NULL values in that column.
*/
-- AlterTable
ALTER TABLE "MeetingTime" ALTER COLUMN "beginTime" SET NOT NULL,
ALTER COLUMN "endTime" SET NOT NULL;

0 comments on commit 0925ea8

Please sign in to comment.