From e92ec4eb0e8f36fd65cbc0d9995601eeb1b878a6 Mon Sep 17 00:00:00 2001 From: Script Generator Date: Fri, 12 Jun 2026 16:43:54 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20formatDuration=20=E6=97=B6=E9=97=B4?= =?UTF-8?q?=E5=B7=AE=E4=B8=BA0=E6=97=B6=E6=98=BE=E7=A4=BA0h=E8=80=8C?= =?UTF-8?q?=E9=9D=9E1=E5=A4=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 之前 hours=0 时会落到 days 分支显示"1天",实际是开始和完成时间相同。 现在统一按小时数判断,不到1天显示Xh,整天显示X天。 Co-Authored-By: Claude Opus 4.7 (1M context) --- apps/web/lib/version-plan.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/apps/web/lib/version-plan.ts b/apps/web/lib/version-plan.ts index 0891620..59ee789 100644 --- a/apps/web/lib/version-plan.ts +++ b/apps/web/lib/version-plan.ts @@ -55,9 +55,10 @@ export function calcPlanDuration(start: string, end: string): { days: number; ho } export function formatDuration(days: number, hours: number): string { - if (hours > 0) return `${hours}h`; - if (days === 0) return '0天'; - return `${days}天`; + if (hours <= 0) return '0h'; + if (hours < 24) return `${hours}h`; + if (hours % 24 === 0) return `${hours / 24}天`; + return `${hours}h`; } export function calcTotalDuration(plans: VersionPlan[]): string {