This commit is contained in:
21
shellhist/utils/__init__.py
Normal file
21
shellhist/utils/__init__.py
Normal file
@@ -0,0 +1,21 @@
|
||||
"""CLI utilities for formatting and display."""
|
||||
|
||||
from datetime import datetime
|
||||
from typing import Optional
|
||||
|
||||
|
||||
def format_timestamp(ts: Optional[datetime]) -> str:
|
||||
"""Format a datetime for display."""
|
||||
if ts is None:
|
||||
return "unknown"
|
||||
return ts.strftime("%Y-%m-%d %H:%M:%S")
|
||||
|
||||
|
||||
def format_duration_hours(hours: float) -> str:
|
||||
"""Format duration in hours to human readable format."""
|
||||
if hours < 1:
|
||||
return f"{int(hours * 60)}m"
|
||||
elif hours < 24:
|
||||
return f"{int(hours)}h"
|
||||
else:
|
||||
return f"{int(hours / 24)}d"
|
||||
Reference in New Issue
Block a user