From 27d0d19bf2c9911138d50539285837345878b7b5 Mon Sep 17 00:00:00 2001 From: Eemeli Aro Date: Fri, 17 Jan 2025 14:32:15 +0200 Subject: [PATCH] Show duration in milliseconds if appropriate --- pontoon/sync/templatetags/helpers.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/pontoon/sync/templatetags/helpers.py b/pontoon/sync/templatetags/helpers.py index df54a4ab5..c9721be64 100644 --- a/pontoon/sync/templatetags/helpers.py +++ b/pontoon/sync/templatetags/helpers.py @@ -12,14 +12,14 @@ def format_sync_duration(start_time: datetime, end_time: datetime | None) -> str td = end_time - start_time minutes = td.days * 24 * 60 + td.seconds // 60 seconds = td.seconds % 60 - if minutes > 1: - min_str = f"{minutes} minutes, " - elif minutes == 1: - min_str = "1 minute, " + if minutes: + min_str = "1 minute" if minutes == 1 else f"{minutes} minutes" + sec_str = "1 second" if seconds == 1 else f"{seconds} seconds" + return f"{min_str}, {sec_str}" + elif seconds > 9: + return f"{seconds} seconds" else: - min_str = "" - sec_str = "1 second" if seconds == 1 else f"{seconds} seconds" - return min_str + sec_str + return f"{td.microseconds // 1000 + seconds * 1000} ms" @library.global_function