1
0
mirror of https://github.com/esphome/esphome.git synced 2026-02-08 00:31:58 +00:00

must set TZ

This commit is contained in:
J. Nick Koston
2026-01-29 23:41:41 -06:00
parent 77ebfc8687
commit 284a9cdab6

View File

@@ -103,7 +103,12 @@ void RealTimeClock::apply_timezone_(const char *tz) {
return;
}
// Parse the POSIX TZ string using our custom parser
// Set TZ env var for components using libc's localtime() directly
// (e.g., sun, datetime, wireguard, deep_sleep)
setenv("TZ", tz, 1);
tzset();
// Parse the POSIX TZ string using our custom parser for RealTimeClock::now()
if (!parse_posix_tz(tz, this->parsed_tz_)) {
ESP_LOGW(TAG, "Failed to parse timezone: %s", tz);
// Reset to UTC on parse failure