From ff709eadca60d6c7b793adaab386e56eb83dd4b4 Mon Sep 17 00:00:00 2001 From: ninemine <1371605831@qq.com> Date: Fri, 31 Oct 2025 18:01:33 +0800 Subject: [PATCH] =?UTF-8?q?=E5=86=92=E9=99=A9=E4=BB=BB=E5=8A=A1=E8=BE=93?= =?UTF-8?q?=E5=87=BA=E6=A0=BC=E5=BC=8F=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...25-10-31_1_change-adventure-time-to-seconds.md | 15 ++++++++++++++- games/adventure.py | 8 +++++++- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/.tasks/2025-10-31_1_change-adventure-time-to-seconds.md b/.tasks/2025-10-31_1_change-adventure-time-to-seconds.md index b1a31b4..484b075 100644 --- a/.tasks/2025-10-31_1_change-adventure-time-to-seconds.md +++ b/.tasks/2025-10-31_1_change-adventure-time-to-seconds.md @@ -74,7 +74,20 @@ Yolo模式:Off 6. 更新帮助信息:添加时间格式说明和示例 - 原因:支持更灵活的时间输入格式,提升用户体验;时间显示按时分秒格式,避免冗长的秒数显示 - 阻碍因素:无 -- 状态:待确认 +- 状态:成功 + +## 2025-10-31_17:49:24 +- 已修改:games/adventure.py +- 更改: + 1. 修复预计完成时间显示问题: + - 原问题:只显示小时时刻(`%H:%M:%S`),跨天的冒险无法正确显示,且秒数显示不够明确 + - 第一次尝试:根据冒险时长是否超过24小时判断(不准确) + - 最终解决方案:根据完成时间是否跨天来判断 + - 跨天或跨年:显示完整日期时间 `YYYY-MM-DD HH:MM:SS`(包含年月日和时分秒) + - 同一天:显示时间 `HH:MM:SS`(包含时分秒) +- 原因:修复跨天冒险无法正确显示完成时间的问题,只要跨天就显示完整日期,确保秒数清晰显示 +- 阻碍因素:无 +- 状态:成功 # 最终审查 diff --git a/games/adventure.py b/games/adventure.py index e229244..e988662 100644 --- a/games/adventure.py +++ b/games/adventure.py @@ -232,7 +232,13 @@ class AdventureGame(BaseGame): # 计算预计完成时间 end_time = current_time + cost_time end_datetime = datetime.fromtimestamp(end_time) - end_time_str = end_datetime.strftime('%H:%M:%S') + current_datetime = datetime.fromtimestamp(current_time) + # 判断是否跨天:如果完成日期和当前日期不同,或跨年,则显示完整日期时间 + if (end_datetime.date() != current_datetime.date() or + end_datetime.year != current_datetime.year): + end_time_str = end_datetime.strftime('%Y-%m-%d %H:%M:%S') + else: + end_time_str = end_datetime.strftime('%H:%M:%S') cost_time_str = self._format_time(cost_time) text = f"## ⚡️ 冒险开始\n\n"