Daily free market countdown fix

This commit is contained in:
Ian Philips 2022-05-23 11:26:17 -06:00
parent d0347ff5c2
commit 0f01753795

View File

@ -5,6 +5,14 @@ import { User } from 'common/user'
let sessionCreatedContractToday = true
export function getUtcFreeMarketResetTimeToday() {
// Uses utc time like the server.
const utcFreeMarketResetTime = new Date()
utcFreeMarketResetTime.setUTCDate(utcFreeMarketResetTime.getUTCDate())
const utcFreeMarketMS = utcFreeMarketResetTime.setUTCHours(16, 0, 0, 0)
return utcFreeMarketMS
}
function getUtcFreeMarketResetTimeYesterday() {
// Uses utc time like the server.
const utcFreeMarketResetTime = new Date()
utcFreeMarketResetTime.setUTCDate(utcFreeMarketResetTime.getUTCDate() - 1)
@ -19,7 +27,7 @@ export const useHasCreatedContractToday = (user: User | null | undefined) => {
useEffect(() => {
setHasCreatedContractToday('loading')
const todayAtMidnight = getUtcFreeMarketResetTimeToday()
const todayAtMidnight = getUtcFreeMarketResetTimeYesterday()
async function listUserContractsForToday() {
if (!user) return