Skip to content

Conversation

@Jiahe114514
Copy link

@Jiahe114514 Jiahe114514 commented Aug 29, 2025

Summary by CodeRabbit

  • Chores
    • 更新学年/学期与开学日期至2025年秋季(学年2025、学期1,开学日2025-09-15)。
    • “当前周次”、学期起止与相关时间计算将按新基准自动更新,覆盖课程表、校历视图与提醒等模块。
    • 无需用户操作,更新后即生效;不影响其他功能与数据,仅校历时间基准调整。

@coderabbitai
Copy link

coderabbitai bot commented Aug 29, 2025

Walkthrough

将 schoolConst/const.go 中的导出日历常量更新:SchoolYear 由 2024 改为 2025,Semester 由 2 改为 1,SemesterStartTimestamp 由 1740326400 改为 1757865600。基于新起始时间,相关周数计算与时间数据中的 WeekNow 随之调整,其余逻辑未变。

Changes

Cohort / File(s) Change Summary
学期日历常量更新
schoolConst/const.go
更新导出常量:SchoolYear=2025,Semester=1,SemesterStartTimestamp=1757865600;周数计算以新起始时间为基准;无结构或签名变更。

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 等字段随新起始时间变化
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

Suggested reviewers

  • setcy

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 Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat/2025-2026-1-semester

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.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbit in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbit in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbit gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbit read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbit help to get the list of available commands.

Other keywords and placeholders

  • Add @coderabbit ignore or @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbit summary or @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbit or @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a 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
}
  1. 用整型运算替代 math.Floor,避免浮点误差。
  2. delta<0 时返回 0(或 1),移除 math 包依赖。
  3. 确认“开学前返回 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.

📥 Commits

Reviewing files that changed from the base of the PR and between 63b82f0 and d95478b.

📒 Files selected for processing (1)
  • schoolConst/const.go (1 hunks)

@Echin-h Echin-h merged commit 780aad3 into main Aug 29, 2025
2 checks passed
@Echin-h Echin-h deleted the feat/2025-2026-1-semester branch August 29, 2025 08:37
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.

3 participants