fix: Add error message for invalid tz

This commit is contained in:
Nathan Woodburn 2025-03-06 15:24:11 +11:00
parent 6d7019bba5
commit f2c29f4073
Signed by: nathanwoodburn
GPG Key ID: 203B000478AD0EF1

View File

@ -126,7 +126,10 @@ def get_full_timezone(tz):
minutes = int(match.group(2)) if match.group(2) else 0
return pytz.FixedOffset(hours * 60 + minutes)
full_tz = SHORT_TZ_MAP.get(tz, tz)
return pytz.timezone(full_tz) if isinstance(full_tz, str) else None
try:
return pytz.timezone(full_tz) if isinstance(full_tz, str) else None
except pytz.UnknownTimeZoneError:
return None
@app.route("/api/v1/convert", methods=["POST"])
def convert():