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

8
lib/dateUtils.ts Normal file
View File

@@ -0,0 +1,8 @@
export function getTodayISOString(timezone = process.env.TZ || 'Europe/Berlin'): string {
return new Date().toLocaleDateString('en-CA', {
timeZone: timezone,
year: 'numeric',
month: '2-digit',
day: '2-digit'
});
}

View File

@@ -1,6 +1,7 @@
'use client';
import { useState, useEffect } from 'react';
import { getTodayISOString } from './dateUtils';
export interface GameState {
date: string;
@@ -31,7 +32,7 @@ export function useGameState() {
useEffect(() => {
// Load game state
const stored = localStorage.getItem(STORAGE_KEY);
const today = new Date().toISOString().split('T')[0];
const today = getTodayISOString();
if (stored) {
const parsed: GameState = JSON.parse(stored);