aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorWolfgang Müller2021-05-03 17:08:20 +0200
committerWolfgang Müller2021-05-03 17:08:20 +0200
commit735b60f32b1e3371d147f3f4df77a2a5b54256ad (patch)
tree7a697880096a44f29785ce9c9314671df55274d1
parent9aae366a37338cb32ed0d0a9ce5280e632b4bcf2 (diff)
downloadquarg-735b60f32b1e3371d147f3f4df77a2a5b54256ad.tar.gz
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.
-rw-r--r--quarg/quassel/formatter.py7
1 files 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: