Skip to content

Commit

Permalink
rss date handling update
Browse files Browse the repository at this point in the history
Signed-off-by: Clemens Vasters <[email protected]>
  • Loading branch information
clemensv committed Sep 16, 2024
1 parent fd77b05 commit d0525f9
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions rss/rssbridge/rssbridge.py
Original file line number Diff line number Diff line change
Expand Up @@ -285,8 +285,15 @@ def parse_source_detail(source):
)
return None

def parse_date(parsed_date):
return datetime(*parsed_date[:6]) if parsed_date else None
def parse_date(parsed_date_value) -> datetime|None:
if isinstance(parsed_date_value, time.struct_time):
st: time.struct_time = parsed_date_value
return datetime(st.tm_year, st.tm_mon, st.tm_mday, st.tm_hour, st.tm_min, st.tm_sec, tzinfo=timezone.utc)
if isinstance(parsed_date_value, datetime):
return parsed_date_value.astimezone(timezone.utc)
if isinstance(parsed_date_value,str):
return datetime.fromisoformat(parsed_date_value).astimezone(timezone.utc)
return None

return FeedItem(
author=parse_author_detail(entry.get('author_detail')),
Expand Down

0 comments on commit d0525f9

Please sign in to comment.