Skip to content

Commit d69bfc9

Browse files
authored
Merge pull request #46 from Developer-Kommunity-24/timings
830 timing
2 parents 6e293cb + f4b76d9 commit d69bfc9

1 file changed

Lines changed: 27 additions & 0 deletions

File tree

apps/api/src/services/vote.Service.ts

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,33 @@ import { eq, count } from 'drizzle-orm'
55
import type { AppEnv } from '../types'
66
import { ensureUserExists } from './user.Service'
77
import { refreshStallAggregates } from './stalls.Service'
8+
function isVotingOpen(): boolean {
9+
const istOffset = 5.5 * 60 * 60 * 1000;
10+
const istTime = new Date(Date.now() + istOffset);
11+
12+
const year = istTime.getUTCFullYear();
13+
const month = istTime.getUTCMonth() + 1;
14+
const day = istTime.getUTCDate();
15+
16+
if (year !== 2026 || month !== 3) return false;
17+
18+
const timeInMinutes = istTime.getUTCHours() * 60 + istTime.getUTCMinutes();
19+
20+
if (day === 28) {
21+
const startMinsDay1 = 8 * 60 + 30; // 8:30 AM (510)
22+
const endMins = 22 * 60; // 10:00 PM (1320)
23+
return timeInMinutes >= startMinsDay1 && timeInMinutes <= endMins;
24+
}
25+
26+
if (day === 29) {
27+
const startMinsDay2 = 9 * 60 + 30; // 9:30 AM (570)
28+
const endMins = 12 * 60; // 12:00 PM (720)
29+
return timeInMinutes >= startMinsDay2 && timeInMinutes <= endMins;
30+
}
31+
32+
return false;
33+
}
34+
835
export const submitVote = async (
936
env: AppEnv['Bindings'],
1037
userId: string,

0 commit comments

Comments
 (0)