From c65dfc62a44d2ae8c8f630eb0ef781da98ea517f Mon Sep 17 00:00:00 2001 From: mitsuha_s Date: Sun, 10 Jul 2022 17:29:31 +0000 Subject: [PATCH] use datetime.datetime instead of time.struct_time --- rss.py | 5 +++-- telegram.py | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/rss.py b/rss.py index fa39cce..d591843 100644 --- a/rss.py +++ b/rss.py @@ -1,5 +1,6 @@ from logging import Logger -from time import strftime +from datetime import datetime +from time import mktime from feedparser import FeedParserDict, parse @@ -9,7 +10,7 @@ class FeedItem: self.title = item.get('title', '') self.description = item.get('summary', '') if 'published' in item: - self.date = strftime("%d.%m.%Y %H:%M", item.published_parsed) + self.date = datetime.fromtimestamp(mktime(item.published_parsed)) else: self.date = None diff --git a/telegram.py b/telegram.py index bab8e58..27e44dd 100644 --- a/telegram.py +++ b/telegram.py @@ -164,7 +164,7 @@ class Notifier: def __format_message(self, item: FeedItem) -> str: return ( f"{item.title}\n" - f"{item.date}\n\n" + f"{item.date.strftime('%m.%d.%Y %H:%M')}\n\n" f"{self.__sanitize_html(item.description)}" )