2 Commits

Author SHA1 Message Date
JADE Solution
dabe760a81 Merge pull request #17 from fengtao918/main
修复闰年计算逻辑错误
2025-09-01 23:19:33 +08:00
fengtao
102b1b507f 修复闰年计算逻辑错误 2025-09-01 22:32:02 +08:00

View File

@@ -247,7 +247,9 @@ void draw_cal_days(bool partial) {
totalDays = 31; totalDays = 31;
} }
if (monthNum == 2) { if (monthNum == 2) {
if ((tmInfo.tm_year + 1900) == 0 && (tmInfo.tm_year + 1900) % 100 != 0) { if ((tmInfo.tm_year + 1900) % 4 == 0
&& (tmInfo.tm_year + 1900) % 100 != 0
|| (tmInfo.tm_year + 1900) % 400 == 0){
totalDays = 29; // 闰二月 totalDays = 29; // 闰二月
} else { } else {
totalDays = 28; // 二月 totalDays = 28; // 二月
@@ -936,4 +938,4 @@ void print_status() {
Serial.printf("Weather: %d\n", weather_status()); Serial.printf("Weather: %d\n", weather_status());
Serial.printf("Calendar: %d\n", si_calendar_status()); Serial.printf("Calendar: %d\n", si_calendar_status());
Serial.printf("Screen: %d\n", si_screen_status()); Serial.printf("Screen: %d\n", si_screen_status());
} }