add daily/weekly goals, streaks, and time rounding
This commit is contained in:
10
src/utils/rounding.ts
Normal file
10
src/utils/rounding.ts
Normal file
@@ -0,0 +1,10 @@
|
||||
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
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user