Wochentag berechnen korrektur für Jahr das am Mittwoch startet

This commit is contained in:
Klaas Börgmann 2025-01-14 15:55:03 +01:00
parent cd59aa0546
commit 898708b37c
2 changed files with 488 additions and 226 deletions

7
app.js
View File

@ -202,8 +202,10 @@ function getdayOfWeek(week, year) {
const firstDayOfYear = new Date(year, 0, 1); const firstDayOfYear = new Date(year, 0, 1);
const dayOfWeek = firstDayOfYear.getDay(); const dayOfWeek = firstDayOfYear.getDay();
const daysUntilFirstThursday = const daysUntilFirstThursday =
dayOfWeek <= weekday ? weekday - dayOfWeek : 11 - dayOfWeek; dayOfWeek <= weekday ? weekday - dayOfWeek : weekday + 7 - dayOfWeek;
const daysUntilThursdayOfWeek = (week - 1) * 7 + daysUntilFirstThursday; const weekcorrekt = daysUntilFirstThursday >= dayOfWeek ? 2 : 1;
const daysUntilThursdayOfWeek =
(week - weekcorrekt) * 7 + daysUntilFirstThursday;
const thursdayOfWeek = new Date(year, 0, 1 + daysUntilThursdayOfWeek); const thursdayOfWeek = new Date(year, 0, 1 + daysUntilThursdayOfWeek);
return thursdayOfWeek; return thursdayOfWeek;
} }
@ -789,6 +791,7 @@ ORDER BY r.riegennummer, t.geburtsdatum ASC;
}); });
}); });
if (training) { if (training) {
console.log("THIS!");
training.datum = getdayOfWeek(training.kw, training.jahr); training.datum = getdayOfWeek(training.kw, training.jahr);
} }

707
package-lock.json generated

File diff suppressed because it is too large Load Diff