From a7dd926877cbbaa16e60bfca8ae5d967c6cf0899 Mon Sep 17 00:00:00 2001 From: hailin Date: Mon, 2 Mar 2026 21:26:47 -0800 Subject: [PATCH] =?UTF-8?q?fix(mining-app):=20=E4=BF=AE=E5=A4=8D=E5=88=86?= =?UTF-8?q?=E9=85=8D=E8=AE=B0=E5=BD=95=20distributionMinute=20=E6=97=B6?= =?UTF-8?q?=E9=97=B4=E4=BB=8D=E6=98=BE=E7=A4=BAUTC=E7=9A=84=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 上次修复使用了 DateTime.parse(t).toLocal(),但 distributionMinute 字符串不带 Z 后缀(如 "2026-03-03 05:09:00"),Dart 的 DateTime.parse 在无时区标识时默认当作本地时间处理,导致 .toLocal() 无效。 修复:解析前追加 Z 后缀,强制标记为 UTC,使 .toLocal() 正确转换 为北京时间(UTC+8)。 Co-Authored-By: Claude Opus 4.6 --- .../lib/presentation/pages/profile/mining_records_page.dart | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/frontend/mining-app/lib/presentation/pages/profile/mining_records_page.dart b/frontend/mining-app/lib/presentation/pages/profile/mining_records_page.dart index 805cea6b..4dce17cf 100644 --- a/frontend/mining-app/lib/presentation/pages/profile/mining_records_page.dart +++ b/frontend/mining-app/lib/presentation/pages/profile/mining_records_page.dart @@ -298,7 +298,10 @@ class _MiningRecordsListPageState extends ConsumerState { // 去掉秒和毫秒部分,截短年份 final t = time.replaceAll('T', ' ').split('.').first; // 去毫秒 try { - final dt = DateTime.parse(t).toLocal(); + // distributionMinute 从后端返回的是 UTC 时间但不带 Z 后缀, + // DateTime.parse 不带 Z 会当作本地时间, 需要追加 Z 标记为 UTC + final utcStr = t.endsWith('Z') ? t : '${t}Z'; + final dt = DateTime.parse(utcStr).toLocal(); final y = (dt.year % 100).toString().padLeft(2, '0'); final m = dt.month.toString().padLeft(2, '0'); final d = dt.day.toString().padLeft(2, '0');