From 3d0a70c3e4d0e2e95816968abb975eb4881fd7c5 Mon Sep 17 00:00:00 2001 From: Knut Ahlers <knut@ahlers.me> Date: Thu, 20 Feb 2025 19:01:04 +0100 Subject: [PATCH] Fix: Allow for `-0` Offset Signed-off-by: Knut Ahlers <knut@ahlers.me> --- bin/tmux-timediff | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/bin/tmux-timediff b/bin/tmux-timediff index bd4933d..c73c32e 100755 --- a/bin/tmux-timediff +++ b/bin/tmux-timediff @@ -25,6 +25,7 @@ KEY_OFFSET = 'Offset' KEY_PARSED_OFFSET = 'Parsed Offset' mult = { + '': 1.0, 's': 1.0, 'ms': 1.0 / 1000.0, 'us': 1.0 / 1000000.0, @@ -40,8 +41,9 @@ def get_stats(): desc, cont = line_parts stats[desc.strip()] = cont.strip() - groups = re.search(r'^([+-])([0-9.]+)([a-z]+)$', - stats[KEY_OFFSET]).groups() + search = re.search(r'^([+-])([0-9.]+)([a-z]*)$', + stats[KEY_OFFSET]) + groups = search.groups() offset = float(groups[1]) offset = offset * mult[groups[2]]