Made the days_in_month its own function

This commit is contained in:
David Volovskiy
2024-08-10 07:40:52 -04:00
parent 6ae5dfef70
commit 09576807eb
7 changed files with 21 additions and 13 deletions

View File

@@ -315,3 +315,11 @@ uint32_t watch_utility_offset_timestamp(uint32_t now, int8_t hours, int8_t minut
new += seconds;
return new;
}
uint8_t 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

@@ -164,4 +164,10 @@ float watch_utility_thermistor_temperature(uint16_t value, bool highside, float
*/
uint32_t watch_utility_offset_timestamp(uint32_t now, int8_t hours, int8_t minutes, int8_t seconds);
/** @brief Returns the number of days in a month. It also handles Leap Years for February.
* @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);
#endif