- 
                Notifications
    You must be signed in to change notification settings 
- Fork 5
feat: new semester #28
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
| Walkthrough将 schoolConst/const.go 中的导出日历常量更新:SchoolYear 由 2024 改为 2025,Semester 由 2 改为 1,SemesterStartTimestamp 由 1740326400 改为 1757865600。基于新起始时间,相关周数计算与时间数据中的 WeekNow 随之调整,其余逻辑未变。 Changes
 Sequence Diagram(s)sequenceDiagram
  participant C as 调用方
  participant T as TimeUtil
  participant S as schoolConst
  Note over S: SemesterStartTimestamp=1757865600(新)
  C->>T: getWeekNum(now)
  T->>S: 读取 SemesterStartTimestamp
  T->>T: 计算 (now - SemesterStartTimestamp) / 周长
  T-->>C: 返回 WeekNum
  Note over C,T: WeekNow 等字段随新起始时间变化
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
 Suggested reviewers
 Poem
 Tip 🔌 Remote MCP (Model Context Protocol) integration is now available!Pro plan users can now connect to remote MCP servers from the Integrations page. Connect with popular remote MCPs such as Notion and Linear to add more context to your reviews and chats. ✨ Finishing Touches
 🧪 Generate unit tests
 Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit: 
 SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. CodeRabbit Commands (Invoked using PR/Issue comments)Type  Other keywords and placeholders
 CodeRabbit Configuration File ( | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️  Outside diff range comments (1)
schoolConst/const.go (1)
14-17: 修复 schoolConst/const.go 行14–17 中 getWeekNum 负周数问题
getWeekNum 在开学前会因 time.Now().Unix()–SemesterStartTimestamp 为负而返回负值,导致调用方异常。请按以下方式重构:func getWeekNum() int { delta := time.Now().Unix() - SemesterStartTimestamp if delta < 0 { return 0 // 或按业务约定返回 1 } const secondsPerWeek = 7 * 24 * 60 * 60 return int(delta/secondsPerWeek) + 1 }
- 用整型运算替代 math.Floor,避免浮点误差。
- delta<0 时返回 0(或 1),移除 math 包依赖。
- 确认“开学前返回 0 还是 1”的业务预期。
🧹 Nitpick comments (4)
schoolConst/const.go (4)
9-11: 学期常量更新OK;请在时间戳注释中显式标注时区并二次核对校历日期1757865600 对应 2025-09-15 00:00:00 Asia/Shanghai(UTC+8,周一)。为避免歧义,建议把时区与星期写入注释并请再对照官方校历确认该日期无误。
- SemesterStartTimestamp = int64(1757865600) // 2025-9-15 00:00:00 + SemesterStartTimestamp = int64(1757865600) // 2025-09-15 00:00:00 Asia/Shanghai (UTC+8), Monday
3-6: 如果采纳上一条修复,请移除未使用的 math,避免编译错误采用纯整型实现后,
math将未被引用,Go 会报未使用的导入。-import ( - "math" - "time" -) +import ( + "time" +)
19-22: 确认 WeekDayNow 的取值约定;如需“周一=1…周日=7”请标准化当前
time.Weekday()返回周日=0…周六=6。若上游期望周一=1…周日=7,建议如下转换(否则保持不动即可):-func getWeekDay() int { - day := int(time.Now().Weekday()) - return day -} +func getWeekDay() int { + w := int(time.Now().Weekday()) // 0=Sunday + if w == 0 { + return 7 + } + return w +}
37-37: 避免多次读取“当前时间”带来的抖动,复用同一个 timeNow在一次请求内,二次调用
time.Now()可能跨分钟边界。直接复用已有的timeNow更稳妥。- minute := time.Now().Minute() + hour*60 + minute := timeNow.Minute() + hour*60- Timestamp: time.Now().Unix(), + Timestamp: timeNow.Unix(),Also applies to: 53-53
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
💡 Knowledge Base configuration:
- MCP integration is disabled by default for public repositories
- Jira integration is disabled by default for public repositories
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (1)
- schoolConst/const.go(1 hunks)
Summary by CodeRabbit