feat(api): user-scoped CSV export matching legacy format
This commit is contained in:
13
apps/api/src/lib/csv.ts
Normal file
13
apps/api/src/lib/csv.ts
Normal file
@@ -0,0 +1,13 @@
|
||||
// CSV helpers ported verbatim from the legacy export route (docs/reference/legacy-backend.md §4).
|
||||
|
||||
// Wrap a value in double quotes, doubling any embedded double quote (standard CSV escaping).
|
||||
export const quote = (value: unknown) => `"${String(value).replace(/"/g, '""')}"`;
|
||||
|
||||
// Format a total number of seconds as zero-padded HH:MM:SS (hours can exceed 99).
|
||||
export function formatDuration(totalSeconds: number): string {
|
||||
const s = totalSeconds || 0;
|
||||
const h = Math.floor(s / 3600);
|
||||
const m = Math.floor((s % 3600) / 60);
|
||||
const sec = s % 60;
|
||||
return `${String(h).padStart(2, '0')}:${String(m).padStart(2, '0')}:${String(sec).padStart(2, '0')}`;
|
||||
}
|
||||
Reference in New Issue
Block a user