fix(gantt): correct month difference calculation for variable month lengths #4909
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
🤔 这个分支是...
🔗 相关 issue 连接
原有的计算逻辑存在缺陷,特别是在跨越不同天数的月份时(如从 31 天的 1 月到 28 天的 2 月)。
adjusted_date(结束日期)所在月份的总天数作为分母。MonthDiff + (adjusted_date - StartDay) / EndMonthDayscomputeCountToTimeScale('2026-01-31', '2026-02-05', 'month', 1, 1)💡 问题的背景&解决方案
1. 修复方案
我已将计算逻辑修改为分别计算开始日期和结束日期在各自月份中的进度比例,然后求差。
MonthDiff + (EndDay / EndMonthDays) - (StartDay / StartMonthDays)5 / 28 ≈ 0.178631 / 31 = 1.01 + 0.1786 - 1.0 = 0.1786个月(符合预期)📝 Changelog
☑️ 自测
🚀 Summary
copilot:summary
🔍 Walkthrough
copilot:walkthrough