fix: Add error message for invalid tz
All checks were successful
Build Docker / BuildImage (push) Successful in 32s

This commit is contained in:
2025-03-06 15:24:11 +11:00
parent 6d7019bba5
commit f2c29f4073

View File

@@ -126,7 +126,10 @@ def get_full_timezone(tz):
minutes = int(match.group(2)) if match.group(2) else 0 minutes = int(match.group(2)) if match.group(2) else 0
return pytz.FixedOffset(hours * 60 + minutes) return pytz.FixedOffset(hours * 60 + minutes)
full_tz = SHORT_TZ_MAP.get(tz, tz) 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"]) @app.route("/api/v1/convert", methods=["POST"])
def convert(): def convert():