✨ Include the active period in the remaining time display

This commit is contained in:
2026-12-03 19:17:46 +01:00
parent 9118663101
commit aa96c37860
7 changed files with 91 additions and 36 deletions
+9 -4
View File
@@ -8,8 +8,11 @@
dayExpectedMs,
entriesForRange,
reopenWeek,
runningDurationMs,
runningEntry,
todayKey,
weekExpectedMs
weekExpectedMs,
workedMsForDay
} from '$lib/app.svelte';
import type { Doc } from '$lib/db.svelte';
import type { ClosedDay } from '$lib/types';
@@ -107,12 +110,13 @@
const DAY_NAMES = ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'];
let running = $derived(runningEntry());
let runningMs = $derived(runningDurationMs());
function dayWorkedMs(dk: string): number {
const cd = closedDaysMap[dk];
if (cd) return cd.worked_ms;
return weekEntries
.filter((e) => e.day_key === dk && e.end_time != null)
.reduce((sum, e) => sum + (e.end_time! - e.start_time), 0);
return workedMsForDay(dk);
}
const totalWorkedMs = $derived(
@@ -162,6 +166,7 @@
weekdayLabel={DAY_NAMES[i]}
workedMs={dayWorkedMs(dk)}
expectedMs={dayExpectedMs(dk)}
runningMs={running?.day_key === dk ? runningMs : 0}
kind={closedDaysMap[dk]?.kind ?? null}
closed={!!closedDaysMap[dk]}
isToday={dk === todayKey()}