Skip to content

Commit

Permalink
Simplify matching named timezones in HTTP header
Browse files Browse the repository at this point in the history
  • Loading branch information
wjt committed Nov 9, 2023
1 parent 0c93645 commit 46afd94
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/lib/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit 46afd94

Please sign in to comment.