Initial release v1.0.0

This commit is contained in:
Kevin O'Neill
2025-12-25 18:58:06 -06:00
commit 021aec7a63
439 changed files with 116588 additions and 0 deletions

View File

@@ -0,0 +1,55 @@
/**
* Format seconds into a human-readable time string
* For durations under 1 hour: m:ss (e.g., 5:32)
* For durations 1 hour or more: h:mm:ss (e.g., 1:05:32)
*/
export function formatTime(seconds: number): string {
if (isNaN(seconds) || !isFinite(seconds) || seconds < 0) return "0:00";
const hours = Math.floor(seconds / 3600);
const mins = Math.floor((seconds % 3600) / 60);
const secs = Math.floor(seconds % 60);
if (hours > 0) {
return `${hours}:${mins.toString().padStart(2, "0")}:${secs.toString().padStart(2, "0")}`;
}
return `${mins}:${secs.toString().padStart(2, "0")}`;
}
/**
* Format seconds into a human-readable duration string
* Always shows full format for clarity (e.g., "2h 30m" or "45m")
*/
export function formatDuration(seconds: number): string {
if (isNaN(seconds) || !isFinite(seconds) || seconds < 0) return "0m";
const hours = Math.floor(seconds / 3600);
const mins = Math.floor((seconds % 3600) / 60);
if (hours > 0) {
if (mins > 0) {
return `${hours}h ${mins}m`;
}
return `${hours}h`;
}
return `${mins}m`;
}