mirror of
https://github.com/esphome/esphome.git
synced 2026-06-02 11:08:06 +08: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) {
|
if (tz.has_dst) {
|
||||||
int dst_hours = -tz.dst_offset_seconds / 3600;
|
int dst_hours = -tz.dst_offset_seconds / 3600;
|
||||||
int dst_mins = std::abs(tz.dst_offset_seconds % 3600) / 60;
|
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_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_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
|
// 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,
|
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,
|
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);
|
this->apply_timezone_(nullptr);
|
||||||
return;
|
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];
|
char buf[128];
|
||||||
if (len >= sizeof(buf))
|
if (len >= sizeof(buf))
|
||||||
len = sizeof(buf) - 1;
|
len = sizeof(buf) - 1;
|
||||||
|
|||||||
@@ -86,12 +86,6 @@ static bool expect_char(const char *&p, const char *end, char expected) {
|
|||||||
return true;
|
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) {
|
bool ESPTime::strptime(const char *time_to_parse, size_t len, ESPTime &esp_time) {
|
||||||
// Supported formats:
|
// Supported formats:
|
||||||
// YYYY-MM-DD HH:MM:SS (19 chars)
|
// 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;
|
return false;
|
||||||
|
|
||||||
esp_time.second = v6;
|
esp_time.second = v6;
|
||||||
skip_trailing_whitespace(p, end);
|
|
||||||
return p == end; // YYYY-MM-DD HH:MM:SS
|
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;
|
return false;
|
||||||
|
|
||||||
esp_time.second = v3;
|
esp_time.second = v3;
|
||||||
skip_trailing_whitespace(p, end);
|
|
||||||
return p == end; // HH:MM:SS
|
return p == end; // HH:MM:SS
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user