mirror of
https://github.com/esphome/esphome.git
synced 2026-02-08 00:31:58 +00:00
bot review
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
|
||||
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user