make time entry calendar use seconds as a duration basis, fixes #996

This commit is contained in:
Gregor Vostrak
2026-01-14 18:41:06 +01:00
parent 5a05ee35e0
commit 19064cdc3d
2 changed files with 9 additions and 9 deletions

View File

@@ -6,10 +6,10 @@ import type { Dayjs } from 'dayjs';
const props = defineProps<{ const props = defineProps<{
date: Dayjs; date: Dayjs;
totalMinutes?: number; totalSeconds?: number;
}>(); }>();
const totalSeconds = computed(() => (props.totalMinutes ?? 0) * 60); const totalSecondsValue = computed(() => props.totalSeconds ?? 0);
// Injected organization for formatting settings // Injected organization for formatting settings
const organization = inject('organization') as ComputedRef<Organization | undefined> | undefined; const organization = inject('organization') as ComputedRef<Organization | undefined> | undefined;
@@ -25,7 +25,7 @@ const dateFormat = computed(() => organization?.value?.date_format);
</div> </div>
<span class="text-xs">{{ formatDate(date.toISOString(), dateFormat) }}</span> <span class="text-xs">{{ formatDate(date.toISOString(), dateFormat) }}</span>
<span class="block text-xs text-muted-foreground font-medium mt-1"> <span class="block text-xs text-muted-foreground font-medium mt-1">
{{ formatHumanReadableDuration(totalSeconds, intervalFormat, numberFormat) }} {{ formatHumanReadableDuration(totalSecondsValue, intervalFormat, numberFormat) }}
</span> </span>
</div> </div>
</template> </template>

View File

@@ -179,20 +179,20 @@ const dailyTotals = computed(() => {
const totals: Record<string, number> = {}; const totals: Record<string, number> = {};
props.timeEntries.forEach((entry) => { props.timeEntries.forEach((entry) => {
const date = getDayJsInstance()(entry.start).format('YYYY-MM-DD'); const date = getDayJsInstance()(entry.start).format('YYYY-MM-DD');
let duration: number; let durationSeconds: number;
if (entry.end !== null) { if (entry.end !== null) {
// Completed entry // Completed entry
duration = getDayJsInstance()(entry.end).diff( durationSeconds = getDayJsInstance()(entry.end).diff(
getDayJsInstance()(entry.start), getDayJsInstance()(entry.start),
'minutes' 'seconds'
); );
} else { } else {
// Running entry - use current time // Running entry - use current time
duration = currentTime.value.diff(getDayJsInstance()(entry.start), 'minutes'); durationSeconds = currentTime.value.diff(getDayJsInstance()(entry.start), 'seconds');
} }
totals[date] = (totals[date] || 0) + duration; totals[date] = (totals[date] || 0) + durationSeconds;
}); });
return totals; return totals;
}); });
@@ -444,7 +444,7 @@ onUnmounted(() => {
:date=" :date="
getDayJsInstance()(arg.date.toISOString()).utc().tz(getUserTimezone(), true) getDayJsInstance()(arg.date.toISOString()).utc().tz(getUserTimezone(), true)
" "
:total-minutes=" :total-seconds="
dailyTotals[ dailyTotals[
getDayJsInstance()(arg.date) getDayJsInstance()(arg.date)
.utc() .utc()