Readds leap year checks (#2)

This commit is contained in:
voloved
2024-10-27 14:04:56 -04:00
committed by GitHub
parent c0514ad39a
commit d05a851d94
7 changed files with 15 additions and 25 deletions

View File

@@ -320,3 +320,11 @@ uint32_t watch_utility_offset_timestamp(uint32_t now, int8_t hours, int8_t minut
new += seconds;
return new;
}
uint8_t watch_utility_days_in_month(uint8_t month, uint16_t year) {
static const uint8_t days_in_month[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
uint8_t days = days_in_month[month - 1];
if (month == 2 && is_leap(year))
days += 1;
return days;
}

View File

@@ -172,6 +172,6 @@ uint32_t watch_utility_offset_timestamp(uint32_t now, int8_t hours, int8_t minut
* @param month The month of the date (1-12)
* @param year The year of the date (ex. 2022)
*/
uint8_t days_in_month(uint8_t month, uint16_t year);
uint8_t watch_utility_days_in_month(uint8_t month, uint16_t year);
#endif