Skip to content

Conversation

@n313893254
Copy link

@n313893254 n313893254 commented Jan 9, 2026

🤔 这个分支是...

  • Bug fix

🔗 相关 issue 连接

原有的计算逻辑存在缺陷,特别是在跨越不同天数的月份时(如从 31 天的 1 月到 28 天的 2 月)。

  • 原逻辑问题:在计算不足一个月的零头天数差时,统一使用了 adjusted_date(结束日期)所在月份的总天数作为分母。
    • 公式:MonthDiff + (adjusted_date - StartDay) / EndMonthDays
    • 重现: computeCountToTimeScale('2026-01-31', '2026-02-05', 'month', 1, 1)
    • 案例(2026年1月31日 - 2月5日)
      • 结果:宽度为0

💡 问题的背景&解决方案

1. 修复方案

我已将计算逻辑修改为分别计算开始日期和结束日期在各自月份中的进度比例,然后求差。

  • 新逻辑MonthDiff + (EndDay / EndMonthDays) - (StartDay / StartMonthDays)
  • 验证(2026年1月31日 - 2月5日)
    • 月份差:1
    • 结束进度(2月5日):5 / 28 ≈ 0.1786
    • 开始进度(1月31日):31 / 31 = 1.0
    • 结果:1 + 0.1786 - 1.0 = 0.1786 个月(符合预期)

📝 Changelog

Language Changelog
🇺🇸 English
🇨🇳 Chinese

☑️ 自测

⚠️ 在提交 PR 之前,请检查一下内容. ⚠️

  • 不需要
  • 不需要
  • 不需要
  • 不需要

🚀 Summary

copilot:summary

🔍 Walkthrough

copilot:walkthrough

@n313893254 n313893254 marked this pull request as ready for review January 9, 2026 11:38
@fangsmile
Copy link
Contributor

@n313893254 建议 帮忙看下季度 年份的逻辑是否需要作相应变更

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants