From 31751bcb6198ecc3a2bfc3d21a35be67581d6bac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maxime=20=E2=80=9Cpep=E2=80=9D=20Buquet?= Date: Wed, 11 Sep 2019 02:30:54 +0200 Subject: poezio/mam: Remove superfluous time format conversions and fix parameter type MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Maxime “pep” Buquet --- poezio/mam.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'poezio') diff --git a/poezio/mam.py b/poezio/mam.py index e297d555..c42e7a18 100644 --- a/poezio/mam.py +++ b/poezio/mam.py @@ -25,13 +25,20 @@ class MAMQueryException(Exception): pass class NoMAMSupportException(Exception): pass -def add_line(tab, text_buffer: TextBuffer, text: str, str_time: str, nick: str, top: bool): +def add_line( + tab, + text_buffer: TextBuffer, + text: str, + time: datetime, + nick: str, + top: bool, + ) -> None: """Adds a textual entry in the TextBuffer""" - time = datetime.strftime(str_time, '%Y-%m-%d %H:%M:%S') - time = datetime.strptime(time, '%Y-%m-%d %H:%M:%S') + # Convert to local timezone time = time.replace(tzinfo=timezone.utc).astimezone(tz=None) time = time.replace(tzinfo=None) + deterministic = config.get_by_tabname('deterministic_nick_colors', tab.jid.bare) if isinstance(tab, tabs.MucTab): nick = nick.split('/')[1] -- cgit v1.2.3