This commit is contained in:
2026-02-12 00:05:42 -05:00
parent 7d86d37dea
commit 49edd5ba84
47 changed files with 4502 additions and 1 deletions

View File

@@ -0,0 +1,39 @@
"""Formatting utilities for display."""
from datetime import timedelta
def format_duration(seconds: int) -> str:
"""
Format duration in seconds to human-readable string.
Args:
seconds: Duration in seconds
Returns:
Formatted string like "5d 12h 30m" or "2h 15m" or "45m"
"""
td = timedelta(seconds=seconds)
days = td.days
hours = td.seconds // 3600
minutes = (td.seconds % 3600) // 60
if days > 0:
return f"{days}d {hours}h {minutes}m"
elif hours > 0:
return f"{hours}h {minutes}m"
else:
return f"{minutes}m"
def format_number(num: int) -> str:
"""
Format large numbers with thousand separators.
Args:
num: Number to format
Returns:
Formatted string with commas (e.g., "1,234,567")
"""
return f"{num:,}"