diff --git a/src/lib/utils.py b/src/lib/utils.py index 9f284a72..34201d98 100644 --- a/src/lib/utils.py +++ b/src/lib/utils.py @@ -64,10 +64,10 @@ def parse_date_header(date_str): In addition to standard(ish) formats, non-standard formats where the timezone is a named zone rather than an offset are detected and handled.""" - list_zones = list(zoneinfo.available_timezones()) - invalid_zones = [e for e in list_zones if e not in ("GMT", "UTC")] - if any((match_tz := tz) in date_str for tz in invalid_zones): - date_str_notz = date_str.replace(match_tz, "").strip() + for tz in zoneinfo.available_timezones(): + if tz in ("UTC", "GMT") or not date_str.endswith(tz): + continue + date_str_notz = date_str[-(len(tz) + 1):] for date_fmt in [ "%a, %d %b %Y %H:%M:%S", "%a, %d-%b-%Y %H:%M:%S",