[time] Point to valid IANA timezone list on validation failure (#15110)

This commit is contained in:
J. Nick Koston
2026-03-23 08:22:25 -10:00
committed by Jesse Hills
parent 7ecdf6db2e
commit e261b5de65
+11 -1
View File
@@ -284,13 +284,23 @@ def validate_tz(value: str) -> str:
tzfile = _load_tzdata(value)
if tzfile is not None:
value = _extract_tz_string(tzfile)
is_iana = True
else:
is_iana = False
# 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
if is_iana:
raise cv.Invalid(f"Invalid POSIX timezone string '{value}': {e}") from e
raise cv.Invalid(
f"Invalid POSIX timezone string '{value}': {e}. "
f"If you meant to use an IANA timezone, check the list of valid "
f"timezones at "
f"https://en.wikipedia.org/wiki/List_of_tz_database_time_zones"
) from e
return value