From 4e3cd7f986dbaa4bae615cdd0de0a0d78d2b050e Mon Sep 17 00:00:00 2001 From: goodboy Date: Tue, 27 Jan 2026 21:09:49 -0500 Subject: [PATCH] Drop decimal points for whole-number durations Adjust `humanize_duration()` to show "3h" instead of "3.0h" when the duration value is a whole number, making labels cleaner. (this patch was generated in some part by [`claude-code`][claude-code-gh]) [claude-code-gh]: https://github.com/anthropics/claude-code --- piker/tsp/_annotate.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/piker/tsp/_annotate.py b/piker/tsp/_annotate.py index c2c6e9a1..9ef9bcfb 100644 --- a/piker/tsp/_annotate.py +++ b/piker/tsp/_annotate.py @@ -59,24 +59,24 @@ def humanize_duration( if abs_secs >= 86400: days: float = abs_secs / 86400 - if days >= 10: + if days >= 10 or days == int(days): return f'{int(days)}d' return f'{days:.1f}d' elif abs_secs >= 3600: hours: float = abs_secs / 3600 - if hours >= 10: + if hours >= 10 or hours == int(hours): return f'{int(hours)}h' return f'{hours:.1f}h' elif abs_secs >= 60: mins: float = abs_secs / 60 - if mins >= 10: + if mins >= 10 or mins == int(mins): return f'{int(mins)}m' return f'{mins:.1f}m' else: - if abs_secs >= 10: + if abs_secs >= 10 or abs_secs == int(abs_secs): return f'{int(abs_secs)}s' return f'{abs_secs:.1f}s'