mirror of
https://github.com/hex248/sprint.git
synced 2026-02-08 18:33:01 +00:00
organisation level time tracking data, export as JSON or CSV
This commit is contained in:
@@ -69,3 +69,19 @@ export const isLight = (hex: string): boolean => {
|
||||
export const unCamelCase = (str: string): string => {
|
||||
return str.replace(/([a-z])([A-Z])/g, "$1 $2").replace(/^./, (char) => char.toUpperCase());
|
||||
};
|
||||
|
||||
export const formatDuration = (ms: number): string => {
|
||||
if (ms === 0) return "0s";
|
||||
|
||||
const totalSeconds = Math.floor(ms / 1000);
|
||||
const hours = Math.floor(totalSeconds / 3600);
|
||||
const minutes = Math.floor((totalSeconds % 3600) / 60);
|
||||
const seconds = totalSeconds % 60;
|
||||
|
||||
const parts: string[] = [];
|
||||
if (hours > 0) parts.push(`${hours}h`);
|
||||
if (minutes > 0) parts.push(`${minutes}m`);
|
||||
if (seconds > 0 || (hours === 0 && minutes === 0)) parts.push(`${seconds}s`);
|
||||
|
||||
return parts.join(" ") || "0s";
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user