Umstellung auf anzeige x h y min

This commit is contained in:
2026-02-13 12:21:43 +01:00
parent 23c255438b
commit af1f6efb40
8 changed files with 117 additions and 94 deletions

View File

@@ -132,6 +132,22 @@ function getWeekStart(dateStr) {
return `${year}-${month}-${dayOfMonth}`;
}
// Helper: Dezimalstunden in Anzeige "X h Y min" (z. B. 8.25 -> "8 h 15 min", -1.5 -> "-1 h 30 min")
function formatHoursMin(decimalHours) {
if (decimalHours == null || !Number.isFinite(Number(decimalHours))) return '0 h 0 min';
const n = Number(decimalHours);
const sign = n < 0 ? -1 : 1;
const absVal = Math.abs(n);
let h = Math.floor(absVal);
let min = Math.round((absVal - h) * 60);
if (min >= 60) {
h += 1;
min = 0;
}
const prefix = sign < 0 ? '-' : '';
return prefix + h + ' h ' + min + ' min';
}
module.exports = {
hasRole,
getDefaultRole,
@@ -143,5 +159,6 @@ module.exports = {
formatDateTime,
getCalendarWeek,
getWeekDatesFromCalendarWeek,
getWeekStart
getWeekStart,
formatHoursMin
};