MCPcopy Index your code
hub / github.com/Codeplain-ai/codeplain / format_duration_hms

Function format_duration_hms

plain2code_utils.py:19–31  ·  view source on GitHub ↗

Format a duration in seconds as hours, minutes, and seconds (e.g. ``1h 2m 3.45s``, ``45.67s``).

(total_seconds: int)

Source from the content-addressed store, hash-verified

17
18
19def format_duration_hms(total_seconds: int) -> str:
20 """Format a duration in seconds as hours, minutes, and seconds (e.g. ``1h 2m 3.45s``, ``45.67s``)."""
21 if total_seconds < 0:
22 total_seconds = 0
23 h = int(total_seconds // 3600)
24 m = int((total_seconds % 3600) // 60)
25 s = total_seconds % 60
26 if h:
27 return f"{h}h {m}m {s}s"
28 if m:
29 return f"{m}m {s}s"
30 text = f"{s}".rstrip("0").rstrip(".")
31 return f"{text}s" if text else "0s"
32
33
34AMBIGUITY_CAUSES = {

Callers 1

print_exit_summaryFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected