Merge pull request #122 from alesgenova/fix-year-2067

fix int32 overflow when setting a year past 2067
This commit is contained in:
atax1a 2025-10-14 00:41:20 +00:00 committed by GitHub
commit fe1c024e47
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 3 additions and 2 deletions

View File

@ -46,7 +46,7 @@ static void _handle_alarm_button(watch_date_time_t date_time, uint8_t current_pa
current_offset = movement_get_current_timezone_offset_for_zone(movement_get_timezone_index());
return;
case 0: // year
date_time.unit.year = ((date_time.unit.year % 60) + 1);
date_time.unit.year = (date_time.unit.year + 1) % 60;
break;
case 1: // month
date_time.unit.month = (date_time.unit.month % 12) + 1;

View File

@ -205,7 +205,8 @@ uint32_t watch_utility_date_time_to_unix_time(watch_date_time_t date_time, int32
watch_date_time_t watch_utility_date_time_from_unix_time(uint32_t timestamp, int32_t utc_offset) {
watch_date_time_t retval;
retval.reg = 0;
int32_t days, secs;
uint32_t secs;
int32_t days;
int32_t remdays, remsecs, remyears;
int32_t qc_cycles, c_cycles, q_cycles;
int32_t years, months;