From 735b60f32b1e3371d147f3f4df77a2a5b54256ad Mon Sep 17 00:00:00 2001 From: Wolfgang Müller Date: Mon, 3 May 2021 17:08:20 +0200 Subject: formatter: Use custom time format when printing message timestamps Up until now we were relying on isoformat() to format timestamps when printing messages, since that was a simple shortcut to a well-known format. With the addition of timezone support, however, isoformat() started adding the timezone offset to the timestamp. This makes timestamps unnecessarily verbose. This commit has the formatter use a custom ISO 8601-esque time format instead which restores the behaviour previous to the introduction of timezones. --- quarg/quassel/formatter.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/quarg/quassel/formatter.py b/quarg/quassel/formatter.py index 603e113..7e7bce6 100644 --- a/quarg/quassel/formatter.py +++ b/quarg/quassel/formatter.py @@ -34,10 +34,11 @@ def format_from(backlog_row): message = Message.from_backlog(backlog_row) formatter = FORMATTERS[message.type] - # make sure to convert timestamps to local time before printing - timestamp = message.time.astimezone().isoformat(sep=' ', timespec='seconds') + return f'{format_timestamp(message.time)}\t{message.buffer}\t{formatter(message)}' - return f'{timestamp}\t{message.buffer}\t{formatter(message)}' +def format_timestamp(time): + # make sure to convert timestamps to local time + return time.astimezone().strftime('%Y-%m-%d %H:%M:%S') def format_part(msg): if msg.message: -- cgit v1.2.3-2-gb3c3