From 35b7041140b6922a8caea5342ed92b18ed36f60a Mon Sep 17 00:00:00 2001 From: Ian Cheung Date: Fri, 22 Nov 2024 12:01:45 -0800 Subject: [PATCH] Update timer --- src/app/(landing)/Heading.tsx | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/app/(landing)/Heading.tsx b/src/app/(landing)/Heading.tsx index 24391d2..9f0c4e2 100644 --- a/src/app/(landing)/Heading.tsx +++ b/src/app/(landing)/Heading.tsx @@ -17,7 +17,14 @@ const msToTime = (time: number) => { 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`; + + const parts = []; + if (days > 0) parts.push(`${days} day${days > 1 ? 's' : ''}`); + if (hours > 0) parts.push(`${hours} hour${hours > 1 ? 's' : ''}`); + if (min > 0) parts.push(`${min} minute${min > 1 ? 's' : ''}`); + if (sec > 0) parts.push(`${sec} second${sec > 1 ? 's' : ''}`); + + return parts.join(', '); }; export default function Heading() {