From 057d72b264e747c44f7e3aae41d0384c5e4aa4fa Mon Sep 17 00:00:00 2001 From: Hermes Agent Date: Thu, 16 Jul 2026 15:50:03 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=B8=8A=E6=AC=A1=E5=90=8C=E6=AD=A5?= =?UTF-8?q?=E6=97=B6=E9=97=B4=E8=BD=AC=E4=B8=BA=E6=9C=AC=E5=9C=B0=E6=97=B6?= =?UTF-8?q?=E5=8C=BA=E6=98=BE=E7=A4=BA=EF=BC=8C=E4=BF=AE=E6=AD=A3=E6=97=B6?= =?UTF-8?q?=E5=8C=BA=E6=B7=B7=E6=B7=86=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit AppConfig 存储 UTC 时间,模板直接输出导致用户在上海(UTC+8)看到错误时刻。 新增 get_last_sync_at_local() 转本地时区,logs_view 采用本地时间显示。 --- app.py | 2 +- log_storage.py | 17 +++++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/app.py b/app.py index 36ff85d..c636e3b 100644 --- a/app.py +++ b/app.py @@ -1020,7 +1020,7 @@ def logs_view(): "start_time": f_start, "end_time": f_end, }, cfg=cfg, - last_sync=log_storage.get_last_sync_at(), + last_sync=log_storage.get_last_sync_at_local(), last_sync_path=log_storage.get_last_sync_path(), use_persistent=use_persistent, format_bytes=log_parser.format_bytes, diff --git a/log_storage.py b/log_storage.py index c9e5e05..ecc4fd8 100644 --- a/log_storage.py +++ b/log_storage.py @@ -797,6 +797,23 @@ def get_last_sync_path() -> str | None: return None +def get_last_sync_at_local() -> str | None: + """Return the last-sync timestamp formatted in local time (not UTC). + + :class:`~app.AppConfig` stores the sync time as an ISO-8601 UTC string + (e.g. ``2026-07-16T07:43:36Z``). This converts it to the system's local + timezone so the UI shows a human-friendly time to the operator. + """ + ts = get_last_sync_at() + if not ts: + return None + try: + dt = datetime.fromisoformat(ts.replace("Z", "+00:00")) + return dt.astimezone().strftime("%Y-%m-%d %H:%M:%S") + except Exception: + return ts + + def import_full_history( path: str, instance_id: int = 0,