Leap Years Now Handled Dynamically
This commit is contained in:
@@ -26,8 +26,9 @@
|
||||
#include <string.h>
|
||||
#include "day_one_face.h"
|
||||
#include "watch.h"
|
||||
#include "watch_utility.h"
|
||||
|
||||
static const uint8_t days_in_month[12] = {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
|
||||
static const uint8_t days_in_month[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
|
||||
|
||||
static uint32_t _day_one_face_juliandaynum(uint16_t year, uint16_t month, uint16_t day) {
|
||||
// from here: https://en.wikipedia.org/wiki/Julian_day#Julian_day_number_calculation
|
||||
@@ -66,13 +67,12 @@ static void _day_one_face_increment(day_one_state_t *state) {
|
||||
break;
|
||||
case PAGE_DAY:
|
||||
state->birth_day = state->birth_day + 1;
|
||||
if (state->birth_day == 0 || state->birth_day > days_in_month[state->birth_month - 1]) {
|
||||
state->birth_day = 1;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
if (state->birth_day == 0 || state->birth_day > (days_in_month[state->birth_month - 1] + (is_leap(state->birth_year) && state->birth_month == 2)))
|
||||
state->birth_day = 1;
|
||||
}
|
||||
|
||||
void day_one_face_setup(movement_settings_t *settings, uint8_t watch_face_index, void ** context_ptr) {
|
||||
|
||||
Reference in New Issue
Block a user