Free daily market bugfix

This commit is contained in:
Ian Philips 2022-05-24 07:31:44 -06:00
parent d19d60eb6a
commit 13bf5ac253

View File

@ -129,8 +129,12 @@ export default function Sidebar(props: { className?: string }) {
useEffect(() => {
const utcMidnightToLocalDate = new Date(getUtcFreeMarketResetTime(false))
const interval = setInterval(() => {
const timeUntil = utcMidnightToLocalDate.getTime() - new Date().getTime()
const hoursUntil = 24 + timeUntil / 1000 / 60 / 60
const now = new Date().getTime()
let timeUntil = Math.abs(utcMidnightToLocalDate.getTime() - now)
if (now > utcMidnightToLocalDate.getTime()) {
timeUntil = 24 * 60 * 60 * 1000 - timeUntil
}
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)