BE+FE: timestamps for sessions and emails corrected #1639

This commit is contained in:
jokob-sk committed 2026-05-16 14:13:59 +10:00
commit bf4e0b4a7c
5 files changed
+17 -20

No files matched your search

-3
View File
@@ -185,9 +185,6 @@ def is_authorized():
return is_authorized_result
@app.route('/mcp/sse', methods=['GET', 'POST', 'OPTIONS'])
def api_mcp_sse():
if not is_authorized():
+4 -3
View File
@@ -35,11 +35,10 @@ from messaging.notification_sections import ( # noqa: E402 [flake8 lint suppres
)
import conf # noqa: E402 [flake8 lint suppression]
# ===============================================================================
# Timezone conversion
# ===============================================================================
def get_datetime_fields_from_columns(column_names):
return [
col for col in column_names
@@ -81,6 +80,7 @@ def apply_timezone(data, fields):
for field in fields:
value = row.get(field)
if not value:
continue
@@ -226,11 +226,12 @@ def get_notifications(db):
try:
json_obj = db.get_table_as_json(sqlQuery, parameters)
data = apply_timezone_to_json(json_obj, section)
except Exception as e:
mylog("minimal", [f"[Notification] DB error in section {section}: ", e])
continue
final_json[section] = json_obj.json.get("data", [])
final_json[section] = data
final_json[f"{section}_meta"] = {
"title": SECTION_TITLES.get(section, section),
"columnNames": getattr(json_obj, "columnNames", [])
+10 -9
View File
@@ -206,17 +206,18 @@ def format_date_iso(date_val: str) -> Optional[str]:
else:
dt = date_val
# 2. If it has no timezone, assume it's UTC (our DB storage format)
# then CONVERT to user's configured timezone
# 2. Normalize to UTC first, then convert to target timezone
if dt.tzinfo is None:
# Mark as UTC first — critical: localize() would label without converting
dt = dt.replace(tzinfo=datetime.UTC)
# Resolve target timezone; fall back to UTC if conf.tz is missing/invalid
try:
target_tz = conf.tz if isinstance(conf.tz, datetime.tzinfo) else ZoneInfo(conf.tz)
except (ZoneInfoNotFoundError, ValueError, TypeError):
target_tz = datetime.UTC
dt = dt.astimezone(target_tz)
else:
dt = dt.astimezone(datetime.UTC)
try:
target_tz = conf.tz if isinstance(conf.tz, datetime.tzinfo) else ZoneInfo(str(conf.tz))
except Exception:
target_tz = datetime.UTC
dt = dt.astimezone(target_tz)
# 3. Return the string. .isoformat() will now include the +11:00 or +10:00
return dt.isoformat()