Skip to content

Commit

Permalink
Revert "sunrise_sunset_face has been updated"
Browse files Browse the repository at this point in the history
This reverts commit 4fc4b52.
  • Loading branch information
voloved committed Oct 26, 2024
1 parent c79fc94 commit 8546bde
Showing 1 changed file with 4 additions and 12 deletions.
16 changes: 4 additions & 12 deletions watch-faces/complication/sunrise_sunset_face.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,28 +49,21 @@ static void _sunrise_sunset_face_update(sunrise_sunset_state_t *state) {
double rise, set, minutes, seconds;
bool show_next_match = false;
movement_location_t movement_location;
int32_t tz;
if (state->longLatToUse == 0 || _location_count <= 1) {
if (state->longLatToUse == 0 || _location_count <= 1)
movement_location = (movement_location_t) watch_get_backup_data(1);
tz = movement_get_current_timezone_offset();
}
else{
movement_location.bit.latitude = longLatPresets[state->longLatToUse].latitude;
movement_location.bit.longitude = longLatPresets[state->longLatToUse].longitude;
tz = movement_get_current_timezone_offset_for_zone(longLatPresets[state->longLatToUse].timezone);
}

if (movement_location.reg == 0) {
watch_clear_colon();
watch_clear_indicator(WATCH_INDICATOR_PM);
watch_clear_indicator(WATCH_INDICATOR_24H);
watch_display_text_with_fallback(WATCH_POSITION_TOP, "Sunri", "rI");
watch_display_text_with_fallback(WATCH_POSITION_BOTTOM, "No LOC", "No Loc");
return;
}

watch_date_time_t utc_now = movement_get_utc_date_time();
watch_date_time_t date_time = watch_utility_date_time_convert_zone(utc_now, 0, tz);
watch_date_time_t date_time = movement_get_local_date_time(); // the current local date / time
watch_date_time_t utc_now = watch_utility_date_time_convert_zone(date_time, movement_get_current_timezone_offset(), 0); // the current date / time in UTC
watch_date_time_t scratch_time; // scratchpad, contains different values at different times
scratch_time.reg = utc_now.reg;

Expand All @@ -85,7 +78,7 @@ static void _sunrise_sunset_face_update(sunrise_sunset_state_t *state) {
// 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)tz) / 3600.0;
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++) {
Expand Down Expand Up @@ -330,7 +323,6 @@ void sunrise_sunset_face_activate(void *context) {
movement_location_t movement_location = (movement_location_t) watch_get_backup_data(1);
state->working_latitude = _sunrise_sunset_face_struct_from_latlon(movement_location.bit.latitude);
state->working_longitude = _sunrise_sunset_face_struct_from_latlon(movement_location.bit.longitude);
movement_update_dst_offset_cache();
}

bool sunrise_sunset_face_loop(movement_event_t event, void *context) {
Expand Down

0 comments on commit 8546bde

Please sign in to comment.