diff --git a/esphome/components/time/posix_tz.cpp b/esphome/components/time/posix_tz.cpp index 06140599a9..fb98edc577 100644 --- a/esphome/components/time/posix_tz.cpp +++ b/esphome/components/time/posix_tz.cpp @@ -364,10 +364,9 @@ bool parse_posix_tz(const char *tz_string, ParsedTimezone &result) { const char *p = tz_string; - // Initialize result + // Initialize result (dst_start/dst_end default to type=NONE, so has_dst() returns false) result.std_offset_seconds = 0; result.dst_offset_seconds = 0; - result.has_dst = false; result.dst_start = {}; result.dst_end = {}; @@ -429,9 +428,7 @@ bool parse_posix_tz(const char *tz_string, ParsedTimezone &result) { return false; } - // Only set has_dst after successfully parsing both rules - result.has_dst = true; - + // has_dst() now returns true since dst_start.type was set by parse_dst_rule return true; } diff --git a/esphome/components/time/real_time_clock.cpp b/esphome/components/time/real_time_clock.cpp index f518b35951..439436420f 100644 --- a/esphome/components/time/real_time_clock.cpp +++ b/esphome/components/time/real_time_clock.cpp @@ -29,7 +29,7 @@ void RealTimeClock::dump_config() { // POSIX offset is positive west, negate for conventional UTC+X display int std_h = -tz.std_offset_seconds / 3600; int std_m = (std::abs(tz.std_offset_seconds) % 3600) / 60; - if (tz.has_dst) { + if (tz.has_dst()) { int dst_h = -tz.dst_offset_seconds / 3600; int dst_m = (std::abs(tz.dst_offset_seconds) % 3600) / 60; ESP_LOGCONFIG(TAG, "Timezone: UTC%+d:%02d (DST UTC%+d:%02d)", std_h, std_m, dst_h, dst_m);