feat: cleaned up leaderboard for official links
continuous-integration/drone/push Build is failing
Details
continuous-integration/drone/push Build is failing
Details
parent
3e5c54bf8f
commit
c752c01976
@ -1,18 +0,0 @@
|
||||
import { formatDate } from 'date-fns'
|
||||
import { useEffect, useState } from 'preact/hooks'
|
||||
|
||||
export const Clock = ({}) => {
|
||||
const [time, setTime] = useState(new Date())
|
||||
|
||||
useEffect(() => {
|
||||
const timer = setInterval(() => {
|
||||
setTime(new Date())
|
||||
}, 1000)
|
||||
|
||||
return () => {
|
||||
clearInterval(timer)
|
||||
}
|
||||
}, [])
|
||||
|
||||
return <>{formatDate(time, 'HH:mm:ss')}</>
|
||||
}
|
@ -0,0 +1,39 @@
|
||||
import { addSeconds, differenceInSeconds, formatDate, formatDistance, formatDuration } from 'date-fns'
|
||||
import { useEffect, useState } from 'preact/hooks'
|
||||
|
||||
export const Clock = () => {
|
||||
const [time, setTime] = useState(new Date())
|
||||
|
||||
useEffect(() => {
|
||||
const timer = setInterval(() => {
|
||||
setTime(new Date())
|
||||
}, 1000)
|
||||
|
||||
return () => {
|
||||
clearInterval(timer)
|
||||
}
|
||||
}, [])
|
||||
|
||||
return <>{formatDate(time, 'HH:mm:ss')}</>
|
||||
}
|
||||
|
||||
export const Countdown = ({ endTime }: { endTime: Date }) => {
|
||||
const [time, setTime] = useState(new Date())
|
||||
|
||||
useEffect(() => {
|
||||
const timer = setInterval(() => {
|
||||
setTime(new Date())
|
||||
}, 1000)
|
||||
|
||||
return () => {
|
||||
clearInterval(timer)
|
||||
}
|
||||
}, [])
|
||||
|
||||
const diff = differenceInSeconds(endTime, time)
|
||||
if (diff < 0) {
|
||||
return <>00:00:00</>
|
||||
}
|
||||
|
||||
return <>{formatDate(addSeconds(new Date(0), diff), 'HH:mm:ss')}</>
|
||||
}
|
Loading…
Reference in New Issue