Fix reward countdown for other time zones (#347)
Co-authored-by: ekzyis <ek@stacker.news>
This commit is contained in:
parent
46014d0de4
commit
3c3a97fb8e
|
@ -29,10 +29,13 @@ export function RewardLine ({ total }) {
|
||||||
const [threshold, setThreshold] = useState(0)
|
const [threshold, setThreshold] = useState(0)
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const dateStr = new Date().toLocaleString('en-US', { timeZone: 'America/Chicago' })
|
const date = new Date()
|
||||||
const date = new Date(dateStr)
|
|
||||||
date.setHours(24, 0, 0, 0)
|
date.setHours(24, 0, 0, 0)
|
||||||
setThreshold(date.getTime())
|
// Central Daylight Saving Time UTC offset in minutes
|
||||||
|
const targetOffset = -5 * 60
|
||||||
|
const localOffset = -date.getTimezoneOffset()
|
||||||
|
const ts = date.getTime() + ((localOffset - targetOffset) * 60 * 1000)
|
||||||
|
setThreshold(ts)
|
||||||
}, [])
|
}, [])
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|
Loading…
Reference in New Issue