Skip to content

Commit 3ef52a6

Browse files
committed
Fix hours and minutes for float input
1 parent dd8a562 commit 3ef52a6

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

build_docs.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1155,7 +1155,7 @@ def build_docs(args) -> bool:
11551155
def format_seconds(seconds: float) -> str:
11561156
hours, remainder = divmod(seconds, 3600)
11571157
minutes, seconds = divmod(remainder, 60)
1158-
seconds = round(seconds)
1158+
hours, minutes, seconds = int(hours), int(minutes), round(seconds)
11591159

11601160
match (hours, minutes, seconds):
11611161
case 0, 0, s:

tests/test_build_docs.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,12 @@
1515
(185, "3m 5s"),
1616
(454, "7m 34s"),
1717
(7456, "2h 4m 16s"),
18+
(30.1, "30s"),
19+
(60.2, "1m 0s"),
20+
(185.3, "3m 5s"),
21+
(454.4, "7m 34s"),
22+
(7456.5, "2h 4m 16s"),
1823
],
1924
)
20-
def test_format_seconds(seconds: int, expected: str) -> None:
25+
def test_format_seconds(seconds: float, expected: str) -> None:
2126
assert format_seconds(seconds) == expected

0 commit comments

Comments
 (0)