[34588f42] Fix: Robuste Zeitzonen-Handhabung (Europe/Berlin) für Scheduling
- Hardcodierter UTC+2 Offset durch ZoneInfo('Europe/Berlin') ersetzt, um automatische Sommer-/Winterzeit-Umstellung sicherzustellen.
This commit is contained in:
@@ -10,9 +10,14 @@ import time
|
||||
import asyncio
|
||||
from typing import List, Dict, Optional
|
||||
|
||||
from zoneinfo import ZoneInfo
|
||||
|
||||
router = APIRouter(prefix="/api/publish-request", tags=["publish-request"])
|
||||
logger = logging.getLogger("publish-request")
|
||||
|
||||
# Timezone for Berlin
|
||||
TZ_BERLIN = ZoneInfo("Europe/Berlin")
|
||||
|
||||
# Official Project Signature
|
||||
SIGNATURE_HTML = """
|
||||
<br><br>
|
||||
@@ -44,8 +49,8 @@ class SendReleaseRequest(BaseModel):
|
||||
|
||||
async def delayed_send(emails: List[Dict[str, str]], scheduled_time: str, db_session_factory):
|
||||
try:
|
||||
# Calculate delay
|
||||
now = datetime.datetime.now(datetime.timezone(datetime.timedelta(hours=2))) # Berlin Time Approx
|
||||
# Calculate delay using Berlin Timezone
|
||||
now = datetime.datetime.now(TZ_BERLIN)
|
||||
target_h, target_m = map(int, scheduled_time.split(":"))
|
||||
target_time = now.replace(hour=target_h, minute=target_m, second=0, microsecond=0)
|
||||
|
||||
@@ -53,7 +58,7 @@ async def delayed_send(emails: List[Dict[str, str]], scheduled_time: str, db_ses
|
||||
target_time += datetime.timedelta(days=1)
|
||||
|
||||
delay_seconds = (target_time - now).total_seconds()
|
||||
logger.info(f"Scheduling {len(emails)} emails for {scheduled_time} (in {delay_seconds} seconds)")
|
||||
logger.info(f"Scheduling {len(emails)} emails for {scheduled_time} Berlin Time (in {delay_seconds} seconds)")
|
||||
|
||||
await asyncio.sleep(delay_seconds)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user