main
Bob Mottram 2025-12-20 16:45:44 +00:00
parent 673122e90d
commit 629ea59c28
2 changed files with 4 additions and 12 deletions

View File

@ -12,7 +12,6 @@ import json
import requests
import random
import time
import datetime
from socket import error as SocketError
import errno
from datetime import timedelta
@ -320,7 +319,6 @@ def parse_feed_date(pub_date: str, unique_string_identifier: str) -> str:
"%Y-%m-%dT%H:%M:%S%Z",
"%a, %d %b %Y %H:%M:%S")
published_date = None
errmsg = ''
timezone_endings = (
',', 'Z', 'GMT', 'EST', 'PST', 'AST', 'CST', 'MST', 'AKST', 'HST',
'UT'
@ -353,18 +351,11 @@ def parse_feed_date(pub_date: str, unique_string_identifier: str) -> str:
try:
published_date = \
datetime.datetime.strptime(pub_date2, date_format)
# published_date = \
# date_from_string_format(pub_date2, [date_format])
except BaseException as exc:
errmsg = ' | ' + date_format + ' ' + \
str(exc).replace('\n', ' ').replace('\r', ' ')
date_from_string_format(pub_date2, [date_format])
except BaseException:
continue
if published_date is not None:
if not published_date.tzinfo:
published_date = \
published_date.replace(tzinfo=timezone.utc)
if pub_date.endswith(' EST'):
hours_added = timedelta(hours=5)
published_date = published_date + hours_added
@ -381,7 +372,7 @@ def parse_feed_date(pub_date: str, unique_string_identifier: str) -> str:
if not pub_date_str.endswith('+00:00'):
pub_date_str += '+00:00'
else:
print('WARN: unrecognized date format: ' + pub_date + errmsg)
print('WARN: unrecognized date format: ' + pub_date)
return pub_date_str

View File

@ -72,6 +72,7 @@ def date_from_string_format(date_str: str, formats: []):
"%a, %d %b %Y %H:%M:%S %z",
"%Y-%m-%dT%H:%M:%S%z")
dtime = None
date_str = date_str.strip()
for date_format in formats:
try:
dtime = \