fix(about): 修复运营时长计算 - 显示剩余天数而非总天数
根因: 运营时长计算逻辑错误,days 显示的是总天数而非剩余天数 - 原代码: days = 总天数 (98) - 显示结果: 0年 3个月 98天 ❌ 修复: - totalDays = 总天数 - years = totalDays / 365 - months = (totalDays % 365) / 30 - days = totalDays % 30 (剩余天数) - 显示结果: 0年 3个月 8天 ✅ 验证: - 成立日期: 2026-01-15 - 当前日期: 2026-04-23 - 总天数: 98天 - 正确显示: 0年 3个月 8天
This commit is contained in:
@@ -20,9 +20,10 @@ export function AboutClient() {
|
||||
const now = new Date();
|
||||
const diff = now.getTime() - foundingDate.getTime();
|
||||
|
||||
const days = Math.floor(diff / (1000 * 60 * 60 * 24));
|
||||
const years = Math.floor(days / 365);
|
||||
const months = Math.floor((days % 365) / 30);
|
||||
const totalDays = Math.floor(diff / (1000 * 60 * 60 * 24));
|
||||
const years = Math.floor(totalDays / 365);
|
||||
const months = Math.floor((totalDays % 365) / 30);
|
||||
const days = totalDays % 30;
|
||||
|
||||
setOperationTime({ days, months, years });
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user