use datetime.datetime instead of time.struct_time

This commit is contained in:
mitsuha_s 2022-07-10 17:29:31 +00:00
parent 7939babbe0
commit c65dfc62a4
2 changed files with 4 additions and 3 deletions

5
rss.py
View file

@ -1,5 +1,6 @@
from logging import Logger from logging import Logger
from time import strftime from datetime import datetime
from time import mktime
from feedparser import FeedParserDict, parse from feedparser import FeedParserDict, parse
@ -9,7 +10,7 @@ class FeedItem:
self.title = item.get('title', '') self.title = item.get('title', '')
self.description = item.get('summary', '') self.description = item.get('summary', '')
if 'published' in item: if 'published' in item:
self.date = strftime("%d.%m.%Y %H:%M", item.published_parsed) self.date = datetime.fromtimestamp(mktime(item.published_parsed))
else: else:
self.date = None self.date = None

View file

@ -164,7 +164,7 @@ class Notifier:
def __format_message(self, item: FeedItem) -> str: def __format_message(self, item: FeedItem) -> str:
return ( return (
f"<strong><a href=\"{item.url}\">{item.title}</a></strong>\n" f"<strong><a href=\"{item.url}\">{item.title}</a></strong>\n"
f"{item.date}\n\n" f"{item.date.strftime('%m.%d.%Y %H:%M')}\n\n"
f"{self.__sanitize_html(item.description)}" f"{self.__sanitize_html(item.description)}"
) )