Fix reward countdown for other time zones (#347)

Co-authored-by: ekzyis <ek@stacker.news>
This commit is contained in:
ekzyis 2023-07-07 03:55:18 +02:00 committed by GitHub
parent 46014d0de4
commit 3c3a97fb8e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 3 deletions

View File

@ -29,10 +29,13 @@ export function RewardLine ({ total }) {
const [threshold, setThreshold] = useState(0)
useEffect(() => {
const dateStr = new Date().toLocaleString('en-US', { timeZone: 'America/Chicago' })
const date = new Date(dateStr)
const date = new Date()
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 (