From b2120609b94f3b502313d0bb4827be3247aab1b7 Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Thu, 29 Jan 2026 23:54:14 -0600 Subject: [PATCH] bot review --- esphome/core/time.cpp | 9 ++------- esphome/core/time.h | 7 ++----- 2 files changed, 4 insertions(+), 12 deletions(-) diff --git a/esphome/core/time.cpp b/esphome/core/time.cpp index 053cf55772..f229340083 100644 --- a/esphome/core/time.cpp +++ b/esphome/core/time.cpp @@ -281,13 +281,8 @@ int32_t ESPTime::timezone_offset() { } return -tz.std_offset_seconds; #else - time_t now = ::time(nullptr); - struct tm local_tm = *::localtime(&now); - local_tm.tm_isdst = 0; // Cause mktime to ignore daylight saving time because we want to include it in the offset. - time_t local_time = mktime(&local_tm); - struct tm utc_tm = *::gmtime(&now); - time_t utc_time = mktime(&utc_tm); - return static_cast(local_time - utc_time); + // No timezone support - no offset + return 0; #endif } diff --git a/esphome/core/time.h b/esphome/core/time.h index 718477563a..3df4d02cad 100644 --- a/esphome/core/time.h +++ b/esphome/core/time.h @@ -117,11 +117,8 @@ struct ESPTime { // Fallback to UTC if conversion failed return ESPTime::from_epoch_utc(epoch); #else - struct tm *c_tm = ::localtime(&epoch); - if (c_tm == nullptr) { - return ESPTime{}; // Return an invalid ESPTime - } - return ESPTime::from_c_tm(c_tm, epoch); + // No timezone support - return UTC (no TZ configured, localtime would return UTC anyway) + return ESPTime::from_epoch_utc(epoch); #endif } /** Convert an UTC epoch timestamp to a UTC time ESPTime instance.