Skip to content

Commit

Permalink
Update Heading.tsx
Browse files Browse the repository at this point in the history
  • Loading branch information
iancheung0202 authored Nov 20, 2024
1 parent 076541c commit e0c7af8
Showing 1 changed file with 16 additions and 12 deletions.
28 changes: 16 additions & 12 deletions src/app/(landing)/Heading.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,15 @@ const overpass = Overpass({
});

const msToTime = (time: number) => {
let ms = String(time % 1000).padStart(3, '0');
time = Math.floor(time / 1000);
let sec = String(time % 60).padStart(2, '0');
time = Math.floor(time / 60);
let min = String(time % 60).padStart(2, '0');
time = Math.floor(time / 60);
let hours = String(time).padStart(2, '0');
return `${hours / 24} days ${hours % 24} hours ${min} minutes and ${sec} seconds`;
const ms = time % 1000;
time = Math.floor(time / 1000); // Convert to seconds
const sec = time % 60;
time = Math.floor(time / 60); // Convert to minutes
const min = time % 60;
time = Math.floor(time / 60); // Convert to hours
const hours = time % 24;
const days = Math.floor(time / 24); // Convert to days
return `${days} days, ${hours} hours, ${min} minutes, and ${sec} seconds`;
};

export default function Heading() {
Expand All @@ -25,10 +26,10 @@ export default function Heading() {

useEffect(() => {
setTime(new Date().getTime());
const inv = setInterval(() => {
const interval = setInterval(() => {
setTime(new Date().getTime());
}, 100);
return () => clearInterval(inv);
return () => clearInterval(interval);
}, []);

return (
Expand All @@ -55,14 +56,17 @@ export default function Heading() {
</div>
</div>
<div className="mt-10 px-16 py-4 text-2xl font-bold">
{time && (time < END ? `The hacking period will start in ${msToTime(END - time)}.` : `The hacking period has started.`)}
{time !== null
? time < END
? `The hacking period will start in ${msToTime(END - time)}.`
: `The hacking period has started.`
: `Loading...`}
</div>
<div className="text-2xl mt-3 flex gap-2 items-center">
<span className="text-[#F47722] text-5xl">[</span>
<a href="https://forms.gle/5JebCYpeFf2eErzY8" rel="noopener noreferrer" target="_blank">Register Here</a>
<span className="text-[#F47722] text-5xl">]</span>
</div>

</section>
);
}

1 comment on commit e0c7af8

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Deploy preview for gunnhacks11-0 ready!

✅ Preview
https://gunnhacks11-0-9vwvex0dp-daniel-kous-projects.vercel.app

Built with commit e0c7af8.
This pull request is being automatically deployed with vercel-action

Please sign in to comment.