Skip to content

Commit

Permalink
show 12 hr format
Browse files Browse the repository at this point in the history
  • Loading branch information
Bahugunajii committed Mar 22, 2024
1 parent fad1825 commit 95708f9
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
10 changes: 5 additions & 5 deletions app/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export default function Home() {
const [liveClasses, setLiveClasses] = useState<SessionSchedule[]>([]);
const [isLoading, setIsLoading] = useState(true);
const [quizzes, setQuizzes] = useState<QuizSession[]>([]);
const commonTextClass = "text-gray-700 text-sm md:text-base mx-6 md:mx-8";
const commonTextClass = "text-gray-700 text-xs md:text-sm mx-3 md:mx-8 whitespace-nowrap w-12";
const infoMessageClass = "flex items-center justify-center text-center h-72 mx-4 pb-40";
const portalBaseUrl = api.portal.frontend.baseUrl;
const [batchId, setBatchId] = useState();
Expand Down Expand Up @@ -105,7 +105,7 @@ export default function Home() {
return (
<p className="text-xs italic font-normal mr-4">
Starts at <br />
{sessionStartTimeStr}
{formatTime(sessionStartTimeStr)}
</p>
);
}
Expand All @@ -122,7 +122,7 @@ export default function Home() {
return (
<p className="text-xs italic font-normal mr-4">
Starts at <br />
{sessionStartTimeStr}
{formatTime(sessionStartTimeStr)}
</p>
);
}
Expand Down Expand Up @@ -204,10 +204,10 @@ export default function Home() {
<div key={index} className="flex mt-4 items-center" >
<div>
<p className={`${commonTextClass}`}>
{formatQuizSessionTime(data.start_time)}
{formatTime(formatQuizSessionTime(data.start_time))}
</p>
<p className={`${commonTextClass}`}>
{formatQuizSessionTime(data.end_time)}
{formatTime(formatQuizSessionTime(data.end_time))}
</p>
</div>
<div className="bg-white rounded-lg shadow-lg min-h-24 h-auto py-6 relative w-full flex flex-row justify-between mr-4 items-center">
Expand Down
4 changes: 2 additions & 2 deletions utils/dateUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ export function formatQuizSessionTime(dateTimeStr: string) {
}

export function formatTime(dateTimeStr: string) {
const [hours, minutes] = dateTimeStr.split(':');
return `${hours}:${minutes}`;
const time = new Date(`2000-01-01T${dateTimeStr}`);
return time.toLocaleTimeString('en-US', { hour: 'numeric', minute: '2-digit', hour12: true });
}

export function isSessionActive(endTime: string): boolean {
Expand Down

0 comments on commit 95708f9

Please sign in to comment.