瀏覽代碼

Set time zone even when NTP is disabled

setTimeZone() was only called inside the useNtp branch, so with an empty
TimeServer setting the configured TimeZone was never applied and all
local times were shown in UTC.
Argetlam 1 月之前
父節點
當前提交
4a43d0ac16
共有 1 個文件被更改,包括 2 次插入 和 2 次删除
  1. 2 2
      code/components/jomjol_time_sntp/time_sntp.cpp

+ 2 - 2
code/components/jomjol_time_sntp/time_sntp.cpp

@@ -278,10 +278,10 @@ bool setupTime() {
         esp_sntp_config_t config = ESP_NETIF_SNTP_DEFAULT_CONFIG(timeServer.c_str());
         esp_sntp_config_t config = ESP_NETIF_SNTP_DEFAULT_CONFIG(timeServer.c_str());
         config.sync_cb = time_sync_notification_cb;
         config.sync_cb = time_sync_notification_cb;
         esp_netif_sntp_init(&config);
         esp_netif_sntp_init(&config);
-
-        setTimeZone(timeZone);
     }
     }
 
 
+    setTimeZone(timeZone);
+
     /* The RTC keeps the time after a restart (Except on Power On or Pin Reset) 
     /* The RTC keeps the time after a restart (Except on Power On or Pin Reset) 
      * There should only be a minor correction through NTP */
      * There should only be a minor correction through NTP */