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:
@@ -134,7 +134,8 @@ static void _planetary_solar_phases(movement_settings_t *settings, planetary_hou
|
||||
state->no_location = false;
|
||||
|
||||
watch_date_time date_time = watch_rtc_get_date_time(); // the current local date / time
|
||||
watch_date_time utc_now = watch_utility_date_time_convert_zone(date_time, movement_timezone_offsets[settings->bit.time_zone] * 60, 0); // the current date / time in UTC
|
||||
int16_t tz = get_timezone_offset(settings->bit.time_zone, date_time);
|
||||
watch_date_time utc_now = watch_utility_date_time_convert_zone(date_time, tz * 60, 0); // the current date / time in UTC
|
||||
watch_date_time scratch_time; // scratchpad, contains different values at different times
|
||||
watch_date_time midnight;
|
||||
scratch_time.reg = midnight.reg = utc_now.reg;
|
||||
@@ -147,7 +148,7 @@ static void _planetary_solar_phases(movement_settings_t *settings, planetary_hou
|
||||
double lon = (double)lon_centi / 100.0;
|
||||
|
||||
// save UTC offset
|
||||
state->utc_offset = ((double)movement_timezone_offsets[settings->bit.time_zone]) / 60.0;
|
||||
state->utc_offset = ((double)tz) / 60.0;
|
||||
|
||||
// calculate sunrise and sunset of current day in decimal hours after midnight
|
||||
sun_rise_set(scratch_time.unit.year + WATCH_RTC_REFERENCE_YEAR, scratch_time.unit.month, scratch_time.unit.day, lon, lat, &sunrise, &sunset);
|
||||
@@ -238,7 +239,7 @@ static void _planetary_hours(movement_settings_t *settings, planetary_hours_stat
|
||||
|
||||
// get current time
|
||||
watch_date_time date_time = watch_rtc_get_date_time(); // the current local date / time
|
||||
watch_date_time utc_now = watch_utility_date_time_convert_zone(date_time, movement_timezone_offsets[settings->bit.time_zone] * 60, 0); // the current date / time in UTC
|
||||
watch_date_time utc_now = watch_utility_date_time_convert_zone(date_time, get_timezone_offset(settings->bit.time_zone, date_time) * 60, 0); // the current date / time in UTC
|
||||
current_hour_epoch = watch_utility_date_time_to_unix_time(utc_now, 0);
|
||||
|
||||
// set the current planetary hour as default screen
|
||||
|
||||
Reference in New Issue
Block a user