This is an automated email from the ASF dual-hosted git repository.

sbp pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tooling-trusted-releases.git


The following commit(s) were added to refs/heads/main by this push:
     new ab4e369  Improve the display of the remaining vote duration
ab4e369 is described below

commit ab4e36909083e9804a9364cd8b1884c2c5b7149f
Author: Sean B. Palmer <[email protected]>
AuthorDate: Mon Dec 29 14:14:59 2025 +0000

    Improve the display of the remaining vote duration
---
 atr/tabulate.py | 31 +++++++++++++++++++++++++++----
 1 file changed, 27 insertions(+), 4 deletions(-)

diff --git a/atr/tabulate.py b/atr/tabulate.py
index 352a0fd..895315a 100644
--- a/atr/tabulate.py
+++ b/atr/tabulate.py
@@ -203,6 +203,29 @@ def vote_summary(tabulated_votes: dict[str, 
models.tabulate.VoteEmail]) -> dict[
     return result
 
 
+def _format_duration(duration_hours: float | int) -> str:
+    hours = int(duration_hours)
+    minutes = round((duration_hours - hours) * 60)
+    if minutes == 60:
+        # Happens when the remainder is 59.5 / 60 or more
+        hours += 1
+        minutes = 0
+
+    parts: list[str] = []
+    if hours == 1:
+        parts.append("1 hour")
+    elif hours > 1:
+        parts.append(f"{hours} hours")
+    if minutes == 1:
+        parts.append("1 minute")
+    elif minutes > 1:
+        parts.append(f"{minutes} minutes")
+
+    if not parts:
+        return "less than 1 minute"
+    return " and ".join(parts)
+
+
 def _vote_break(line: str) -> bool:
     if line == "-- ":
         # Start of a signature
@@ -279,8 +302,8 @@ def _vote_outcome_format(
     outcome_passed = (binding_plus_one >= 3) and (binding_plus_one > 
binding_minus_one)
     if not outcome_passed:
         if (duration_hours_remaining is not None) and 
(duration_hours_remaining > 0):
-            rounded = round(duration_hours_remaining, 2)
-            msg = f"The vote is still open for {rounded} hours, but it would 
fail if closed now."
+            duration_str = _format_duration(duration_hours_remaining)
+            msg = f"The vote is still open for {duration_str}, but it would 
fail if closed now."
         elif duration_hours_remaining is None:
             msg = "The vote would fail if closed now."
         else:
@@ -288,8 +311,8 @@ def _vote_outcome_format(
         return False, msg
 
     if (duration_hours_remaining is not None) and (duration_hours_remaining > 
0):
-        rounded = round(duration_hours_remaining, 2)
-        msg = f"The vote is still open for {rounded} hours, but it would pass 
if closed now."
+        duration_str = _format_duration(duration_hours_remaining)
+        msg = f"The vote is still open for {duration_str}, but it would pass 
if closed now."
     else:
         msg = "The vote passed."
     return True, msg


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to