Skip to content
Snippets Groups Projects
Commit d73b9250 authored by Iziram's avatar Iziram
Browse files

Assiduité : signal_assiduites_hedbo : v1 OK

parent dea403b0
No related branches found
No related tags found
No related merge requests found
......@@ -430,3 +430,23 @@ class Duration {
function hasTimeConflict(period, interval) {
return period.deb.isBefore(interval.fin) && period.fin.isAfter(interval.deb);
}
// Fonction auxiliaire pour obtenir le numéro de semaine ISO d'une date donnée
function getISOWeek(date) {
const target = new Date(date.valueOf());
const dayNr = (date.getUTCDay() + 6) % 7;
target.setUTCDate(target.getUTCDate() - dayNr + 3);
const firstThursday = target.valueOf();
target.setUTCMonth(0, 1);
if (target.getUTCDay() !== 4) {
target.setUTCMonth(0, 1 + ((4 - target.getUTCDay() + 7) % 7));
}
return 1 + Math.ceil((firstThursday - target) / 604800000);
}
// Fonction auxiliaire pour obtenir le nombre de semaines ISO dans une année donnée
function getISOWeeksInYear(year) {
const date = new Date(year, 11, 31);
const week = getISOWeek(date);
return week === 1 ? getISOWeek(new Date(year, 11, 24)) : week;
}
This diff is collapsed.
......@@ -2072,6 +2072,45 @@ def signal_assiduites_hebdo():
# TODO vérif perm AbsChange -> readonly
# Gestion des jours
jours: dict[str, list[str]] = {
"lun": [
"Lundi",
datetime.datetime.strptime(week + "-1", "%G-W%V-%u").strftime("%d/%m/%Y"),
],
"mar": [
"Mardi",
datetime.datetime.strptime(week + "-2", "%G-W%V-%u").strftime("%d/%m/%Y"),
],
"mer": [
"Mercredi",
datetime.datetime.strptime(week + "-3", "%G-W%V-%u").strftime("%d/%m/%Y"),
],
"jeu": [
"Jeudi",
datetime.datetime.strptime(week + "-4", "%G-W%V-%u").strftime("%d/%m/%Y"),
],
"ven": [
"Vendredi",
datetime.datetime.strptime(week + "-5", "%G-W%V-%u").strftime("%d/%m/%Y"),
],
"sam": [
"Samedi",
datetime.datetime.strptime(week + "-6", "%G-W%V-%u").strftime("%d/%m/%Y"),
],
"dim": [
"Dimanche",
datetime.datetime.strptime(week + "-7", "%G-W%V-%u").strftime("%d/%m/%Y"),
],
}
non_travail = sco_preferences.get_preference("non_travail")
non_travail = non_travail.replace(" ", "").split(",")
hebdo_jours: list[tuple[bool, str]] = []
for key, val in jours.items():
hebdo_jours.append((key in non_travail, val))
return render_template(
"assiduites/pages/signal_assiduites_hebdo.j2",
gr=gr_tit,
......@@ -2079,6 +2118,7 @@ def signal_assiduites_hebdo():
moduleimpl_select=_module_selector(
formsemestre=formsemestre, moduleimpl_id=moduleimpl_id
),
hebdo_jours=hebdo_jours,
)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment