From fe69bcb357daada9e02a453819d871edc96e6572 Mon Sep 17 00:00:00 2001 From: Felix Schlusche Date: Fri, 31 Oct 2025 19:00:45 +0100 Subject: [PATCH] feat: update pause duration logic to comply with German law based on target work hours --- public/js/main.js | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/public/js/main.js b/public/js/main.js index 396f30a..03fdc83 100644 --- a/public/js/main.js +++ b/public/js/main.js @@ -401,15 +401,19 @@ function updateTimerMetrics(netElapsedSeconds) { // Target hours from user selection (default 8) const targetSeconds = targetHours * 60 * 60; - // Calculate total pause time: 30 min after 6h + 15 min after 9h - const pauseDuration30Min = 30 * 60; // 30 minutes in seconds - const pauseDuration15Min = 15 * 60; // 15 minutes in seconds + // Calculate required pause time based on target hours (German law) + let totalPauseSeconds = 0; + if (targetHours > 9) { + // More than 9h -> 45 min pause (30 + 15) + totalPauseSeconds = 45 * 60; + } else if (targetHours > 6) { + // More than 6h -> 30 min pause + totalPauseSeconds = 30 * 60; + } + // 6h or less -> no mandatory pause - // Time needed including pauses - // After 6h work -> 30 min pause - // After 9h work -> 15 min pause - // Total gross time = target work hours + 30min pause + 15min pause - const totalGrossTimeNeeded = targetSeconds + pauseDuration30Min + pauseDuration15Min; + // Total gross time = target work hours + pause time + const totalGrossTimeNeeded = targetSeconds + totalPauseSeconds; // Calculate when target will be reached (clock time) const targetReachedTimestamp = new Date(timerStartTime + totalGrossTimeNeeded * 1000);