]> git.earman.xyz Git - sensor-watch.git/commitdiff
actually, set the time after loading settings (need to convert to UTC)
authorJoey Castillo <joeycastillo@utexas.edu>
Sat, 15 Mar 2025 22:30:37 +0000 (18:30 -0400)
committerJoey Castillo <joeycastillo@utexas.edu>
Sat, 15 Mar 2025 22:30:37 +0000 (18:30 -0400)
movement.c

index ec6471b20712187294078840a1b80b41a0ce2db2..21250ddf0ead3b9afa96c871b9a5f5b3c596cddd 100644 (file)
@@ -572,15 +572,6 @@ void app_init(void) {
 
     filesystem_init();
 
-    watch_date_time_t date_time = watch_rtc_get_date_time();
-    if (date_time.reg == 0) {
-        // at first boot, set year to 2025
-        date_time.unit.year = 2025 - WATCH_RTC_REFERENCE_YEAR;
-        date_time.unit.month = 1;
-        date_time.unit.day = 1;
-        watch_rtc_set_date_time(date_time);
-    }
-
     // check if we are plugged into USB power.
     HAL_GPIO_VBUS_DET_in();
     HAL_GPIO_VBUS_DET_pulldown();
@@ -639,6 +630,22 @@ void app_init(void) {
 
         movement_store_settings();
     }
+
+    // populate the DST offset cache
+    _movement_update_dst_offset_cache();
+
+    watch_date_time_t date_time = watch_rtc_get_date_time();
+    if (date_time.reg == 0) {
+        // at first boot, set year to 2025
+        date_time.unit.year = 2025 - WATCH_RTC_REFERENCE_YEAR;
+        date_time.unit.month = 1;
+        date_time.unit.day = 1;
+        // but convert from local time to UTC
+        date_time = watch_utility_date_time_convert_zone(date_time, movement_get_current_timezone_offset(), 0);
+        watch_rtc_set_date_time(date_time);
+    }
+
+
     movement_state.light_ticks = -1;
     movement_state.alarm_ticks = -1;
     movement_state.next_available_backup_register = 2;
@@ -664,9 +671,6 @@ void app_setup(void) {
             is_first_launch = false;
         }
 
-        // populate the DST offset cache
-        _movement_update_dst_offset_cache();
-
 #if __EMSCRIPTEN__
         int32_t time_zone_offset = EM_ASM_INT({
             return -new Date().getTimezoneOffset();