To-DO abgearbeitet
This commit is contained in:
@@ -117,6 +117,21 @@ function getWeekDatesFromCalendarWeek(year, weekNumber) {
|
||||
};
|
||||
}
|
||||
|
||||
// Helper: Berechnet week_start (Montag) aus einem Datum
|
||||
function getWeekStart(dateStr) {
|
||||
const date = new Date(dateStr);
|
||||
const day = date.getDay(); // 0 = Sonntag, 1 = Montag, ..., 6 = Samstag
|
||||
const diff = day === 0 ? -6 : 1 - day; // Montag = 1, Sonntag = 0
|
||||
const monday = new Date(date);
|
||||
monday.setDate(date.getDate() + diff);
|
||||
|
||||
// Format: YYYY-MM-DD
|
||||
const year = monday.getFullYear();
|
||||
const month = String(monday.getMonth() + 1).padStart(2, '0');
|
||||
const dayOfMonth = String(monday.getDate()).padStart(2, '0');
|
||||
return `${year}-${month}-${dayOfMonth}`;
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
hasRole,
|
||||
getDefaultRole,
|
||||
@@ -127,5 +142,6 @@ module.exports = {
|
||||
formatDate,
|
||||
formatDateTime,
|
||||
getCalendarWeek,
|
||||
getWeekDatesFromCalendarWeek
|
||||
getWeekDatesFromCalendarWeek,
|
||||
getWeekStart
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user