Skip to content
Open
Show file tree
Hide file tree
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
11 changes: 9 additions & 2 deletions app/main.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import logging
from datetime import datetime
import pytz
import os
from fastapi import FastAPI, Request
from fastapi.responses import (
JSONResponse,
Expand Down Expand Up @@ -87,8 +88,14 @@ async def get_date_info(request: Request):
params = dict(request.query_params)
logger.debug(f"GET /app/neng/getDateInfoeu.php - Query params: {params}")

# Get current date in UTC and format it
now = datetime.now(pytz.utc)
# Get current date and format it
# Return localtime or UTC if timezone is not set
tz_name = os.getenv("APP_TIMEZONE")

try:
now = datetime.now(pytz.utc).astimezone(pytz.timezone(tz_name))
except pytz.UnknownTimeZoneError:
now = datetime.now(pytz.utc)

# Format: _YYYY_MM_DD_HH_MM_SS_04_0_0_0
formatted_date = f"_{now.year}_{now.month:02d}_{now.day:02d}_{now.hour:02d}_{now.minute:02d}_{now.second:02d}_04_0_0_0"
Expand Down
1 change: 1 addition & 0 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ services:
- "80:8000"
environment:
- LOG_LEVEL=info
- APP_TIMEZONE=Europe/Berlin