Skip to content

Commit a74eab8

Browse files
authored
Don't include '.0' on minutes and hours for durations when passed as large floats. (dbcli#1517)
1 parent 435cf7f commit a74eab8

File tree

4 files changed

+10
-2
lines changed

4 files changed

+10
-2
lines changed

AUTHORS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,7 @@ Contributors:
141141
* Josh Lynch (josh-lynch)
142142
* Fabio (3ximus)
143143
* Doug Harris (dougharris)
144+
* Jay Knight (jay-knight)
144145

145146
Creator:
146147
--------

changelog.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,11 @@ Internal:
1717
* Update dev requirements and replace requirements-dev.txt with pyproject.toml
1818
* Use ruff instead of black
1919

20+
Bug fixes:
21+
----------
22+
23+
* Improve display of larger durations when passed as floats
24+
2025
4.3.0 (2025-03-22)
2126
==================
2227

pgcli/main.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1926,12 +1926,12 @@ def duration_in_words(duration_in_seconds: float) -> str:
19261926
components = []
19271927
hours, remainder = divmod(duration_in_seconds, 3600)
19281928
if hours > 1:
1929-
components.append(f"{hours} hours")
1929+
components.append(f"{int(hours)} hours")
19301930
elif hours == 1:
19311931
components.append("1 hour")
19321932
minutes, seconds = divmod(remainder, 60)
19331933
if minutes > 1:
1934-
components.append(f"{minutes} minutes")
1934+
components.append(f"{int(minutes)} minutes")
19351935
elif minutes == 1:
19361936
components.append("1 minute")
19371937
if seconds >= 2:

tests/test_main.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -565,9 +565,11 @@ def test_application_name_db_uri(tmpdir):
565565
(60, "1 minute"),
566566
(61, "1 minute 1 second"),
567567
(123, "2 minutes 3 seconds"),
568+
(124.4, "2 minutes 4 seconds"),
568569
(3600, "1 hour"),
569570
(7235, "2 hours 35 seconds"),
570571
(9005, "2 hours 30 minutes 5 seconds"),
572+
(9006.7, "2 hours 30 minutes 6 seconds"),
571573
(86401, "24 hours 1 second"),
572574
],
573575
)

0 commit comments

Comments
 (0)