1
0
mirror of https://github.com/esphome/esphome.git synced 2026-02-08 00:31:58 +00:00

bot review

This commit is contained in:
J. Nick Koston
2026-01-29 23:54:14 -06:00
parent 9e6e8a7ecb
commit b2120609b9
2 changed files with 4 additions and 12 deletions

View File

@@ -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<int32_t>(local_time - utc_time);
// No timezone support - no offset
return 0;
#endif
}

View File

@@ -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.