Time flies when you floor it
This commit is contained in:
parent
05c6575ebb
commit
ead13b4e08
|
@ -165,15 +165,14 @@ export default function Sidebar(props: { className?: string }) {
|
||||||
const now = new Date().getTime()
|
const now = new Date().getTime()
|
||||||
const timeUntil = nextUtcResetTime - now
|
const timeUntil = nextUtcResetTime - now
|
||||||
const hoursUntil = timeUntil / 1000 / 60 / 60
|
const hoursUntil = timeUntil / 1000 / 60 / 60
|
||||||
const minutesUntil = Math.floor((hoursUntil * 60) % 60)
|
const minutesUntil = (hoursUntil * 60) % 60
|
||||||
const secondsUntil = Math.floor((hoursUntil * 60 * 60) % 60)
|
const secondsUntil = Math.round((hoursUntil * 60 * 60) % 60)
|
||||||
const hoursUntilFloor = Math.floor(hoursUntil)
|
|
||||||
const timeString =
|
const timeString =
|
||||||
minutesUntil < 1
|
hoursUntil < 1 && minutesUntil < 1
|
||||||
? `${secondsUntil}s`
|
? `${secondsUntil}s`
|
||||||
: hoursUntilFloor < 1
|
: hoursUntil < 1
|
||||||
? `${minutesUntil}m`
|
? `${Math.round(minutesUntil)}m`
|
||||||
: `${hoursUntilFloor}h`
|
: `${Math.floor(hoursUntil)}h`
|
||||||
setCountdown(timeString)
|
setCountdown(timeString)
|
||||||
}, 1000)
|
}, 1000)
|
||||||
return () => clearInterval(interval)
|
return () => clearInterval(interval)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user