diff --git a/movement/watch_faces/clock/day_night_percentage_face.c b/movement/watch_faces/clock/day_night_percentage_face.c index 86f07f9d..dd822ffd 100644 --- a/movement/watch_faces/clock/day_night_percentage_face.c +++ b/movement/watch_faces/clock/day_night_percentage_face.c @@ -62,7 +62,7 @@ void day_night_percentage_face_setup(movement_settings_t *settings, uint8_t watc if (*context_ptr == NULL) { *context_ptr = malloc(sizeof(day_night_percentage_state_t)); day_night_percentage_state_t *state = (day_night_percentage_state_t *)*context_ptr; - watch_date_time utc_now = watch_utility_date_time_convert_zone(watch_rtc_get_date_time(), movement_timezone_offsets[settings->bit.time_zone] * 60, 0); + watch_date_time utc_now = watch_utility_date_time_convert_zone(watch_rtc_get_date_time(), movement_get_current_timezone_offset(), 0); recalculate(utc_now, state); } } @@ -77,7 +77,7 @@ bool day_night_percentage_face_loop(movement_event_t event, movement_settings_t char buf[12]; watch_date_time date_time = watch_rtc_get_date_time(); - watch_date_time utc_now = watch_utility_date_time_convert_zone(date_time, movement_timezone_offsets[settings->bit.time_zone] * 60, 0); + watch_date_time utc_now = watch_utility_date_time_convert_zone(date_time, movement_get_current_timezone_offset(), 0); switch (event.event_type) { case EVENT_ACTIVATE: diff --git a/movement/watch_faces/clock/mars_time_face.c b/movement/watch_faces/clock/mars_time_face.c index 30f6a34b..fba6e56b 100644 --- a/movement/watch_faces/clock/mars_time_face.c +++ b/movement/watch_faces/clock/mars_time_face.c @@ -70,7 +70,7 @@ static void _h_to_hms(mars_clock_hms_t *date_time, double h) { static void _update(movement_settings_t *settings, mars_time_state_t *state) { char buf[11]; watch_date_time date_time = watch_rtc_get_date_time(); - uint32_t now = watch_utility_date_time_to_unix_time(date_time, movement_timezone_offsets[settings->bit.time_zone] * 60); + uint32_t now = watch_utility_date_time_to_unix_time(date_time, movement_get_current_timezone_offset()); // TODO: I'm skipping over some steps here. // https://www.giss.nasa.gov/tools/mars24/help/algorithm.html double jdut = 2440587.5 + ((double)now / 86400.0); diff --git a/movement/watch_faces/clock/world_clock2_face.c b/movement/watch_faces/clock/world_clock2_face.c index 7fa86d28..ead219af 100644 --- a/movement/watch_faces/clock/world_clock2_face.c +++ b/movement/watch_faces/clock/world_clock2_face.c @@ -183,7 +183,7 @@ 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); + timestamp = watch_utility_date_time_to_unix_time(date_time, movement_get_current_timezone_offset()); date_time = watch_utility_date_time_from_unix_time(timestamp, movement_timezone_offsets[state->current_zone] * 60); previous_date_time = state->previous_date_time; state->previous_date_time = date_time.reg; diff --git a/movement/watch_faces/complication/astronomy_face.c b/movement/watch_faces/complication/astronomy_face.c index 204a0a3a..dece5247 100644 --- a/movement/watch_faces/complication/astronomy_face.c +++ b/movement/watch_faces/complication/astronomy_face.c @@ -80,7 +80,7 @@ static void _astronomy_face_recalculate(movement_settings_t *settings, astronomy #endif watch_date_time date_time = watch_rtc_get_date_time(); - uint32_t timestamp = watch_utility_date_time_to_unix_time(date_time, movement_timezone_offsets[settings->bit.time_zone] * 60); + uint32_t timestamp = watch_utility_date_time_to_unix_time(date_time, movement_get_current_timezone_offset()); date_time = watch_utility_date_time_from_unix_time(timestamp, 0); double jd = astro_convert_date_to_julian_date(date_time.unit.year + WATCH_RTC_REFERENCE_YEAR, date_time.unit.month, date_time.unit.day, date_time.unit.hour, date_time.unit.minute, date_time.unit.second); diff --git a/movement/watch_faces/complication/deadline_face.c b/movement/watch_faces/complication/deadline_face.c index 8e2f41ea..6af7be3a 100644 --- a/movement/watch_faces/complication/deadline_face.c +++ b/movement/watch_faces/complication/deadline_face.c @@ -159,7 +159,7 @@ static inline int _days_in_month(int16_t month, int16_t year) /* Return time zone offset */ static inline int32_t _get_tz_offset(movement_settings_t *settings) { - return movement_timezone_offsets[settings->bit.time_zone] * 60; + return movement_get_current_timezone_offset(); } /* Beep for a button press*/ diff --git a/movement/watch_faces/complication/menstrual_cycle_face.c b/movement/watch_faces/complication/menstrual_cycle_face.c index 37cc7303..57ca9824 100644 --- a/movement/watch_faces/complication/menstrual_cycle_face.c +++ b/movement/watch_faces/complication/menstrual_cycle_face.c @@ -301,7 +301,7 @@ void menstrual_cycle_face_activate(movement_settings_t *settings, void *context) state->period_today = 0; state->current_page = 0; state->reset_tracking = 0; - state->utc_offset = movement_timezone_offsets[settings->bit.time_zone] * 60; + state->utc_offset = movement_get_current_timezone_offset(); movement_request_tick_frequency(4); // we need to manually blink some pixels } diff --git a/movement/watch_faces/complication/moon_phase_face.c b/movement/watch_faces/complication/moon_phase_face.c index f74de647..6f60c017 100644 --- a/movement/watch_faces/complication/moon_phase_face.c +++ b/movement/watch_faces/complication/moon_phase_face.c @@ -59,8 +59,8 @@ static void _update(movement_settings_t *settings, moon_phase_state_t *state, ui (void)state; char buf[11]; watch_date_time date_time = watch_rtc_get_date_time(); - uint32_t now = watch_utility_date_time_to_unix_time(date_time, movement_timezone_offsets[settings->bit.time_zone] * 60) + offset; - date_time = watch_utility_date_time_from_unix_time(now, movement_timezone_offsets[settings->bit.time_zone] * 60); + uint32_t now = watch_utility_date_time_to_unix_time(date_time, movement_get_current_timezone_offset()) + offset; + date_time = watch_utility_date_time_from_unix_time(now, movement_get_current_timezone_offset()); double currentfrac = fmod(now - FIRST_MOON, LUNAR_SECONDS) / LUNAR_SECONDS; double currentday = currentfrac * LUNAR_DAYS; uint8_t phase_index = 0; diff --git a/movement/watch_faces/complication/orrery_face.c b/movement/watch_faces/complication/orrery_face.c index 42fdf81f..5847b16d 100644 --- a/movement/watch_faces/complication/orrery_face.c +++ b/movement/watch_faces/complication/orrery_face.c @@ -48,7 +48,7 @@ static const char orrery_celestial_body_names[NUM_AVAILABLE_BODIES][3] = { static void _orrery_face_recalculate(movement_settings_t *settings, orrery_state_t *state) { watch_date_time date_time = watch_rtc_get_date_time(); - uint32_t timestamp = watch_utility_date_time_to_unix_time(date_time, movement_timezone_offsets[settings->bit.time_zone] * 60); + uint32_t timestamp = watch_utility_date_time_to_unix_time(date_time, movement_get_current_timezone_offset()); date_time = watch_utility_date_time_from_unix_time(timestamp, 0); double jd = astro_convert_date_to_julian_date(date_time.unit.year + WATCH_RTC_REFERENCE_YEAR, date_time.unit.month, date_time.unit.day, date_time.unit.hour, date_time.unit.minute, date_time.unit.second); double et = astro_convert_jd_to_julian_millenia_since_j2000(jd); diff --git a/movement/watch_faces/complication/planetary_hours_face.c b/movement/watch_faces/complication/planetary_hours_face.c index 7c004491..466296a6 100644 --- a/movement/watch_faces/complication/planetary_hours_face.c +++ b/movement/watch_faces/complication/planetary_hours_face.c @@ -134,7 +134,7 @@ 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 + watch_date_time 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 scratch_time; // scratchpad, contains different values at different times watch_date_time midnight; scratch_time.reg = midnight.reg = utc_now.reg; @@ -147,7 +147,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)movement_get_current_timezone_offset()) / 3600.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); @@ -237,7 +237,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, movement_get_current_timezone_offset(), 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 diff --git a/movement/watch_faces/complication/planetary_time_face.c b/movement/watch_faces/complication/planetary_time_face.c index 227f68d4..1bad968e 100644 --- a/movement/watch_faces/complication/planetary_time_face.c +++ b/movement/watch_faces/complication/planetary_time_face.c @@ -129,7 +129,7 @@ static void _planetary_solar_phase(movement_settings_t *settings, planetary_time 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 + watch_date_time 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 scratch_time; // scratchpad, contains different values at different times watch_date_time midnight; scratch_time.reg = midnight.reg = utc_now.reg; @@ -142,7 +142,7 @@ static void _planetary_solar_phase(movement_settings_t *settings, planetary_time 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)movement_get_current_timezone_offset()) / 3600.0; // get UNIX epoch time now_epoch = watch_utility_date_time_to_unix_time(utc_now, 0); @@ -210,7 +210,7 @@ static void _planetary_time(movement_event_t event, movement_settings_t *setting watch_set_colon(); // get current time and convert to UTC - state->scratch = watch_utility_date_time_convert_zone(watch_rtc_get_date_time(), movement_timezone_offsets[settings->bit.time_zone] * 60, 0); + state->scratch = watch_utility_date_time_convert_zone(watch_rtc_get_date_time(), movement_get_current_timezone_offset(), 0); // when current phase ends calculate the next phase if ( watch_utility_date_time_to_unix_time(state->scratch, 0) >= state->phase_end ) { diff --git a/movement/watch_faces/complication/sailing_face.c b/movement/watch_faces/complication/sailing_face.c index a6c13fe8..8d39fc36 100644 --- a/movement/watch_faces/complication/sailing_face.c +++ b/movement/watch_faces/complication/sailing_face.c @@ -34,7 +34,7 @@ #define DEFAULT_MINUTES { 5,4,1,0,0,0 } static inline int32_t get_tz_offset(movement_settings_t *settings) { - return movement_timezone_offsets[settings->bit.time_zone] * 60; + return movement_get_current_timezone_offset(); } static int lap = 0; diff --git a/movement/watch_faces/complication/solstice_face.c b/movement/watch_faces/complication/solstice_face.c index c31223e9..66fe210e 100644 --- a/movement/watch_faces/complication/solstice_face.c +++ b/movement/watch_faces/complication/solstice_face.c @@ -125,7 +125,7 @@ static watch_date_time jde_to_date_time(double JDE) { static void calculate_datetimes(solstice_state_t *state, movement_settings_t *settings) { for (int i = 0; i < 4; i++) { // TODO: handle DST changes - state->datetimes[i] = jde_to_date_time(calculate_solstice_equinox(2020 + state->year, i) + (movement_timezone_offsets[settings->bit.time_zone] / (60.0*24.0))); + state->datetimes[i] = jde_to_date_time(calculate_solstice_equinox(2020 + state->year, i) + (movement_get_current_timezone_offset() / (3600.0*24.0))); } } diff --git a/movement/watch_faces/complication/sunrise_sunset_face.c b/movement/watch_faces/complication/sunrise_sunset_face.c index 7a0ba366..5fd77889 100644 --- a/movement/watch_faces/complication/sunrise_sunset_face.c +++ b/movement/watch_faces/complication/sunrise_sunset_face.c @@ -62,7 +62,7 @@ static void _sunrise_sunset_face_update(movement_settings_t *settings, sunrise_s } 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, movement_get_current_timezone_offset(), 0); // the current date / time in UTC watch_date_time scratch_time; // scratchpad, contains different values at different times scratch_time.reg = utc_now.reg; @@ -77,7 +77,7 @@ static void _sunrise_sunset_face_update(movement_settings_t *settings, sunrise_s // 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 struct. // to deal with this, we set aside the offset in hours, and add it back before converting it to a watch_date_time. - double hours_from_utc = ((double)movement_timezone_offsets[settings->bit.time_zone]) / 60.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++) { diff --git a/movement/watch_faces/complication/timer_face.c b/movement/watch_faces/complication/timer_face.c index aa7f2d99..50b93ec9 100644 --- a/movement/watch_faces/complication/timer_face.c +++ b/movement/watch_faces/complication/timer_face.c @@ -37,7 +37,7 @@ static const int8_t _sound_seq_start[] = {BUZZER_NOTE_C8, 2, 0}; static uint8_t _beeps_to_play; // temporary counter for ring signals playing static inline int32_t _get_tz_offset(movement_settings_t *settings) { - return movement_timezone_offsets[settings->bit.time_zone] * 60; + return movement_get_current_timezone_offset(); } static void _signal_callback() { diff --git a/movement/watch_faces/complication/tomato_face.c b/movement/watch_faces/complication/tomato_face.c index 3d46ba94..b4b7ae37 100644 --- a/movement/watch_faces/complication/tomato_face.c +++ b/movement/watch_faces/complication/tomato_face.c @@ -31,7 +31,7 @@ static uint8_t focus_min = 25; static uint8_t break_min = 5; static inline int32_t get_tz_offset(movement_settings_t *settings) { - return movement_timezone_offsets[settings->bit.time_zone] * 60; + return movement_get_current_timezone_offset(); } static uint8_t get_length(tomato_state_t *state) { diff --git a/movement/watch_faces/complication/totp_face.c b/movement/watch_faces/complication/totp_face.c index fdb41095..7fb45e56 100644 --- a/movement/watch_faces/complication/totp_face.c +++ b/movement/watch_faces/complication/totp_face.c @@ -158,7 +158,7 @@ static void totp_generate_and_display(totp_state_t *totp_state) { } static inline uint32_t totp_compute_base_timestamp(movement_settings_t *settings) { - return watch_utility_date_time_to_unix_time(watch_rtc_get_date_time(), movement_timezone_offsets[settings->bit.time_zone] * 60); + return watch_utility_date_time_to_unix_time(watch_rtc_get_date_time(), movement_get_current_timezone_offset()); } void totp_face_setup(movement_settings_t *settings, uint8_t watch_face_index, void ** context_ptr) { diff --git a/movement/watch_faces/complication/totp_face_lfs.c b/movement/watch_faces/complication/totp_face_lfs.c index 5d7defe8..8823cbc9 100644 --- a/movement/watch_faces/complication/totp_face_lfs.c +++ b/movement/watch_faces/complication/totp_face_lfs.c @@ -254,7 +254,7 @@ void totp_face_lfs_activate(movement_settings_t *settings, void *context) { } #endif - totp_state->timestamp = watch_utility_date_time_to_unix_time(watch_rtc_get_date_time(), movement_timezone_offsets[settings->bit.time_zone] * 60); + totp_state->timestamp = watch_utility_date_time_to_unix_time(watch_rtc_get_date_time(), movement_get_current_timezone_offset()); totp_face_set_record(totp_state, 0); } diff --git a/movement/watch_faces/sensor/accelerometer_data_acquisition_face.c b/movement/watch_faces/sensor/accelerometer_data_acquisition_face.c index 6d174d5a..5acb9f09 100644 --- a/movement/watch_faces/sensor/accelerometer_data_acquisition_face.c +++ b/movement/watch_faces/sensor/accelerometer_data_acquisition_face.c @@ -442,7 +442,7 @@ static void start_reading(accelerometer_data_acquisition_state_t *state, movemen accelerometer_data_acquisition_record_t record; watch_date_time date_time = watch_rtc_get_date_time(); - state->starting_timestamp = watch_utility_date_time_to_unix_time(date_time, movement_timezone_offsets[settings->bit.time_zone] * 60); + state->starting_timestamp = watch_utility_date_time_to_unix_time(date_time, movement_get_current_timezone_offset()); record.header.info.record_type = ACCELEROMETER_DATA_ACQUISITION_HEADER; record.header.info.range = ACCELEROMETER_RANGE; record.header.info.temperature = lis2dw_get_temperature(); diff --git a/movement/watch_faces/settings/set_time_hackwatch_face.c b/movement/watch_faces/settings/set_time_hackwatch_face.c index 9b96014f..0b6c76e3 100644 --- a/movement/watch_faces/settings/set_time_hackwatch_face.c +++ b/movement/watch_faces/settings/set_time_hackwatch_face.c @@ -231,8 +231,8 @@ bool set_time_hackwatch_face_loop(movement_event_t event, movement_settings_t *s sprintf(buf, "%s %3d%02d ", set_time_hackwatch_face_titles[current_page], - (int8_t)(movement_timezone_offsets[settings->bit.time_zone] / 60), - (int8_t)(movement_timezone_offsets[settings->bit.time_zone] % 60) * (movement_timezone_offsets[settings->bit.time_zone] < 0 ? -1 : 1)); + (int8_t)(movement_get_current_timezone_offset() / 3600), + (int8_t)(movement_get_current_timezone_offset() % 3600) * (movement_get_current_timezone_offset() < 0 ? -1 : 1)); } }