blob: fc682066172fc955e1e7fe97e55f4d9e1033ee90 (
plain)
1
2
3
4
5
6
7
8
9
|
from datetime import timedelta
def human_timedelta(delta: timedelta) -> str:
hours = delta.seconds // 3600
minutes = delta.seconds % (hours * 3600) // 60
return (
f"{delta.days} days, " if delta.days else ""
) + f"{hours:0>2}:{minutes:0>2}" # zero-pad to two digits
|