From a4b458d3b26f36e32b229097fef742bb85f76a80 Mon Sep 17 00:00:00 2001 From: 7000pctAUTO Date: Sat, 31 Jan 2026 13:13:06 +0000 Subject: [PATCH] Initial upload with CI/CD workflow --- shellhist/utils/__init__.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 shellhist/utils/__init__.py diff --git a/shellhist/utils/__init__.py b/shellhist/utils/__init__.py new file mode 100644 index 0000000..2547cc3 --- /dev/null +++ b/shellhist/utils/__init__.py @@ -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"