mirror of
https://github.com/esphome/esphome.git
synced 2026-02-08 00:31:58 +00:00
remove crazy over definsive edge cases that the bot wants -- they never happen and just make things larger
This commit is contained in:
@@ -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,
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user