From e2b3186731380880fcc361a033f1f4b9c18ee1a7 Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Fri, 30 Jan 2026 00:23:09 -0600 Subject: [PATCH] remove crazy over definsive edge cases that the bot wants -- they never happen and just make things larger --- esphome/components/time/real_time_clock.cpp | 6 +++--- esphome/components/time/real_time_clock.h | 2 +- esphome/core/time.cpp | 8 -------- 3 files changed, 4 insertions(+), 12 deletions(-) diff --git a/esphome/components/time/real_time_clock.cpp b/esphome/components/time/real_time_clock.cpp index 0a5ff63481..f18afa7159 100644 --- a/esphome/components/time/real_time_clock.cpp +++ b/esphome/components/time/real_time_clock.cpp @@ -32,11 +32,11 @@ void RealTimeClock::dump_config() { if (tz.has_dst) { int dst_hours = -tz.dst_offset_seconds / 3600; int dst_mins = std::abs(tz.dst_offset_seconds % 3600) / 60; - // Transition times (when DST starts/ends) + // Transition times (when DST starts/ends) - tzdata always uses positive times (default 2:00 AM) int start_time_hours = tz.dst_start.time_seconds / 3600; - int start_time_mins = std::abs(tz.dst_start.time_seconds % 3600) / 60; + int start_time_mins = (tz.dst_start.time_seconds % 3600) / 60; int end_time_hours = tz.dst_end.time_seconds / 3600; - int end_time_mins = std::abs(tz.dst_end.time_seconds % 3600) / 60; + int end_time_mins = (tz.dst_end.time_seconds % 3600) / 60; // Always use M format - tzdata and aioesphomeapi only generate M format rules ESP_LOGCONFIG(TAG, " DST: UTC%+d:%02d, M%d.%d.%d/%d:%02d - M%d.%d.%d/%d:%02d", dst_hours, dst_mins, tz.dst_start.month, tz.dst_start.week, tz.dst_start.day_of_week, start_time_hours, start_time_mins, diff --git a/esphome/components/time/real_time_clock.h b/esphome/components/time/real_time_clock.h index c608351310..9312d075df 100644 --- a/esphome/components/time/real_time_clock.h +++ b/esphome/components/time/real_time_clock.h @@ -33,7 +33,7 @@ class RealTimeClock : public PollingComponent { this->apply_timezone_(nullptr); return; } - // Stack buffer - TZ strings are typically short but allow up to 128 + // Stack buffer - TZ strings from tzdata are typically short (< 50 chars) char buf[128]; if (len >= sizeof(buf)) len = sizeof(buf) - 1; diff --git a/esphome/core/time.cpp b/esphome/core/time.cpp index e59c33dc23..aa8dba4b6f 100644 --- a/esphome/core/time.cpp +++ b/esphome/core/time.cpp @@ -86,12 +86,6 @@ static bool expect_char(const char *&p, const char *end, char expected) { return true; } -// Helper to skip trailing whitespace (for backward compatibility with sscanf) -static void skip_trailing_whitespace(const char *&p, const char *end) { - while (p < end && (*p == ' ' || *p == '\t' || *p == '\n' || *p == '\r')) - p++; -} - bool ESPTime::strptime(const char *time_to_parse, size_t len, ESPTime &esp_time) { // Supported formats: // YYYY-MM-DD HH:MM:SS (19 chars) @@ -156,7 +150,6 @@ bool ESPTime::strptime(const char *time_to_parse, size_t len, ESPTime &esp_time) return false; esp_time.second = v6; - skip_trailing_whitespace(p, end); return p == end; // YYYY-MM-DD HH:MM:SS } @@ -184,7 +177,6 @@ bool ESPTime::strptime(const char *time_to_parse, size_t len, ESPTime &esp_time) return false; esp_time.second = v3; - skip_trailing_whitespace(p, end); return p == end; // HH:MM:SS }