From 603ecb08871d1f8e5c394a3455e4f63abca0b4b8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E5=BE=B7=E5=AE=87?= Date: Fri, 2 Oct 2026 19:11:59 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D(=E8=AE=A1=E8=B4=B9):=20?= =?UTF-8?q?=E6=98=9F=E6=9C=9F=E6=8D=A2=E7=AE=97=E9=81=BF=E5=85=8D=20i64=20?= =?UTF-8?q?=E6=BA=A2=E5=87=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit weekday_from_date_key 先按 7 取模再加偏移,消除 date_key 接近 i64::MAX 时的中间加法溢出 Co-authored-by: Junie --- server-rs/crates/module-runtime/src/civil_calendar.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server-rs/crates/module-runtime/src/civil_calendar.rs b/server-rs/crates/module-runtime/src/civil_calendar.rs index 60c0a4ec8..bc6cec172 100644 --- a/server-rs/crates/module-runtime/src/civil_calendar.rs +++ b/server-rs/crates/module-runtime/src/civil_calendar.rs @@ -54,7 +54,7 @@ pub fn civil_from_days(date_key: i64) -> (i32, u8, u8) { /// ISO 星期:周一 = 1,周日 = 7。 pub fn weekday_from_date_key(date_key: i64) -> u8 { // 中文注释:1970-01-01 是周四;这里返回 ISO weekday,周一=1,周日=7。 - (date_key + 3).rem_euclid(7) as u8 + 1 + (date_key.rem_euclid(7) + 3).rem_euclid(7) as u8 + 1 } #[cfg(test)]