Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions apps/api/src/services/vote.Service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,33 @@ import { eq, count } from 'drizzle-orm'
import type { AppEnv } from '../types'
import { ensureUserExists } from './user.Service'
import { refreshStallAggregates } from './stalls.Service'
function isVotingOpen(): boolean {
const istOffset = 5.5 * 60 * 60 * 1000;
const istTime = new Date(Date.now() + istOffset);

const year = istTime.getUTCFullYear();
const month = istTime.getUTCMonth() + 1;
const day = istTime.getUTCDate();

if (year !== 2026 || month !== 3) return false;

const timeInMinutes = istTime.getUTCHours() * 60 + istTime.getUTCMinutes();

if (day === 28) {
const startMinsDay1 = 8 * 60 + 30; // 8:30 AM (510)
const endMins = 22 * 60; // 10:00 PM (1320)
return timeInMinutes >= startMinsDay1 && timeInMinutes <= endMins;
}

if (day === 29) {
const startMinsDay2 = 9 * 60 + 30; // 9:30 AM (570)
const endMins = 12 * 60; // 12:00 PM (720)
return timeInMinutes >= startMinsDay2 && timeInMinutes <= endMins;
}

return false;
}

export const submitVote = async (
env: AppEnv['Bindings'],
userId: string,
Expand Down
Loading