Fix daily puzzle rotation timezone issue

- Added lib/dateUtils.ts for consistent timezone handling
- Updated app/page.tsx and app/api/daily/route.ts to use Europe/Berlin timezone
- Updated lib/gameState.ts to sync client-side daily check with server time
- Exposed TZ env var to client in next.config.ts
This commit is contained in:
Hördle Bot
2025-11-22 00:44:14 +01:00
parent 3e0fa430a3
commit 4f8524c286
6 changed files with 66 additions and 10 deletions

View File

@@ -1,18 +1,12 @@
import { NextResponse } from 'next/server';
import { PrismaClient } from '@prisma/client';
import { getTodayISOString } from '@/lib/dateUtils';
const prisma = new PrismaClient();
export async function GET() {
try {
// Use timezone from environment variable (default: Europe/Berlin)
const timezone = process.env.TZ || 'Europe/Berlin';
const today = new Date().toLocaleDateString('en-CA', {
timeZone: timezone,
year: 'numeric',
month: '2-digit',
day: '2-digit'
}); // Format: "2025-11-21"
const today = getTodayISOString();
let dailyPuzzle = await prisma.dailyPuzzle.findUnique({
where: { date: today },