Trainingstag aus .env
This commit is contained in:
parent
7dc599f11b
commit
58c0f55c7c
|
@ -6,4 +6,6 @@ MAILFROM=
|
||||||
MAILPASS=
|
MAILPASS=
|
||||||
PORT=2000
|
PORT=2000
|
||||||
TELEBOT=
|
TELEBOT=
|
||||||
TELECHAT=
|
TELECHAT=
|
||||||
|
HOST=
|
||||||
|
WEEKDAY=4
|
9
app.js
9
app.js
|
@ -157,11 +157,12 @@ const addNewSpiel = async (spielName) => {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
function getThursdayOfWeek(week, year) {
|
function getdayOfWeek(week, year) {
|
||||||
|
const weekday = parseInt(process.env.WEEKDAY, 10);
|
||||||
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 <= 4 ? 4 - dayOfWeek : 11 - dayOfWeek;
|
dayOfWeek <= weekday ? weekday - dayOfWeek : 11 - dayOfWeek;
|
||||||
const daysUntilThursdayOfWeek = (week - 1) * 7 + daysUntilFirstThursday;
|
const daysUntilThursdayOfWeek = (week - 1) * 7 + daysUntilFirstThursday;
|
||||||
const thursdayOfWeek = new Date(year, 0, 1 + daysUntilThursdayOfWeek);
|
const thursdayOfWeek = new Date(year, 0, 1 + daysUntilThursdayOfWeek);
|
||||||
return thursdayOfWeek;
|
return thursdayOfWeek;
|
||||||
|
@ -677,7 +678,7 @@ app.get("/training", requireAuth, async (req, res) => {
|
||||||
);
|
);
|
||||||
const trainingsDates = trainingsResult.rows.map((tr) => ({
|
const trainingsDates = trainingsResult.rows.map((tr) => ({
|
||||||
kw: tr.kw,
|
kw: tr.kw,
|
||||||
datum: formatDate(getThursdayOfWeek(tr.kw, tr.jahr)),
|
datum: formatDate(getdayOfWeek(tr.kw, tr.jahr)),
|
||||||
}));
|
}));
|
||||||
|
|
||||||
// Vorheriges Training ermitteln
|
// Vorheriges Training ermitteln
|
||||||
|
@ -737,7 +738,7 @@ ORDER BY r.riegennummer, t.geburtsdatum ASC;
|
||||||
});
|
});
|
||||||
|
|
||||||
if (training) {
|
if (training) {
|
||||||
training.datum = getThursdayOfWeek(training.kw, training.jahr);
|
training.datum = getdayOfWeek(training.kw, training.jahr);
|
||||||
}
|
}
|
||||||
|
|
||||||
const aufwaermleiterCandidates = await getCandidatesForAufwaermleiter();
|
const aufwaermleiterCandidates = await getCandidatesForAufwaermleiter();
|
||||||
|
|
Loading…
Reference in New Issue