[time] Skip POSIX TZ validation for empty timezone strings

Empty timezone strings are valid (meaning UTC/no timezone).
The parse_posix_tz_python() validation should only run on
non-empty strings.
This commit is contained in:
J. Nick Koston
2026-02-23 15:00:17 -06:00
parent 49ddaa2002
commit ba11722e77

View File

@@ -280,11 +280,12 @@ def validate_tz(value: str) -> str:
if tzfile is not None:
value = _extract_tz_string(tzfile)
# Validate that the POSIX TZ string is parseable
try:
parse_posix_tz_python(value)
except ValueError as e:
raise cv.Invalid(f"Invalid POSIX timezone string '{value}': {e}") from e
# Validate that the POSIX TZ string is parseable (skip empty strings)
if value:
try:
parse_posix_tz_python(value)
except ValueError as e:
raise cv.Invalid(f"Invalid POSIX timezone string '{value}': {e}") from e
return value