feat: Replace timezone offset with timezone selector
This commit is contained in:
parent
7266a51a92
commit
c62563c3c2
5 changed files with 739 additions and 6 deletions
|
@ -259,7 +259,7 @@ void setupWifi()
|
|||
|
||||
void syncTime()
|
||||
{
|
||||
configTime(preferences.getInt("gmtOffset", DEFAULT_TIME_OFFSET_SECONDS), 0,
|
||||
configTime(0, 0,
|
||||
NTP_SERVER);
|
||||
struct tm timeinfo;
|
||||
|
||||
|
@ -267,15 +267,24 @@ void syncTime()
|
|||
{
|
||||
auto& ledHandler = getLedHandler();
|
||||
ledHandler.queueEffect(LED_EFFECT_CONFIGURING);
|
||||
configTime(preferences.getInt("gmtOffset", DEFAULT_TIME_OFFSET_SECONDS), 0,
|
||||
configTime(0, 0,
|
||||
NTP_SERVER);
|
||||
delay(500);
|
||||
Serial.println(F("Retry set time"));
|
||||
}
|
||||
|
||||
setTimezone(get_timezone_value_string(timezone_data::find_timezone_value(preferences.getString("tzString", DEFAULT_TZ_STRING))));
|
||||
|
||||
lastTimeSync = esp_timer_get_time() / 1000000;
|
||||
}
|
||||
|
||||
void setTimezone(String timezone) {
|
||||
Serial.printf(" Setting Timezone to %s\n",timezone.c_str());
|
||||
setenv("TZ",timezone.c_str(),1); // Now adjust the TZ. Clock settings are adjusted to show the new local time
|
||||
tzset();
|
||||
}
|
||||
|
||||
|
||||
void setupPreferences()
|
||||
{
|
||||
preferences.begin("btclock", false);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue