From 8913758a24a0a75d782f0c3d6d25fbb72c9f5009 Mon Sep 17 00:00:00 2001 From: Konrad Rieck Date: Mon, 27 Jul 2026 20:39:30 +0200 Subject: [PATCH 1/3] Fix wrong July day count in deadline_face settings table The local days_in_month table in _increment_date() listed July as having 30 days instead of 31, diverging from the correct table in _days_in_month(). This made July 31 unreachable when incrementing the day field in settings mode. Co-Authored-By: Claude Sonnet 5 Claude-Session: https://claude.ai/code/session_01PSucp94GA31sshe5AjvSzQ --- watch-faces/complication/deadline_face.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/watch-faces/complication/deadline_face.c b/watch-faces/complication/deadline_face.c index ebad0e8b..f1254c7e 100644 --- a/watch-faces/complication/deadline_face.c +++ b/watch-faces/complication/deadline_face.c @@ -227,7 +227,7 @@ static void _correct_time_difference(int16_t *units, watch_date_time_t deadline) /* Increment date in settings mode. Function taken from `set_time_face.c` */ static void _increment_date(deadline_state_t *state, watch_date_time_t date_time) { - const uint8_t days_in_month[12] = { 31, 28, 31, 30, 31, 30, 30, 31, 30, 31, 30, 31 }; + const uint8_t days_in_month[12] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }; switch (state->current_page) { case 0: From 0b7ea662fee0530272a7557e045a5f7643673744 Mon Sep 17 00:00:00 2001 From: Konrad Rieck Date: Mon, 27 Jul 2026 20:40:21 +0200 Subject: [PATCH 2/3] Fix day-increment overflow check in deadline_face settings date_time.unit.day is a 5-bit bitfield (max 31). Incrementing 31 directly in the bitfield wrapped to 0 via truncation before the day > days_in_month bounds check ever ran, so the overflow was never caught. The result decoded as "day 0" of the current month, i.e. the last day of the previous month, silently rolling the displayed date backwards (e.g. Aug 31 -> Jul 31 -> Jun 30). Compute the incremented day in a plain uint8_t local first, compare it against the month length, and only then write the final value into the bitfield. Co-Authored-By: Claude Sonnet 5 Claude-Session: https://claude.ai/code/session_01PSucp94GA31sshe5AjvSzQ --- watch-faces/complication/deadline_face.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/watch-faces/complication/deadline_face.c b/watch-faces/complication/deadline_face.c index f1254c7e..814701a0 100644 --- a/watch-faces/complication/deadline_face.c +++ b/watch-faces/complication/deadline_face.c @@ -237,17 +237,18 @@ static void _increment_date(deadline_state_t *state, watch_date_time_t date_time case 1: date_time.unit.month = (date_time.unit.month % 12) + 1; break; - case 2: - date_time.unit.day = date_time.unit.day + 1; - + case 2: { /* Check for leap years */ - int8_t days = days_in_month[date_time.unit.month - 1]; + uint8_t days = days_in_month[date_time.unit.month - 1]; if (date_time.unit.month == 2 && _is_leap(date_time.unit.year)) days++; - if (date_time.unit.day > days) - date_time.unit.day = 1; + /* Compute next day outside the 5-bit bitfield so overflow past 31 + * can be compared against `days` before it gets truncated. */ + uint8_t day = date_time.unit.day + 1; + date_time.unit.day = (day > days) ? 1 : day; break; + } case 3: date_time.unit.hour = (date_time.unit.hour + 1) % 24; break; From eacb6de737669fd24cb9d1e66394f2cdbda69f32 Mon Sep 17 00:00:00 2001 From: Konrad Rieck Date: Mon, 27 Jul 2026 20:41:36 +0200 Subject: [PATCH 3/3] Deduplicate month-length table in deadline_face _increment_date() kept its own copy of the days-per-month table and leap-year check, duplicating _days_in_month() in the same file. Two sources of truth is how the July day-count typo went unnoticed. Call _days_in_month() directly instead, leaving one table in the file. Co-Authored-By: Claude Sonnet 5 Claude-Session: https://claude.ai/code/session_01PSucp94GA31sshe5AjvSzQ --- watch-faces/complication/deadline_face.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/watch-faces/complication/deadline_face.c b/watch-faces/complication/deadline_face.c index 814701a0..a7e0aee7 100644 --- a/watch-faces/complication/deadline_face.c +++ b/watch-faces/complication/deadline_face.c @@ -227,8 +227,6 @@ static void _correct_time_difference(int16_t *units, watch_date_time_t deadline) /* Increment date in settings mode. Function taken from `set_time_face.c` */ static void _increment_date(deadline_state_t *state, watch_date_time_t date_time) { - const uint8_t days_in_month[12] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }; - switch (state->current_page) { case 0: /* Only 10 years covered. Fix this sometime next decade */ @@ -238,10 +236,7 @@ static void _increment_date(deadline_state_t *state, watch_date_time_t date_time date_time.unit.month = (date_time.unit.month % 12) + 1; break; case 2: { - /* Check for leap years */ - uint8_t days = days_in_month[date_time.unit.month - 1]; - if (date_time.unit.month == 2 && _is_leap(date_time.unit.year)) - days++; + int days = _days_in_month(date_time.unit.month, date_time.unit.year); /* Compute next day outside the 5-bit bitfield so overflow past 31 * can be compared against `days` before it gets truncated. */