fix: formatDuration 时间差为0时显示0h而非1天
之前 hours=0 时会落到 days 分支显示"1天",实际是开始和完成时间相同。 现在统一按小时数判断,不到1天显示Xh,整天显示X天。 Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -55,9 +55,10 @@ export function calcPlanDuration(start: string, end: string): { days: number; ho
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function formatDuration(days: number, hours: number): string {
|
export function formatDuration(days: number, hours: number): string {
|
||||||
if (hours > 0) return `${hours}h`;
|
if (hours <= 0) return '0h';
|
||||||
if (days === 0) return '0天';
|
if (hours < 24) return `${hours}h`;
|
||||||
return `${days}天`;
|
if (hours % 24 === 0) return `${hours / 24}天`;
|
||||||
|
return `${hours}h`;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function calcTotalDuration(plans: VersionPlan[]): string {
|
export function calcTotalDuration(plans: VersionPlan[]): string {
|
||||||
|
|||||||
Reference in New Issue
Block a user