use datetime.datetime instead of time.struct_time
This commit is contained in:
parent
7939babbe0
commit
c65dfc62a4
5
rss.py
5
rss.py
|
@ -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
|
||||||
|
|
||||||
|
|
|
@ -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)}"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue