fix: sunrise/set before DST change
The Sunrise and Sunset timezone offset needs to be calculated for the day it's relevant to, since it might experience a timezone change.
This commit is contained in:
@@ -93,13 +93,9 @@ static void _sunrise_sunset_face_update(sunrise_sunset_state_t *state) {
|
||||
double lat = (double)lat_centi / 100.0;
|
||||
double lon = (double)lon_centi / 100.0;
|
||||
|
||||
// sunriset returns the rise/set times as signed decimal hours in UTC.
|
||||
// this can mean hours below 0 or above 31, which won't fit into a watch_date_time_t struct.
|
||||
// to deal with this, we set aside the offset in hours, and add it back before converting it to a watch_date_time_t.
|
||||
double hours_from_utc = ((double)movement_get_current_timezone_offset()) / 3600.0;
|
||||
|
||||
// we loop twice because if it's after sunset today, we need to recalculate to display values for tomorrow.
|
||||
for(int i = 0; i < 2; i++) {
|
||||
double hours_from_utc = ((double)movement_get_timezone_offset_for_date(scratch_time)) / 3600.0;
|
||||
uint8_t result = sun_rise_set(scratch_time.unit.year + WATCH_RTC_REFERENCE_YEAR, scratch_time.unit.month, scratch_time.unit.day, lon, lat, &rise, &set);
|
||||
|
||||
if (result != 0) {
|
||||
|
||||
Reference in New Issue
Block a user