MCPcopy
hub / github.com/agent0ai/agent-zero / format_remaining_time

Function format_remaining_time

helpers/wait.py:7–39  ·  view source on GitHub ↗
(total_seconds: float)

Source from the content-addressed store, hash-verified

5
6
7def format_remaining_time(total_seconds: float) -> str:
8 if total_seconds < 0:
9 total_seconds = 0
10
11 days, remainder = divmod(total_seconds, 86400)
12 hours, remainder = divmod(remainder, 3600)
13 minutes, seconds = divmod(remainder, 60)
14
15 days = int(days)
16 hours = int(hours)
17 minutes = int(minutes)
18
19 parts = []
20 if days > 0:
21 parts.append(f"{days}d")
22 if hours > 0:
23 parts.append(f"{hours}h")
24 if minutes > 0:
25 parts.append(f"{minutes}m")
26
27 if days > 0 or hours > 0:
28 if seconds >= 1:
29 parts.append(f"{int(seconds)}s")
30 elif minutes > 0:
31 if seconds >= 0.1:
32 parts.append(f"{seconds:.1f}s")
33 else:
34 parts.append(f"{total_seconds:.1f}s")
35
36 if not parts:
37 return "0.0s remaining"
38
39 return " ".join(parts) + " remaining"
40
41
42async def managed_wait(agent, target_time, is_duration_wait, log, get_heading_callback):

Callers 1

managed_waitFunction · 0.85

Calls 1

joinMethod · 0.45

Tested by

no test coverage detected