diff --git a/front/deviceDetailsSessions.php b/front/deviceDetailsSessions.php index 837a8971..0d8c7664 100755 --- a/front/deviceDetailsSessions.php +++ b/front/deviceDetailsSessions.php @@ -56,9 +56,6 @@ function initializeSessionsDatatable (sessionsRows) { if (!cellData.includes("missing event") && !cellData.includes("...")) { - if (cellData.includes("+")) { // Check if timezone offset is present - cellData = cellData.split('+')[0]; // Remove timezone offset - } // console.log(cellData); result = localizeTimestamp(cellData); } else diff --git a/front/plugins/sync/config.json b/front/plugins/sync/config.json index 7179071b..e364c339 100755 --- a/front/plugins/sync/config.json +++ b/front/plugins/sync/config.json @@ -613,7 +613,8 @@ "options": [ "devMac", "devName", - "devVendor" + "devVendor", + "devLastIP" ], "localized": ["name", "description"], "name": [ @@ -810,7 +811,7 @@ "column": "Dummy", "mapped_to_column": "scanSourcePlugin", "mapped_to_column_data": { - "value": "sync" + "value": "SYNC" }, "css_classes": "col-sm-2", "show": false, diff --git a/server/api_server/api_server_start.py b/server/api_server/api_server_start.py index 484e19f0..f1342397 100755 --- a/server/api_server/api_server_start.py +++ b/server/api_server/api_server_start.py @@ -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(): diff --git a/server/messaging/reporting.py b/server/messaging/reporting.py index dfe9f087..811e8ed7 100755 --- a/server/messaging/reporting.py +++ b/server/messaging/reporting.py @@ -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", []) diff --git a/server/utils/datetime_utils.py b/server/utils/datetime_utils.py index df125b39..4366e7c0 100644 --- a/server/utils/datetime_utils.py +++ b/server/utils/datetime_utils.py @@ -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()