From f0d44be2f4cb3f6ded54dee740b05729e0b3be8d Mon Sep 17 00:00:00 2001 From: Ian Philips Date: Wed, 25 May 2022 16:04:14 -0600 Subject: [PATCH] Clean up time diff code --- web/components/nav/sidebar.tsx | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/web/components/nav/sidebar.tsx b/web/components/nav/sidebar.tsx index 67e000d0..1948aae2 100644 --- a/web/components/nav/sidebar.tsx +++ b/web/components/nav/sidebar.tsx @@ -127,13 +127,10 @@ export default function Sidebar(props: { className?: string }) { const currentPage = router.pathname const [countdown, setCountdown] = useState('...') useEffect(() => { - const utcMidnightToLocalDate = new Date(getUtcFreeMarketResetTime(false)) + const nextUtcResetTime = getUtcFreeMarketResetTime(false) const interval = setInterval(() => { const now = new Date().getTime() - let timeUntil = Math.abs(utcMidnightToLocalDate.getTime() - now) - if (now > utcMidnightToLocalDate.getTime()) { - timeUntil = 24 * 60 * 60 * 1000 - timeUntil - } + let timeUntil = nextUtcResetTime - now const hoursUntil = timeUntil / 1000 / 60 / 60 const minutesUntil = Math.floor((hoursUntil * 60) % 60) const secondsUntil = Math.floor((hoursUntil * 60 * 60) % 60)