From 234b65c9d8dff5ba0f83323dec645e0f0d1e9add Mon Sep 17 00:00:00 2001 From: Kharec Date: Mon, 15 Dec 2025 20:59:15 +0100 Subject: [PATCH] refactor: consolidate time formatting --- auditui/library.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/auditui/library.py b/auditui/library.py index 42ba34c..ac8f996 100644 --- a/auditui/library.py +++ b/auditui/library.py @@ -227,3 +227,15 @@ class LibraryClient: parts.append(f"{minutes} minute{'s' if minutes != 1 else ''}") return " ".join(parts) if parts else default_none + + @staticmethod + def format_time(seconds: float) -> str: + """Format seconds as HH:MM:SS or MM:SS.""" + total_seconds = int(seconds) + hours = total_seconds // 3600 + minutes = (total_seconds % 3600) // 60 + secs = total_seconds % 60 + + if hours > 0: + return f"{hours:02d}:{minutes:02d}:{secs:02d}" + return f"{minutes:02d}:{secs:02d}"