export function formatTimer(totalSeconds: number) { const hours = Math.floor(totalSeconds / 3600); const minutes = Math.floor((totalSeconds % 3600) / 60); const seconds = totalSeconds % 60; return [hours, minutes, seconds].map((part) => String(part).padStart(2, "0")).join(":"); } export function formatMinutes(minutes: number) { const hours = Math.floor(minutes / 60); const rest = minutes % 60; if (hours === 0) { return `${rest} min`; } if (rest === 0) { return `${hours} h`; } return `${hours} h ${rest} min`; } export function formatDateTime(value: string) { return new Intl.DateTimeFormat("de-DE", { dateStyle: "medium", timeStyle: "short" }).format(new Date(value)); } export function formatDate(value: string) { return new Intl.DateTimeFormat("de-DE", { weekday: "long", day: "2-digit", month: "2-digit", year: "numeric" }).format(new Date(value)); } export function formatTime(value: string) { return new Intl.DateTimeFormat("de-DE", { hour: "2-digit", minute: "2-digit" }).format(new Date(value)); } export function formatTimeRange(start: string, end: string) { return `${formatTime(start)} - ${formatTime(end)}`; } export function currentMonth() { const now = new Date(); return `${now.getFullYear()}-${String(now.getMonth() + 1).padStart(2, "0")}`; } export function currentWeek() { const now = new Date(); const date = new Date(Date.UTC(now.getFullYear(), now.getMonth(), now.getDate())); const weekday = date.getUTCDay() || 7; date.setUTCDate(date.getUTCDate() + 4 - weekday); const yearStart = new Date(Date.UTC(date.getUTCFullYear(), 0, 1)); const week = Math.ceil(((date.getTime() - yearStart.getTime()) / 86_400_000 + 1) / 7); return `${date.getUTCFullYear()}-W${String(week).padStart(2, "0")}`; } export function currentDay() { const now = new Date(); return `${now.getFullYear()}-${String(now.getMonth() + 1).padStart(2, "0")}-${String(now.getDate()).padStart(2, "0")}`; }