From ead13b4e08e039637863b5ae9340754433d6218f Mon Sep 17 00:00:00 2001 From: Ian Philips Date: Fri, 10 Jun 2022 09:15:55 -0600 Subject: [PATCH] Time flies when you floor it --- web/components/nav/sidebar.tsx | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/web/components/nav/sidebar.tsx b/web/components/nav/sidebar.tsx index 70396676..457b69ff 100644 --- a/web/components/nav/sidebar.tsx +++ b/web/components/nav/sidebar.tsx @@ -165,15 +165,14 @@ export default function Sidebar(props: { className?: string }) { const now = new Date().getTime() const timeUntil = nextUtcResetTime - now const hoursUntil = timeUntil / 1000 / 60 / 60 - const minutesUntil = Math.floor((hoursUntil * 60) % 60) - const secondsUntil = Math.floor((hoursUntil * 60 * 60) % 60) - const hoursUntilFloor = Math.floor(hoursUntil) + const minutesUntil = (hoursUntil * 60) % 60 + const secondsUntil = Math.round((hoursUntil * 60 * 60) % 60) const timeString = - minutesUntil < 1 + hoursUntil < 1 && minutesUntil < 1 ? `${secondsUntil}s` - : hoursUntilFloor < 1 - ? `${minutesUntil}m` - : `${hoursUntilFloor}h` + : hoursUntil < 1 + ? `${Math.round(minutesUntil)}m` + : `${Math.floor(hoursUntil)}h` setCountdown(timeString) }, 1000) return () => clearInterval(interval)