Files
zeroclock/src/utils/rounding.ts
Your Name c7b9822e48 feat: add daily/weekly goals, streaks, and time rounding
Settings Timer tab now has daily/weekly goal hour inputs. Dashboard
shows goal progress bars and streak counter. Settings Billing tab
has rounding toggle with increment and method selectors. New
rounding.ts utility for nearest/up/down time rounding.
2026-02-18 10:51:56 +02:00

11 lines
469 B
TypeScript

export function roundDuration(seconds: number, incrementMinutes: number, method: 'nearest' | 'up' | 'down'): number {
if (incrementMinutes <= 0) return seconds
const incSeconds = incrementMinutes * 60
switch (method) {
case 'up': return Math.ceil(seconds / incSeconds) * incSeconds
case 'down': return Math.floor(seconds / incSeconds) * incSeconds
case 'nearest': return Math.round(seconds / incSeconds) * incSeconds
default: return seconds
}
}