Merge PR #470 - implement automatic DST toggling
Implements logic to automatically offset daylight saving time settings when calculating timezone offsets. This should make the DST functions work automatically with no need for user input in most cases. Reviewed-by: Matheus Afonso Martins Moreira <matheus@matheusmoreira.com> GitHub-Pull-Request: https://github.com/joeycastillo/Sensor-Watch/pull/470
This commit is contained in:
@@ -154,6 +154,7 @@ void world_clock2_face_activate(movement_settings_t *settings, void *context)
|
||||
movement_request_tick_frequency(4);
|
||||
break;
|
||||
}
|
||||
state->tz = get_timezone_offset(settings->bit.time_zone, watch_rtc_get_date_time());
|
||||
refresh_face = true;
|
||||
}
|
||||
|
||||
@@ -183,8 +184,8 @@ static bool mode_display(movement_event_t event, movement_settings_t *settings,
|
||||
|
||||
/* Determine current time at time zone and store date/time */
|
||||
date_time = watch_rtc_get_date_time();
|
||||
timestamp = watch_utility_date_time_to_unix_time(date_time, movement_timezone_offsets[settings->bit.time_zone] * 60);
|
||||
date_time = watch_utility_date_time_from_unix_time(timestamp, movement_timezone_offsets[state->current_zone] * 60);
|
||||
timestamp = watch_utility_date_time_to_unix_time(date_time, state->tz * 60);
|
||||
date_time = watch_utility_date_time_from_unix_time(timestamp, state->tz * 60);
|
||||
previous_date_time = state->previous_date_time;
|
||||
state->previous_date_time = date_time.reg;
|
||||
|
||||
@@ -289,7 +290,7 @@ static bool mode_settings(movement_event_t event, movement_settings_t *settings,
|
||||
watch_clear_indicator(WATCH_INDICATOR_PM);
|
||||
refresh_face = false;
|
||||
}
|
||||
result = div(movement_timezone_offsets[state->current_zone], 60);
|
||||
result = div(state->tz, 60);
|
||||
hours = result.quot;
|
||||
minutes = result.rem;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user