Umstellung auf anzeige x h y min
This commit is contained in:
@@ -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
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user