From 9e4f7c141b6807220a0c808e857379550f54150f Mon Sep 17 00:00:00 2001 From: Niko Felger Date: Sun, 21 May 2023 22:29:32 +0200 Subject: [PATCH] Always return last-modified date as string --- gadi/gesetze_im_internet/download.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/gadi/gesetze_im_internet/download.py b/gadi/gesetze_im_internet/download.py index 5af06fc..2da4eb4 100644 --- a/gadi/gesetze_im_internet/download.py +++ b/gadi/gesetze_im_internet/download.py @@ -32,12 +32,13 @@ def fetch_toc(): def _parse_last_modified_date_str(response): last_modified_header = response.headers.get("Last-Modified") - if not last_modified_header: + if last_modified_header: + last_modified_date = parsedate_to_datetime(last_modified_header) + else: # If there's no last modified date, pretend the file is current. - return dt.datetime.now() + last_modified_date = dt.datetime.now() - last_modified_date = parsedate_to_datetime(last_modified_header).strftime("%Y%m%d") - return last_modified_date + return last_modified_date.strftime("%Y%m%d")